注意在使用 Bootstrap 时,容器 div 内的行 div 如何在容器 div 外“出现”左边距(左边距是黄色部分):
我尝试使用以下代码复制此行为:
<!DOCTYPE html>
<html>
<head>
<style>
#div1
{
width: 500px;
height: 400px;
border: 1px solid black;
margin-left: auto;
margin-right: auto;
}
#div2
{
width: 500px;
height: 200px;
background-color: red;
margin-right: 100px;
margin-left: 100px;
}
</style>
</head>
<body>
<div id="div1">
<div id="div2">
</div>
</div>
</body>
</html>
但它不起作用(左边距留在容器div内):
您可以通过使用具有负值的边距来做到这一点,如下所示:
.row {
margin-left: -15px;
margin-right: -15px;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句