如何使<li>标签自动调整大小

时间:2016-12-27 18:30:37

标签: css

我有这个高度为60px的li。

但是如果我把我的内容包含超过200个字母,那么内容就会超出li。

如何使李自己成长?

 #myUL li 
{
    height: 60px;
              
    word-wrap: break-word;
    max-height: auto;
}
<ul id="myUL">
  <li>
   <span class="post">ljcbnvkdsjbvdskjbvdskjbvdskjvbsdkjbvksdjvbsdkjvbsdkjvbsdkjvbdskjvbdskjbvsdbvsdkjdbvdskjbvdksjvbsdkjbvsdkjvbsdkjvbsdkjvbsdkjvbsdkvjbsdkjvbdskjvbsdkjvbsdkjvbsdkjvbsdkjvbsdkjvbsdkvjbsdvkjbsdkvjbsdvkjdsbv
   </span>
   <span class="close">&#215;</span>
   <div class="id-content">
   <span class="content">By </span>Mera Yahan
   <span class="content"> @ </span> 11:21 pm                
   </div>
 </li>
 <hr />
</ul>

2 个答案:

答案 0 :(得分:1)

您的代码有:

#myUL li 
{
  height: 60px;
  word-wrap: break-word;
  max-height: auto;
}

你应该:

#myUL li 
{
  min-height: 60px;
  word-wrap: break-word;
  height: auto;
}

答案 1 :(得分:0)

 #myUL li 
{
    height:60px;
     overflow:auto;
    word-wrap: break-word;
    max-height: auto;
}

您可以添加overflow属性以获得所需的结果。

或只是

#myUL li 
{
    height:auto;

    word-wrap: break-word;

}