Html 在浮动子对象上使用100%高度
我有一个父div,里面有两个div。 第一个div将位于左侧,其中一个图片高度为100%,另一个位于右侧,内容位于其旁边 我无法使左div跟随父div。 高度100%不工作 请参见正在发生的事情中的照片: 结果是: 下面是我在JSFIDLE中的代码: HTML: 有人能帮我吗?试试下面的代码: css:Html 在浮动子对象上使用100%高度,html,css,Html,Css,我有一个父div,里面有两个div。 第一个div将位于左侧,其中一个图片高度为100%,另一个位于右侧,内容位于其旁边 我无法使左div跟随父div。 高度100%不工作 请参见正在发生的事情中的照片: 结果是: 下面是我在JSFIDLE中的代码: HTML: 有人能帮我吗?试试下面的代码: css: 您可以尝试向左浮动.enquete foto和.enquete数据,并将父divs背景设置为蓝色,如下所示: .enquete-foto, enquete-data { float:l
您可以尝试向左浮动.enquete foto和.enquete数据,并将父divs背景设置为蓝色,如下所示:
.enquete-foto, enquete-data {
float:left;
display:block;
}
.enquete-foto img {
height: 100%
}
.enquetes-listagem .enquete {
background: blue;
display:block;
min-height: 70px; #This could be any height?
}
下面是一个使用表的解决方案:
那不行,你看过自己的小提琴了吗?现在检查并提问!我给了家长一个高度!子dive将继承其父div的高度!就像magicI一样,根据OP添加的图像,不要认为这是OP想要的:现在当尝试添加更多内容时,另一个div不会跟随->只需增加父级的大小或将其设置为自动
body {
font-family: Arial, Verdana, Helvetica, sans-serif;
}
a {
color: #428bca;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* div pai */
.enquetes-listagem .enquete {
background: yellow;
padding-bottom: 5px;
margin-bottom: 5px;
border-bottom: 1px solid #eee;
}
/* div filho esquerda */
.enquetes-listagem .enquete .enquete-foto {
max-width: 34px;
float: left;
margin-right: 10px;
height: 100%; /* Not Work, why???? */
background: red;
}
/* div filho direita */
.enquetes-listagem .enquete .enquete-data {
background: blue;
}
body {
font-family: Arial, Verdana, Helvetica, sans-serif;
}
a {
color: #428bca;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.enquetes-listagem .enquete {
background: yellow;
padding-bottom: 5px;
margin-bottom: 5px;
border-bottom: 1px solid #eee;
position:relative;
height:60px;
}
.enquetes-listagem .enquete .enquete-foto {
position:absolute;
max-width: 34px;
float: left;
margin-right: 10px;
width:100%;
overflow:auto;
background: red;
height:inherit;
}
.enquetes-listagem .enquete .enquete-data {
position:absolute;
margin-left: 34px;
float: left;
background: blue;
height:inherit;
}
.enquete-foto, enquete-data {
float:left;
display:block;
}
.enquete-foto img {
height: 100%
}
.enquetes-listagem .enquete {
background: blue;
display:block;
min-height: 70px; #This could be any height?
}
body {
font-family: Arial, Verdana, Helvetica, sans-serif;
}
a {
color: #428bca;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* div pai */
.enquetes-listagem .enquete {
background: yellow;
padding-bottom: 5px;
margin-bottom: 5px;
border-bottom: 1px solid #eee;
display: table;
width: 100%;
}
.enquetes-listagem .enquete .enquete-foto {
width: 34px;
background: red;
display: table-cell;
vertical-align: top;
}
.enquetes-listagem .enquete .enquete-data {
background: blue;
display: table-cell;
}