酒吧= 500像素,紅色框= 1,黃色盒= 1,綠盒子= 2的總寬度,
CSS:
.box {
float:left;
width:150px;
box-shadow:3px 3px 2px #666767;
height:30px;
}
.red {
background-color:#ff0000;
width:150px;
}
.yellow {
background-color:#ffff00;
width:200px;
}
.green {
background-color:#00ff00;
width:50px;
}
HTML代碼:
content += "<div class=\"box-container\">
<div class=\"box red\">
</div>
<div class=\"box yellow\">
</div>
<div class=\"box green\">
</div>
</div>
</br>";
從這我想要計算紅色框,黃色框和綠色框的px框的寬度。
你的意思是在這種情況下,Redbox的寬度應該是25%,黃色-25%和綠色50%? –
這取決於框的大小(內容框,邊框)以及您想要的邊距和填充。 – gus27
@ArunKumarMk問題不明確。你需要分享一些代碼。你的* PX *只是元素的「高度和寬度」。 –