我有以下HTML页面:https://jsfiddle.net/fk42dw85/
我想将橙色块放置在div容器的底部而不是顶部。我该如何实现?
.container {
margin-top: 20px;
margin-bottom: 20px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script>
<div style="background:url('https://dynaimage.cdn.cnn.com/cnn/q_auto,w_826,c_fill/http%3A%2F%2Fcdn.cnn.com%2Fcnnnext%2Fdam%2Fassets%2F131126191411-strahov-abbey-library.jpg');height:200px;">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-6" style="background:orange">
test
</div>
</div>
</div>
</div>
</div>
</div>
答案 0 :(得分:2)
假设您想要一个与页脚相关的图像。我建议您采用以下方法,这种方法要简单得多,请让我知道是否适合您。
<div class="container">
<div class="image"></div>
<div class="image-footer">
This is the footer of the image
</div>
</div>
.image {
background: url('https://dynaimage.cdn.cnn.com/cnn/q_auto,w_826,c_fill/http%3A%2F%2Fcdn.cnn.com%2Fcnnnext%2Fdam%2Fassets%2F131126191411-strahov-abbey-library.jpg');
height:200px;
}
.container {
margin-top: 20px;
margin-bottom: 20px;
}
.image-footer {
background: orange;
opacity: 0.8;
}
以下是对jsfiddle进行的更改:https://jsfiddle.net/rdarioduarte/fk42dw85/91/
答案 1 :(得分:2)
答案 2 :(得分:1)
.container {
margin-top: 20px;
margin-bottom: 20px;
position: absolute;
bottom: 0;
left: calc(50% - 270px);
}
.parentContainer {
position: relative;
}
答案 3 :(得分:0)
您也可以尝试此解决方案,该解决方案避免使用绝对定位
payment_id
根据需要调整top属性的值。