Css Div高度不符合内容的高度
我正在尝试自动调整主div的高度,但我无法让它工作。我已经把620px,所以你可以看到的内容,但想让它适合它的内容 CSS代码:Css Div高度不符合内容的高度,css,Css,我正在尝试自动调整主div的高度,但我无法让它工作。我已经把620px,所以你可以看到的内容,但想让它适合它的内容 CSS代码: #distributors { } #distributors input { height: 2.5em; visibility: hidden; } #distributors input.visible { visibility: visible !important; } #distributors label { bac
#distributors {
}
#distributors input {
height: 2.5em;
visibility: hidden;
}
#distributors input.visible {
visibility: visible !important;
}
#distributors label {
background: #f9f9f9;
border-radius: .25em .25em 0 0;
color: #888;
cursor: pointer;
display: block;
float: left;
font-size: 1em;
height: 2.5em;
line-height: 2.5em;
margin-right: .25em;
padding: 0 1.5em;
text-align: center;
}
#distributors input:hover + label {
background: #ddd;
color: #666;
}
#distributors input:checked + label {
background: #f1f1f1;
color: #444;
position: relative;
z-index: 6;
/*
-webkit-transition: .1s;
-moz-transition: .1s;
-o-transition: .1s;
-ms-transition: .1s;
*/
}
#content {
background: #f1f1f1;
border-radius: 0 .25em .25em .25em;
min-height: 20em;
position: relative;
overflow: auto;
width: 100%;
height: 620px;
z-index: 5;
}
#content .store-card {
min-height: 240px;
margin-bottom: 15px;
display: inline-block;
}
#content .store-card img {
margin-bottom: 10px;
}
#content .store-card h4 {
font-weight: 700;
margin-bottom: 0;
}
#content .store-card p {
margin-bottom: 0;
}
#content .store-card a {
font-weight: 700;
}
#content-1, #content-2, #content-3, #content-4 {
opacity: 0;
padding: 1.5em;
position: absolute;
display: block;
z-index: -100;
transition: all linear 0.3s;
}
#distributors input#tab-1:checked ~ #content #content-1,
#distributors input#tab-2:checked ~ #content #content-2,
#distributors input#tab-3:checked ~ #content #content-3,
#distributors input#tab-4:checked ~ #content #content-4 {
opacity: 1;
z-index: 100;
}
请检查以下JSFIDLE并在可能的情况下进行修复:
您需要从子内容分区中删除绝对位置,更改小提琴的最后一种样式,并从内容分区中删除固定高度:
#content-1,
#内容-2,
#内容-3,
#内容-4{
不透明度:0;
填充:1.5em;
显示:无;
过渡:全线性0.3s;
}
#分销商输入#表1:选中#内容#内容-1,
#分销商输入#选项卡2:选中#内容#内容2,
#分销商输入#表3:选中#内容#内容3,
#分销商输入#表4:选中~#内容#内容-4{
不透明度:1;
z指数:100;
显示:块;
}
所以您使用了height:auto;它不起作用了吗?只需删除
height
属性或给出height:auto
@nashcheez和keith将不起作用,因为内容是绝对定位的-如果你看小提琴并实际尝试你的建议,你会看到这一点