html - 如何减少导航链接之间的间距

标签 html css

我有一个导航栏,我希望它在整个页面上延伸,我有一个响应式布局(虽然这没有在下面反射(reflect)出来,但我已经削减了构建我的导航的必要代码)和我的移动 View 我希望导航栏下拉到单独的一行。

但是我想要做的是在这些 <a> 上设置背景颜色标签,但要创建它们连接在一起的效果。

我试过使用填充,但这对我没有用,反而增加了整体高度,有什么想法吗?

我的代码在下面,如果有任何帮助,我们将不胜感激

或查看我的 jsfiddle here

测试.html

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>iManage</title>
    <style>
    @charset "utf-8";
    /* CSS Document */
    /********************************
    * CSS Reset                     *
    *********************************/
    html, body, div, span, applet, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td,
    article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, 
    menu, nav, output, ruby, section, summary, time, mark, audio, video {
        margin: 0;
        padding: 0;
        border: 0;
        font-size: 100%;
        font: inherit;
        vertical-align: baseline;
    }
    /* HTML5 display-role reset for older browsers */
    article, aside, details, figcaption, figure,footer, header, hgroup, menu, nav, section {
        display: block;
    }

    body {

        line-height: 1;
        background-color:#EEEEEE;
            font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;

    }

    ol, ul {
        list-style: none;
    }

    blockquote, q {
        quotes: none;
    }

    blockquote:before, blockquote:after,
    q:before, q:after {
        content: '';
        content: none;
    }

    table {
        border-collapse: collapse;
        border-spacing: 0;
    }


    /* Styles */
    header h1 {
    font-size:20px;
    text-align:center;

    }

    header nav {
        width:100%;
        background-color:#232527;

    }

    .maina > li  {

    }

    header nav a:link {
    font-size:12px;
    font-size:12px;
    width:120px;
    padding:10px;
    display:inline-block;
    background-color:#98bf21;
    }


    header {
    width:auto;
    min-height:50px;
    background-color:#374348;
    }

    header > h1 {
        font-size:24px;
        font-weight:300;
        color:#FFF;
        padding:10px;
        font-family: 'Oxygen', sans-serif;  
    }

    .main a {

    }

    .maina > li  {
        display:inline; 
        list-style:none;    
    }

    header > nav {
        font-family: 'Oxygen', sans-serif;
        text-align:center;
        height:auto;
        border:medium #999;
        float: left;
    }

    .clear:after {
        content: "";
        display: table;
        clear: both;
    }

    header nav a:link {
    color:#CCC;
    text-decoration:none;
    font-weight:bold;
    border:medium #CCC; 
    }

    header nav a:visited {
    color:#FFF;
    }


    header nav a:active {
    color:#7e7975;
    }

    header nav a:hover {
    text-decoration:underline;
    }
    </style>
    </head>


    <body>
    <div id="wrapper">
    <header class="clear">
    <h1>iManage</h1>
      <nav>
            <ul class="maina">
                <li><a href="index">Home</a></li>
                <li><a href="Projects">Projects</a></li>
                <li><a href="Settings">Settings</a></li>
            </ul>
        </nav>
    </header>

    <div id="maincontentWrapper">


    </div>

最佳答案

删除 li 元素之间的空白。

<li><a href="index">Home</a></li><li><a href="Projects">Projects</a></li><li><a href="Settings">Settings</a></li>

jsFiddle example

或者在列表项之间放置 HTML 注释 ( <!-- -->):

<ul class="maina">
    <li><a href="index">Home</a></li><!--
 --><li><a href="Projects">Projects</a></li><!--
 --><li><a href="Settings">Settings</a></li>
</ul>

jsFiddle example

关于html - 如何减少导航链接之间的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18534740/

相关文章:

javascript - 如何让一个 div 显示两个拉伸(stretch)宽度的内联项?

Javascript onmouseover 和 onmouseout

jquery - 在 Safari 中正确计算 $(this).css(“width”)

javascript - jQuery 函数仅在调试器模式下工作

html - Flex 元素在 Chrome 和 IE11 中重叠

html - 在图像周围环绕定义列表文本 (CSS\HTML)

javascript - 如何对 bootstrap-3 分页进行编程以处理简单的 HTML 内容

javascript - 使 <a> 滚动到 Div

css - 如何在悬停效果上创建 css translateY

jquery - 将 Bootstrap Navbar 修复到滚动顶部