如何随着CSS中文本的数量增加高度?
我遇到这种情况,
<div class="sub_project">
<div class="sbone brown_gradient optzeci">Description</div>
<div class="sbtwo optzecitwo">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</div>
</div>
.sub_project{
font-size: 16px;
margin: 10px 0;
background: #D7D7D7;
}
.brown_gradient{
background: #EB994F;
}
.sbone{
padding: 5px;
color: white;
float: left;
width: 160px;
margin: 0 10px 0 0;
}
.sbtwo{padding: 5px;}
.optzeci{height: 80px;}
.optzecitwo{min-height: 80px;} * html .optzeci { height:80px; }
我希望
高度随着文本量的增加而增长。Description
现在我设置了 min-height: 80px;
但我根本不想设置高度。
另外,我不想使用图像或 javascript
请参阅 jsfiddle
有什么想法吗?
谢谢
i have this situation
<div class="sub_project">
<div class="sbone brown_gradient optzeci">Description</div>
<div class="sbtwo optzecitwo">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</div>
</div>
.sub_project{
font-size: 16px;
margin: 10px 0;
background: #D7D7D7;
}
.brown_gradient{
background: #EB994F;
}
.sbone{
padding: 5px;
color: white;
float: left;
width: 160px;
margin: 0 10px 0 0;
}
.sbtwo{padding: 5px;}
.optzeci{height: 80px;}
.optzecitwo{min-height: 80px;} * html .optzeci { height:80px; }
I would like the <div class="sbone brown_gradient optzeci">Description</div>
height to grow with the amount of text.
Right now i set a min-height: 80px;
but i do't want to set height at all.
Also i don't want to use images or javascript
See jsfiddle
any ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
相对定位容器
.sub_project
,并为其提供左侧填充。绝对定位.optzeci
并给它top: 0;左:0;底部:0;
。http://jsfiddle.net/W7Nrn/9/
Relatively position the container,
.sub_project
, and give it left padding. Absolutely position.optzeci
and give ittop: 0; left: 0; bottom: 0;
.http://jsfiddle.net/W7Nrn/9/
如果你可以使用jquery,那么你可以动态地为盒子分配高度。您只需要获取包含文本的 div 的高度,然后将相同的高度分配给描述框。
这是我的尝试: http://jsfiddle.net/W7Nrn/6/
if you can use jquery then you can assign height to the box on the fly. you just need to get the height on the div containing your text then assign the same height to description box.
here is my try: http://jsfiddle.net/W7Nrn/6/