Home > Web Front-end > JS Tutorial > body text

Set width based on percentage

巴扎黑
Release: 2016-12-06 11:21:17
Original
1443 people have browsed it

   var grid_width; 
var grid_init=false; 

function caculate_grid_width_func(){ 


var tabPanel = $('#documentlist').closest('.tabs-panels'); 
if(tabPanel.length>0){ 
grid_width = tabPanel.width(); 
}else{ 
grid_width=$('#documentlist').width(); 





/**Set percentage*/ 
function count_width_func(columnWidth){ 
var result = 128; 
var diff = 0; 
columnWidth=null==columnWidth||''==columnWidth||'100%'==columnWidth?'128':columnWidth; 

if ( $.browser.msie ){ 
if('9.0'==$.browser.version ) 
diff=3; 
else if('8.0'==$.browser.version ) 
diff=3; 
else 
diff=6; 

else if($.browser.chrome) 
diff=5; 
else 
diff=2; 

if(columnWidth.indexOf('%')>0){ 
columnWidth=columnWidth.replace('%','')*1; 
result=grid_width*columnWidth/100; 

else if(columnWidth.indexOf('px')>0){ 
columnWidth=columnWidth.replace('px',''); 
result=columnWidth; 

else 
result=columnWidth; 
return Math.ceil(result)-diff; 
}

Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!