我正在动态生成框,margin-left当屏幕溢出时,我在框之间给出它转到下一行,但从左边距开始。如何删除下一行留下的这个边距。
<div style="width: 200px; height: 200px; background-color: green; float: left;">test</div>
<div style="width: 200px; height: 200px; background-color: green; margin-left: 10px; float: left;">test</div>
<div style="width: 200px; height: 200px; background-color: green; margin-left: 10px; float: left;">test</div>
<div style="width: 200px; height: 200px; background-color: green; margin-left: 10px; float: left;">test</div>
<div style="width: 200px; height: 200px; background-color: green; margin-left: 10px; float: left;">test</div>
<div style="width: 200px; height: 200px; background-color: green; margin-left: 10px; float: left;">test</div>
Run Code Online (Sandbox Code Playgroud)
问题:
这是小提琴链接:https : //jsfiddle.net/jotftL3z/1/
你可以改为给它 margin-right :)
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<div style="width: 200px; height: 200px; background-color: green; margin-right:10px;float: left;">test</div>
<div style="width: 200px; height: 200px; background-color: green; margin-right:10px; float: left;">test</div>
<div style="width: 200px; height: 200px; background-color: green; margin-right:10px; float: left;">test</div>
<div style="width: 200px; height: 200px; background-color: green; margin-right:10px; float: left;">test</div>
<div style="width: 200px; height: 200px; background-color: green; margin-right:10px; float: left;">test</div>
<div style="width: 200px; height: 200px; background-color: green; margin-right:10px; float: left;">test</div>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
从所有 div 中删除 margin-left 并添加 margin-right。如果您想要左侧空间,请将所有 div 放入一个 div 中,并指定 margin-left 或 padding-left。