简体   繁体   English

底部对齐浮动div。 ( 图片 )

[英]Bottom align a floated div. ( image )

This seemed simple in my head.. But it's not. 在我看来,这很简单。但是事实并非如此。 I have 2 div's. 我有2个div。 floating next to eachother The right div should have an image that is always sticking to the footer 彼此相邻浮动右div的图像应始终贴在页脚上

It's not even applying the 100% Height of my .block div, the parent div ( body ) is also set at 100% 它甚至都没有应用我的.block div的100%高度,父div(body)也设置为100%

For some reason this is not working with my following code. 由于某种原因,这不适用于我的以下代码。

JSFIDDLE JSFIDDLE

HTML 的HTML

<div class="header">
    Header
</div>

<div class="block">
    <img src="http://www.zwaldtransport.com/images/placeholders/placeholder1.jpg" />
</div>

CSS 的CSS

body {
    margin: 0; 
    padding: 0; 
    width: 100%; 
    height: 100%;   
    background: url('background.jpg') no-repeat center center fixed;
    background-size: cover;
}


.header {
    float: left;
    height: 100%;
    width: 40%;
    background: red;
}

.block {
    float: left;
    width: 60%;
    height: 100%;
    background: green;
}

.block img {
    max-width: 100%;
}

You can try this. 你可以试试看 check and let me know, have you asked for this: 检查并让我知道,您是否要求过:

.header {
height: 100%;
width: 40%;
background: red;
}

.block {
position:absolute;
bottom:0;
width: 60%;
height: auto;
background: green;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM