1

无论出于何种原因,我都无法摆脱标题和导航栏菜单之间的差距。我已经尝试了所有我能想到的填充/边距调整以向上推或移动栏,但它只是在菜单上做一些时髦的事情或向上推其他内容。我需要一些帮助。

和代码

#header_wrap {
    width:100%;
    height:144px;
    text-align: center;

}

#header {
    width:980px;
    margin:0 auto;


}

#preloadedImages
{
    width: 0px;
    height: 0px;
    display: none;
    background-image:url(Logo/logo14hover.gif);


}

.site_logo {
    float:left;
    width:302px;
    height:144px;
    background:url(Logo/logo14.gif) no-repeat;

}

.site_logo:hover {  
    float:left;
    width:302px;
    height:144px;
    background:url(Logo/logo14hover.gif) no-repeat;

}


.headerpic { 
    float:left;
    width:678px;
    height:144px;
    background:url(Images/headerpic.gif) no-repeat;

}




#menu_wrap {
     position:relative;
         z-index:2;
    text-align:center; 
    width:100%;
    padding: 0px 0px;
    }



#menu {
     position:relative;
     z-index:2;
    width:1000px;
    text-align:center; 
    margin:0 auto;
    height:61px;
    padding: 0px 0px;
    }

nav ul ul {
    display: none;

}

    nav ul li:hover > ul {
        display: block;
    }

nav ul {

    background: #bbb38f; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2JiYjM4ZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM2YjY0NDEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top,  #bbb38f 0%, #6b6441 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bbb38f), color-stop(100%,#6b6441)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #bbb38f 0%,#6b6441 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #bbb38f 0%,#6b6441 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #bbb38f 0%,#6b6441 100%); /* IE10+ */
background: linear-gradient(to bottom,  #bbb38f 0%,#6b6441 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bbb38f', endColorstr='#6b6441',GradientType=0 ); /* IE6-8 */
    box-shadow: 0px 0px 9px rgba(0,0,0,0.5);

    padding: 0px 0px;
    list-style:none;
    position: relative;
    display:inline-table;
    text-decoration:none;
    font-family:Copperplate Gothic Light,Georgia, Palatino, Times New Roman, serif; 
    font-size:17px;
    color:#FFFFFF;
    font-weight:light;
    outline:none;   
    text-shadow: 1px 1px #000000;

}

    nav ul:after {
        content: ""; clear: both; display: block;
    }


nav ul li {
    float: left;
}

nav ul li:hover {
        background: #736e57;
        background: linear-gradient(top, #BBB38F 0%, #6B6441 40%);
        background: -moz-linear-gradient(top, #BBB38F4 0%, #6B64415 40%);
        background: -webkit-linear-gradient(top, #BBB38F 0%,#6B6441 40%);
        text-decoration:none; 
        font-family:Copperplate Gothic Light,Georgia, Palatino, Times New Roman, serif; 
        font-size:17px;
        color:#FFFFFF;
        font-weight:light;
        outline:none;
        filter:alpha(opacity=100);
        opacity: 1;
        -moz-opacity:1;

}

nav ul li:hover a {
    color:#FFFFFF;
    filter:alpha(opacity=100);
    opacity: 1;
    -moz-opacity:1;

}

nav ul li a {
    color:#FFFFFF;
    display: block;
    padding: 12px 42px;
    text-decoration:none;
    filter:alpha(opacity=100);
    opacity: 1;
    -moz-opacity:1;

}



nav ul li:hover > ul {
    background: #303030;
    text-decoration:none;
    display: block;

    }

nav ul ul {
    background: #303030;

    font-family:  Helvetica, Copperplate Gothic Light, Arial, sans-serif;   
    font-size:14px;
    text-decoration:none;
    color:#000;
    font-weight:light;
    outline:none;
    filter:alpha(opacity=95);
    opacity: 0.95;
    -moz-opacity:0.95;
}

    nav ul ul li {
        text-decoration:none;
        float: none; 
        position: relative;

    }
        nav ul ul li a {
            text-decoration:none;
            padding: 0px 0px;
            color:#000;
            filter:alpha(opacity=100);
            opacity: 1;
            -moz-opacity:1;

        }   
            nav ul ul li a:hover {
                text-decoration:none;
                background: #736e57;
                text-shadow: 1px 1px #000000;
                filter:alpha(opacity=100);
                opacity: 1;
                -moz-opacity:1;
            }

nav ul ul {

    text-decoration:none;
    padding: 0px;
    position: absolute;



    }

    nav ul ul li {

        float: none; 
        position: relative;
    }
        nav ul ul li a {
            filter:alpha(opacity=100);
            opacity: 1;
            -moz-opacity:1;
            padding: 10px 40px 10px 15px;
            color:#000;
            font-family:  Helvetica, Copperplate Gothic Light, Arial, sans-serif;
            font-size:15px;
            text-align: left;


        }   
            nav ul ul li a:hover {
                font-family:  Helvetica, Copperplate Gothic Light, Arial, sans-serif;
                font-size:15px;
                background: #6B6441;
                text-align: left;
                background: #bbb38f; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2JiYjM4ZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM2YjY0NDEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top,  #bbb38f 0%, #6b6441 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bbb38f), color-stop(100%,#6b6441)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #bbb38f 0%,#6b6441 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #bbb38f 0%,#6b6441 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #bbb38f 0%,#6b6441 100%); /* IE10+ */
background: linear-gradient(to bottom,  #bbb38f 0%,#6b6441 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bbb38f', endColorstr='#6b6441',GradientType=0 ); /* IE6-8 */
    filter:alpha(opacity=100);
    opacity: 1;
    -moz-opacity:1;
            }

nav ul ul ul {
    position: absolute;
    left: 100%; top:0;

}

和 HTML

<div align="center" id="header_wrap">
<div id="header">
<a href="index.html"><div id="preloadedImages"></div><div class="site_logo"></div></a>
<div class="headerpic"></div>
</div>
</div>
<!-- START MENU NAV BAR CODE -->
<div id="menu_wrap">
<div id="menu">
<nav>
<ul>
    <li><a href="Company/company.html">Company</a>
        <ul>
        <li><a href="Company/mission.html">Mission</a></li>
        <li><a href="Company/philosophy.html">Philosophy</a></li>
        </ul>
    </li>
    <li><a href="Solutions/solutions.html">Solutions</a>
        <ul>
        <li><a href="Solutions/QPipe-Estimator/qpipe-estimator.html">Q Pipe Estimator</a>
            <ul>
            <li><a href="Solutions/QPipe-Estimator/advantage.html">Advantage</a></li>
            <li><a href="Solutions/QPipe-Estimator/differentiator.html">Differentiator</a></li>
            <li><a href="Solutions/QPipe-Estimator/features.html">Features</a></li>
            <li><a href="Solutions/QPipe-Estimator/screenshots.html">Screen Shots</a></li>
            </ul>
        </ul>
        </li>
    </li>
    <li><a href="#">Services</a>
        <ul>
        <li><a href="Services/technical-support.html">Technical Support</a></li>
        <li><a href="Services/training.html">Training</a></li>
        <li><a href="Services/customization.html">Customization</a></li>
        <li><a href="Services/faqs.html">FAQ's</a></li>
        </ul>
    </li>
    <li><a href="#">Industry</a>
        <ul>
        <li><a href="Industry/focus.html">Focus</a></li>
        <li><a href="Industry/customers.html">Customers</a></li>
        </ul>
    </li>
    <li><a href="Contact/contact-information.html">Contact</a>
        <ul>
        <li><a href="Contact/contact-information.html">Contact Information</a></li>
        <li><a href="Contact/request-information.html">Request Information</a></li>
        </ul>
    </li>
    <li><a href="http://web.qsoftsolutions.com/">Login</a>
    </li>
</ul>
</nav>
</div>
</div>
<!-- END MENU NAV BAR CODE -->

在评论中添加小提琴链接

4

3 回答 3

8

只需删除您的主要ul(的直接后代nav)的默认边距

使用以下 CSS 选择它,或给出特定ul的 aclassid(这样您只针对ul引起您的麻烦)。

nav > ul {margin: 0}

我把它放在你的小提琴顶部,并在这里更新

我意识到现在已经回答了这个问题,因为我花了太长时间格式化它,但我只想指出它与这无关,box-shadow这对定位没有影响。

于 2013-03-07T15:32:55.957 回答
2

ul默认边距负责此空间。尝试设置margin-top:0nav ul. 演示:http: //jsfiddle.net/xtsAx/8/

于 2013-03-07T15:15:25.787 回答
1

对我来说,这个错误是因为我使用 Dream Weaver 来编辑我的代码。这通过添加默认标题给我打了个嗝。当我删除这些标题并<html> <head>...<?php>....?> .... </html>让它完美运行时。 总是由织梦者删除 html 标签和标题。

**更新:我在 Firefox 中再次遇到同样的错误,所以我申请了

    *{
margin:0;
padding:0;
}

因此现在完全摆脱了它。**

于 2015-03-16T05:07:02.873 回答