我想知道如何放置一個div盒(我想要放置圖像)以便它出現在中心底部的另一個div的頂部。居中在另一個div的底部的div
我想下面的代碼:
<html>
<body>
<style type="text/css">
.outer {
width: 350px;
height: 350px;
}
.inner {
width: 100px;
height: 100px;
background-color: red;
}
</style>
<div class="outer">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pellentesque, neque ut ultrices posuere, velit arcu aliquam dui, id rutrum justo leo nec purus. Donec aliquet justo a est iaculis id porta nulla pulvinar. Proin quis turpis vitae augue volutpat volutpat. Donec volutpat accumsan urna, id vulputate augue euismod eu. In vitae libero tortor. Integer lacinia, turpis vel egestas ornare, nisi libero tempus orci, non imperdiet erat nulla malesuada lectus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
<div class="inner"></div>
</div>
</body>
</html>
將它與像素值的位置,但是應當'左:125px'(350-100)/ 2 = 125。然而,有一種方法使其居中爲任意大小的元件 – jackwanders