我想用margin
向col
添加一些mr-md-3
,但这会导致中断
div
.content {
height: 200px;
border: 1px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<div class="container">
<div class="row no-gutters">
<div class="col-md-4 col-12 content mr-md-3 mb-3"></div>
<div class="col-md-8 col-12 content mb-3"></div>
</div>
</div>
<footer>
<div class="container">
<div class="row no-gutters">
<div class="col-md-4 col-12 content mb-3"></div>
<div class="col-md-8 col-12 content mb-3"></div>
</div>
</div>
</footer>
我需要不间断地在元素上添加一些边距权,并且要适合全局container
,我该怎么做?
注意:请参见高分辨率示例。
答案 0 :(得分:3)
您要做的就是将flex: 1;
送给相邻的div
。
现在,您可以使margin
更大,并且problem
列将相应缩小。
.container .problem{flex: 1;}
.content {
height: 200px;
border: 1px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<div class="container">
<div class="row no-gutters">
<div class="col-md-4 col-12 content mr-md-3 mb-3"></div>
<div class="col-md-8 col-12 content problem mb-3"></div>
</div>
</div>
<footer>
<div class="container">
<div class="row no-gutters">
<div class="col-md-4 col-12 content mb-3"></div>
<div class="col-md-8 col-12 content mb-3"></div>
</div>
</div>
</footer>
答案 1 :(得分:2)