Demo
HTML
<div class="content">Content</div>
<div class="footerLike">
<img src="http://placekitten.com/100/100" style="height:90px;position:relative;display:inline-block;" />
</div>
CSS
.content {
height:calc(100% - 102px); /* 100% - height of footer - borders */
}
.footerLike {
border:1px solid black;
height:100px;
}
body, html {
height: 100%;
width: 100%;
margin:0;
padding:0;
}
Demo,在評論
<div class="footerLike">
<div class="dummy"><!-- you can put anything here --></div>
<img src="http://placekitten.com/100/100" style="height:90px;position:relative;display:inline-block;" />
</div>
.footerLike {
border:1px solid black;
height:100%;
}
img {
height: 100%;
display: block;
}
.dummy {
height: calc(100% - 100px);
}
body, html {
height: 100%;
width: 100%;
margin:0;
padding:0;
}
出於純粹的個人好奇心說,爲什麼不使用使用'position'(不一定是絕對的)或對齊?爲什麼說,「有工具存在,所以讓我們使用......別的東西!」我在這裏的想法是什麼? –
我沒有使用其他位置的問題:但只是不是絕對的。當添加移動元素時,它會使圖像位置像瘋狂一樣起作用 – Sajeeb
啊,好的。謝謝。所以這就是真正的煩惱。我一直在想這樣的問題。再次感謝。 –