How to auto adjust the
height according to c

2020-01-27 02:32发布

I have a <div> which needs to be auto adjusted according to the content in it. How can I do this? Right now my content is coming out of the <div>

The class I have used for the div is as follows

box-centerside  {
background:url("../images/greybox-center-bg1.jpg") repeat-x scroll center top transparent;
float:left;
height:100px;
width:260px;
}

标签: css html
20条回答
爷、活的狠高调
2楼-- · 2020-01-27 02:41

Just use this display type:

display: inline-block;
查看更多
Root(大扎)
3楼-- · 2020-01-27 02:45

<div> should expand automatically. I guess that the problem is that you're using fixed height:100px;, try replacing it with min-height:100px;

查看更多
老娘就宠你
4楼-- · 2020-01-27 02:46

Just write "min-height: XXX;" And "overflow: hidden;" & you will be out of this problem Like this

min-height: 100px;
overflow: hidden;
查看更多
Melony?
5楼-- · 2020-01-27 02:46

Set a height to the last placeholder div.

    <div class="row" style="height:30px;">
    <!--placeholder to make the whole block has valid auto height-->
查看更多
聊天终结者
6楼-- · 2020-01-27 02:46

For me after trying everything the below css worked:

float: left; width: 800px;

Try in chrome by inspecting element before putting it in css file.

查看更多
ら.Afraid
7楼-- · 2020-01-27 02:47

Simple answer is to use overflow: hidden and min-height: x(any) px which will auto-adjust the size of div.

The height: auto won't work.

查看更多
登录 后发表回答