酒吧= 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 *只是元素的“高度和宽度”。 –