css – 如何根据内容自动调整高度?

前端之家收集整理的这篇文章主要介绍了css – 如何根据内容自动调整高度?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个< div>需要根据其中的内容进行自动调整。我如何做到这一点?现在我的内容是从< div>

我用于div的类如下

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>
原文链接:https://www.f2er.com/css/222250.html

猜你在找的CSS相关文章