想要制作一个看起来像这样的网格,其中div/section为百分比。保证金在任何地方都一样。 http://www.ladda-upp.se/bilder/giefekcmgwmnx/股利与百分比?总计100%
如果我把margin设置为1px,但我想使用margin 1em或10px左右,下面的代码有效。我怎么做?
HTML
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" media="all" href="default.css" />
</head>
<body>
<div class="box small"></div>
<div class="box small"></div>
<div class="box small"></div>
<div class="clear"></div>
<div class="box small"></div>
<div class="box large"></div>
</body>
</html>
CSS
.box {
height:50px;
margin:1em;
background:#000;
float:left;
}
.small {
width:33%;
}
.large {
width:66%;
}
.clear{
clear:both;
}
为什么不使用其他'DIV'的'DIV.box'内,你就可以到任何保证金或填充应用到它,它不会破坏你的'DIV.box'百分比。 –