Footer Items Expanding with Viewport Evenly

こ雲淡風輕ζ 提交于 2019-12-24 03:27:05

问题


I'm trying to get a footer to display 5 items which space themselves out evenly, utilising the full width of the viewport. I've managed to get it working somewhat, but the last box flickers and gets pushed downwards when you resize the browser window bigger and smaller.

http://jsfiddle.net/pnUnU/

I was wondering if there was a better way to go about coding this? And also, is it possible to stop the buttons from expanding with the viewport once they reach a certain (small) size?

Much appreciated,


回答1:


You could use another element inside the li, having the border. That way the li could take the full 20% each.

http://jsfiddle.net/pnUnU/2/

HTML:

<footer class="footer">

    <ul>
        <li>
            <span class="content">
               Option 1
            </span>
        </li>
        <li>
            <span class="content">
               Option 2
            </span>
        </li>
        <li>
          <span class="content">
               Option 3
            </span>        
        </li>
        <li>
          <span class="content">
               Option 4
            </span>
        </li>
        <li>
          <span class="content">
               Option 5
            </span>
        </li>
    </ul>

</footer> <!-- end footer -->​

CSS:

.footer li
{
    float: left;
    line-height: 43px;
    text-align: center;
    color: white;
    width: 20%;
    background: grey;
}

.footer li span{
  display: block;
  border-right: 1px solid #fff;
}

.footer li:last-child span
{
    border: none;
}
​



回答2:


Demo

http://jsfiddle.net/pnUnU/1/



来源:https://stackoverflow.com/questions/11244089/footer-items-expanding-with-viewport-evenly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!