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 03:07

If you haven't gotten the answer yet, your "float:left;" is messing up what you want. In your HTML create a container below your closing tags that have floating applied. For this container, include this as your style:

#container {
clear:both;
}

Done.

查看更多
贪生不怕死
3楼-- · 2020-01-27 03:07

You could try, div tag will auto fit height with content inside:

height: fit-content;
查看更多
登录 后发表回答