我有一个带背景图片和文字的超大屏幕。我需要调整图像,以便文本不会与背景图像的任何部分发生碰撞。
HTML:
<div class="jumbotron">
<div class="container">
<h1>Header title text</h1>
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. </p>
</div>
</div>
CSS:
.jumbotron {
position: relative;
background: #fff url("https://s3.us-east-2.amazonaws.com/ftp-assets/family.png") center center;
width: 100%;
height: 400px;
background-size: cover;
}
h1 {
margin-top: -30px;
margin-left: -20px;
}
p {
margin-left: -2%;
}
的jsfiddle:https://jsfiddle.net/2ek2e2rf/
答案 0 :(得分:0)
尝试转换为以下内容:
<div class="jumbotron jumbotron-fluid bg-dark">
<div class="jumbotron-background">
<img src="assets/background_img4.jpg" class="blur ">
</div>
<div class="container text-white" style="background-color: transparent; border: none;">
<h1>Some text</h1>
</div>
</div>
然后,您可以通过更改以下属性来调整背景:
.jumbotron-background {
top: 50px;
bottom: 50px;
left: 50px;
right: 50px;
}