Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何更改靠近左边缘的元素的左边距_Css_Margin - Fatal编程技术网

Css 如何更改靠近左边缘的元素的左边距

Css 如何更改靠近左边缘的元素的左边距,css,margin,Css,Margin,以下是我想做的: 我有一个包装盒。盒体,我想将靠近左边缘的所有元素的左边距更改为0 在我的示例中,我希望带有views.py和context\u processors.py的框剩余边距:0,但其余的保持不变,我想创建额外的类并重写此属性,但这不是我想要做的,因为我不知道我将拥有的框的数量可能是7,可能是20。。。。另外,如果调整窗口大小,一行中框的数量将发生变化 以下是css: .box-body { background: #ddd; width: 700px; h

以下是我想做的: 我有一个包装盒
。盒体
,我想将靠近左边缘的所有元素的
左边距
更改为
0

在我的示例中,我希望带有
views.py
context\u processors.py
的框剩余
边距:0
,但其余的保持不变,我想创建额外的类并重写此属性,但这不是我想要做的,因为我不知道我将拥有的框的数量可能是7,可能是20。。。。另外,如果调整窗口大小,一行中框的数量将发生变化

以下是css:

.box-body {
    background: #ddd;  
    width: 700px;
    height: 300px
}

.app-file {
    position: relative;
    float: left;
    margin: 10px 0 0 14px;
    display: inline-block;
    padding: 10px 18px 10px 18px;
    text-align: center;
    font-size: 16px;
    cursor: pointer;
    background: rgba(255,255,255, 0.9);
    color: rgb(68,68,68);
}

您只需在框体左侧添加负边距即可。大概是这样的:

css:


这将导致整个车身箱向左移动14px。由于它位于视口之外,因此将不可见。请注意,我还将14px添加到了宽度中,以使长方体的可见大小保持在700px。

无法100%确定您的意思。
context\u processors.py
框不靠近左边缘,而是一直向右。您想在容器上使用marginleft:10px吗?正如您所说的,您可以使用
marginleft:0px
样式向div添加一个新类。尝试为每一行使用固定的宽度,以使效果更好。
.box-body {
    background: #ddd;  
    width: 714px;
    height: 300px;
    margin-left: -14px;
}