【问题标题】:How to get more of a space between a tags inside ul li tags如何在 ul li 标签内的标签之间获得更多空间
【发布时间】:2013-07-14 23:04:37
【问题描述】:

我正在创建一个带有 ul li 标签的菜单栏,并且链接要靠在一起我如何让它们在链接之间有更大的空间?

【问题讨论】:

  • 填充?举个例子会很有用。

标签: css html-lists hyperlink


【解决方案1】:

在 li 元素上设置边距 ...

<nav>
  <ul>
    <li><a href="#"><span>Home</span></a></li>
    <li><a href="#"><span>Gallery</span></a></li>
    <li class="last"><a href="#"><span>Map</span></a></li>
  </ul>
</nav>


<style>
li{
    display:inline-block; 
    background:blue; 
    width:100px; 
    height:20px; 
    text-align:center;
    margin-right:15px; /* edit this margin to separate your elements*/
}
a{
    text-decoration:none; 
    color:black;
    display:block;
}
.last {margin-right:0px;}
</style>

http://jsfiddle.net/Tv7pA/

您可以从最后一个元素(如 top 或使用 jQuery 或使用 css li:last-child、li:nth-child(3) )删除边距...但最好的方法是使用 jQuery 或使用类 coz 它是 sup。在所有浏览器中

【讨论】:

    猜你喜欢
    • 2014-07-25
    • 2022-01-12
    • 1970-01-01
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多