1
我已經離開了很長時間,我開始了我的第一個建造多年。這可能是幾年來編碼防鏽之前不會成爲問題的東西!:我認爲這是一個非常基本的問題,但它讓我感到非常緊張。部門沒有正確對齊
我已經構建了兩個容器。容器1(紅色)應該有一個圖像,並很好地調整到70%的顯示。
Container2(綠色的)是用於標題等,但我不能讓它坐在Container1下。目前它堅守在頁面頂部。
任何與此有關的幫助將大規模讚賞。
#container1 {
width: 70%;
height: 70%;
position: absolute;
margin: auto;
top: 136px;
bottom: 0;
left: 0;
right: 0;
background-color: red;
z-index: 2;
display: inline-block;
}
#container2 {
width: 100%;
height: 50px;
position: relative;
left: 0;
right: 0;
background-color: green;
z-index: 2;
display: inline-block;
}
img {
max-width: 100%;
max-height: 100%;
position: absolute;
margin: auto;
border: 4px solid #ffffff;
border-bottom: 4px solid #ffffff;
box-shadow: 1px 1px 5px 1px #c9c9c9;
top: 0;
padding-bottom: 0px;
left: 0;
right: 0;
}
<html>
<head>
<link rel="stylesheet" href="layout.css">
</head>
<body>
<div id="container1">
<img src="image.jpg" alt="image" style="padding: 0px 0px 0px 0px;" align="center" />
</div>
<div id="container2">
CAPTION INFO TO GO HERE
</div>
</body>
</html>
製作容器中的兩個顯示塊,而不是內聯塊,並給予一試 –
您可能還檢查了''標籤。它默認包含圖像和標題的空間。是的,放棄絕對/相對定位,沒有必要。 –