如何删除新行框css的margin-left

Tha*_*vam 1 html css

我正在动态生成框,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/

aMJ*_*Jay 7

你可以改为给它 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)


Aja*_*ese 5

从所有 div 中删除 margin-left 并添加 margin-right。如果您想要左侧空间,请将所有 div 放入一个 div 中,并指定 margin-left 或 padding-left。