如何自动调整< div>高度根据内容而定? [英] How to auto adjust the <div> height according to content in it?

查看:87
本文介绍了如何自动调整< div>高度根据内容而定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个< div> ,需要根据其中的内容进行自动调整。我如何做到这一点?现在我的内容来自< div>

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>

我用于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;
}


推荐答案

而不是直接指定高度:

<html>
<head>
  <style type="text/css">
    .box-centerside  {
      background:url("../images/greybox-center-bg1.jpg") repeat-x scroll center top transparent;
      float:left;
      min-height:100px;
      width:260px;
    }
  </style>
</head>
<body>
  <div class="box-centerside">
    This is sample content<br />
    This is sample content<br />
    This is sample content<br />
    This is sample content<br />
    This is sample content<br />
    This is sample content<br />
    This is sample content<br />
    This is sample content<br />
    This is sample content<br />
    This is sample content<br />
    This is sample content<br />
    This is sample content<br />
  </div>
</body>
</html>

这篇关于如何自动调整&lt; div&gt;高度根据内容而定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆