div设置高度相等

时间:2013-02-15 09:04:28

标签: html css

我有3 div个。如果另一个div高度调整,我怎样才能使它们相等。我希望我的所有div都能调整它的高度,即使它们的内容较少。就像在图像中一样,即使没有数据的div也必须与其他数据相等,并将读数设置在底部。

HTML:

<div class="column-wrapper">
   <div class="column-small border  border-top"> 
      <h3>Features</h3>

      <ul>
         <li>Code blocking</li>
         <li>Code Wrapping</li>
         <li>Code Killing</li>
         <li>Code Sleeping</li>
      </ul>

      <span><a href="#">Read more</a></span>
   </div>

   <div class="column-small border  border-top"> 
      <h3>Modules</h3>

      <ul>
         <li>Barking Around The house</li>
         <li>Loving the Cats</li>
         <li>Floating The points</li>
         <li>Coding The Sleepers</li>
      </ul>

      <span><a href="#">Read more</a></span>
   </div>

   <div class="column-small border  border-top"> 
      <h3>Idont knows</h3>
      <span><a href="#">Read more</a></span>
   </div>
</div>

CSS:

.column-wrapper {
   padding-top: 20px;
   text-align: center;
   vertical-align: middle;
   width: 100%;
}

.column-wrapper div {
    display: inline-table; 
    margin: 2px;
}

.column-small {
    padding: 10px;
    width: 30%; 
    min-width: 250px; 
    height: auto;
} 

.column-small span {
   float: right;
} 

.column-small ul {
    margin-top: -10px;
    width: 100%; 
    max-width: 240px;
}

.column-small ul li {
    text-align: left;  
}

.column-small li { 
    list-style: none;
    padding: 5px;
    text-indent: -30px;
    word-wrap: break-word;
}

Screenshot

4 个答案:

答案 0 :(得分:2)

CSS:

.column-wrapper { overflow: hidden; }

.column-small {
   float: left;
   margin: 20px;
   background-color: red;
   padding-bottom: 1000px;
   margin-bottom: -1000px;
}

.column-small span { float: right; }

.column-small ul {
   margin-top: -10px;
   width: 100%;
   max-width: 240px;
}

.column-small ul li { text-align: left; }

.column-small li {
   list-style: none;
   padding: 5px;
   text-indent: -30px;
   word-wrap: break-word;
}

HTML:

<div class="column-wrapper">
   <div class="column-small border  border-top"> 
      <h3>Features</h3>

      <ul>
         <li>Code blocking</li>
         <li>Code Wrapping</li>
         <li>Code Killing</li>
         <li>Code Sleeping</li>
      </ul>

      <span><a href="#">Read more</a></span>
   </div>

   <div class="column-small border  border-top"> 
      <h3>Modules</h3>

      <ul>
         <li>Barking Around The house</li>
         <li>Loving the Cats</li>
         <li>Floating The points</li>
         <li>Coding The Sleepers</li>
      </ul>

      <span><a href="#">Read more</a></span>
   </div>

   <div class="column-small border  border-top"> 
      <h3>Idont knows</h3>
      <span><a href="#">Read more</a></span>
   </div>
</div>

答案 1 :(得分:1)

第一部分看起来像是https://stackoverflow.com/a/10235116/1902425

的副本

到你的第二部分:如果你用js做,你的身高是动态计算的,所以你可以设置你的“阅读更多”链接wir position: absolute小例子:

<div class="column-small">
      <div class="column-content">
          <h3>Idont knows</h3>
          <p>Your content</p>
      </div>
      <div class="readmore"><a href="#">Read more</a></div>
 </div>

CSS:

.column-small {
     position: relative;
     height: 240px;
}
.readmore {
    position: absolute;
    bottom: 10px;
    right: 10px;
}

答案 2 :(得分:0)

设置.column-small div的高度。

答案 3 :(得分:0)

.column-small{
    height: inherit !important;
}