【问题标题】:How to reduce the height of my div element, relative to the other div element如何降低我的 div 元素相对于其他 div 元素的高度
【发布时间】:2014-02-01 00:53:25
【问题描述】:

我正在尝试降低包含内容的 div 元素的高度,使其比相应的 div 略小,以便内容不会溢出到其他元素中,这是他们执行此类问题的一种方法。

<!DOCTYPE html>

<html>
  <head>
   <script>
        .atlas.region-map
    {
    border: 2px solid #716E64;
    max-width: 500px;
    overflow: hidden;
    margin: 0;
    float: left;
    }

   .atlas .map-content .info-col
   {
    margin-left: 549px;
    width: 335px;
   }

  .atlas .map-content .info-col p
   {
   color: #5c5642;
   margin-top: 15px;
  font-size: 12px;
   }
  .Atlas_Test
  {
      height: 300px;
      font-size: 14px;
      overflow-y: scroll;
  }
  </script>
  </head>

  <body>
    <div class="info-col">
    <p>Content will go here</p>
    </div>

 </body>

【问题讨论】:

标签: html css height


【解决方案1】:

如果这不起作用,那么它实际上没有执行!

您需要将 CSS 编码放在 style 元素中,而不是 script 中。脚本元素用于JS代码。

但是,要减小 div 的大小,您可以尝试以下代码:

max-height: 90%; // shorten it!

这样你可以阻止 div 变得超过这个大小。并且内容不会移出。使用此代码,元素将获得父元素高度大小的 90%!因此不会移出解决方案框。

要提供滚动条,请使用:

overflow: scroll;

【讨论】:

    猜你喜欢
    相关资源
    最近更新 更多
    热门标签