展开的标签,以填补空间(Expand an tag to fill the space)

2019-07-04 19:48发布

我怎样才能使锚标记扩大到列表项的底部? 我知道我可以把锚轮列表项的标签,但打破XHTML 1.0严格遵守,所以我不能做到这一点。

<html>
  <head>
    <style>
      #listWrapper { text-align:center;}
      #list { margin-left: 0px auto; margin-right: 0px auto; width: 100%; min-height: 100%; height:100%; margin-bottom: 10px; margin-top: 0px;}
      #list ul { padding: 5px 10px 10px 10px; margin: 0; min-height: 100%;}
      #list li { clear:both; font-weight:bolder; height:auto; border-bottom: 1px solid Silver; border-left: 1px solid Silver; font-size:x-small; border-right: 1px solid Silver; list-style-type: none;}
      #list a:hover { background-color: red;}
      #list a { display:block; cursor:pointer; text-decoration: none; text-align:left; vertical-align:top; }
      #list h3 { background-color:Silver; vertical-align:top; font-size:larger; }
      #list img { height:auto; margin: 8px; float:left; vertical-align:top; border:solid 1px Silver;}   
    </style>
  </head>
  <body>
    <div id="listWrapper">
      <div id="list">
        <ul>
          <li>
            <h3>title</h3>
            <a href="#">
              <img src="/images/x.jpg" alt="" />
              Lorem ipsun........
            </a>
            <div style="clear:both;" />
          </li>
          <li>
            <h3>title</h3>
            <a href="#">
              <img src="/images/x.jpg" alt="" />
              Lorem ipsun........
            </a>
            <div style="clear:both;" />
          </li>
        </ul>
      </div>
    </div>
  </body>
</html>

Answer 1:

你的答案的组合固定它。 多谢....

#list ul { display: block; }
#list li { display: block;}
#list a { display:block; height:100%; }


Answer 2:

使用这个CSS:

#list ul li a { display: block }


Answer 3:

放在

<br style="clear: both;"/>

锚标签内。

编辑:改变的div BR



Answer 4:

为了填补底部,你需要修复的图像边缘-现在的图像占用太多的空间,与它的8px保证金。 为了填补前,你需要删除的下边距h3

#list h3 { margin-bottom: 0; }
#list img { margin: 5px 8px; }


Answer 5:

尝试所设定的高度#list到一个固定的大小和高度上#list a100%

差异到现有的代码:

    #list
    {
        min-height: 100px;
        height: 100px;
    }

    #list a
    {
         height:100%;
    }


Answer 6:

这是我做的:

<!-- teh codes -->
<style type="text/css">
  .nav-cell
  {
    height: 35px;
    padding: 0px; /* just to make sure the link will fill the entire cell */
    text-align: center;
    width: 92px;
  }
  .nav-cell-link
  {
    display: block;
    width: 100%;
    height: 100%;
  }
  .nav-cell-link-text
  {
    display: block;
    padding-top: 11px;
  }
</style>
<!-- teh codes -->
<table cellpadding="0" cellspacing="0" style="height: 35px;">
  <tr>
    <td class="nav-cell">
      <a href="#" class="nav-cell-link">
        <span class="nav-cell-link-text">Link Text</span>
      </a>
    </td>
  </tr>
</table>
<!-- teh codes -->


文章来源: Expand an tag to fill the space