我有这个page,其中我在一个盒子里面显示一个视频,并希望我的背景图像有一些“边缘顶部”,因此它不会显示在框的边缘。我尝试添加background-position: 10%
,但它无效。
现在它看起来像这样:
这是我的代码:
.eu {
height: auto;
width: 100%;
background: url(images/BODY-VERDE.png);
position: absolute;
top: 0;
}
.bg-image {
position: relative;
}
.bg-image img {
display: block;
width: 100%;
/* max-width: 1200px; */
/* corresponds to max height of 450px */
margin: 0 auto;
}
.container-video {
width: 100%;
height: auto;
background: url(images/BODY-VERDE.png);
margin: 0 auto;
overflow: auto;
}
<div class="bg-image" style="width: 70%;margin: 0 auto;">
<div class="eu">
<div class="text-sus">
<p>Set us perspiciatis</p>
<p style="text-align: center;color: white;font-size: 16px;">unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore</p>
</div>
<div class="video">
<img src="images/VIDEO.png" style="width:100%;height:auto;">
</div>
</div>
<img src="images/CU-PRETURI.png">
</div>
我也尝试添加.bg-image img {margin-top:10%;}
,但随后一切都下降了,我只想要背景图片。
答案 0 :(得分:1)
尝试给出两个坐标:
background-position: 0 50px;
在以下示例中,bg图像的上边距为50px
#wrapper {
width: 100%;
height: 300px;
border: 1px solid red;
background-image: url('http://www.bestmanspeechestoasts.com/wp-content/themes/thesis/rotator/sample-4.jpg');
background-position: 0 50px;
background-repeat: no-repeat;
}
<div id="wrapper"></div>