我正在尝试将图像放置在容器内的右侧。但是,在我将父容器设置为 position: relative;
之后,我的图像消失了。有任何想法吗?网站: http ://andrewgu12.kodingen.com/。谢谢!
CSS:
.slide {
padding-top: 138px;
background-attachment: fixed;
width: 100%;
height: 100%;
position: relative;
box-shadow:inset 0px 10px 10px rgba(0,0,0,0.3);
}
div#inner-container {
text-align: left;
width: 960px;
margin: 0 auto;
padding: 0;
white-space: normal;
position: relative;
}
div#name {
right: 0;
bottom: 200px;
position: absolute;
}
HTML:
<div class="slide" id="home" data-slide="1" data-stellar-background-ratio="1">
<div id="inner-container">
<div id="name" clas="row">
<img src="images/names.png">
</div>
</div>
</div>
原文由 Andrew 发布,翻译遵循 CC BY-SA 4.0 许可协议
它不会消失,它只是一直上升并离开监视器 xD 你必须记住,当你使用
position: absolute
对象将寻找具有position: relative
的父对象定位自己。当您将position: relative
添加到div#inner-container
时,它会更改div#name.row
参考。也许将height: 100%;
添加到父div
可能会达到你想要的效果?