2

所以我对 css/HTML 很陌生(两个月左右),我正在研究一个由标题图像、Youtube 嵌入式播放器和导航栏组成的网站的主页。顺便说一句,第一次在这里发帖,我花了一段时间,但我终于设法居中/自动对齐我的网站,使用“包装器”,用于任何浏览器,或者如果你要放大和缩小浏览器,它将始终保持居中。现在我设法做到了,但我的问题是导航栏似乎有这个不必要的白色/空白空间附加到它的末尾,就像整个导航栏延伸得比实际导航链接更远,然后创建一个底部滚动条我不想。后面会有图片,但我可以判断的方式是当我在浏览器中突出显示它时。如果有人可以帮助我解决这个问题,那么我就不必有底部滚动条了' 非常感谢,谢谢![![在这里你可以看到导航栏右侧的所有空白区域!

单击此处查看问题图片,注意导航栏向右延伸太远] 1

这是CSS

<style>

*{  
margin:0;  
padding:0;  
}  

body{  
text-align:center; /*For IE6 Shenanigans*/  
}  

#wrapper{  
width:960px;  
margin:0 auto;  
text-align:left;  
}   


#navigation   {
    position:relative;
    left:100px;
    top:10px

}

#navigation li {
    list-style: none;
    display: block;
    float: left;
    margin: .5em;

<!--spacing between navbar-->
   padding-right: 20px;
   padding-left: 25px;

}


#navigation li a {   
    display: block;
    text-decoration: none;
    font-family: arial, sans-serif;
    color: #000000;
    font-size: 1.09em;
    margin: -.01em;
}

#navigation li a:hover {
color: #0000FF;
    text-decoration: underline;
}





#video1
{
    margin-left:83px;
    margin-top:40px;
    position:relative;
}


#mainlogo {
    position:relative;
    display: inline;
    left:300px;
    top:15px;
}





 /**
 * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
 * http://cssreset.com
 */
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;
}
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;
}


</style>

这是 HTML

</head>




<body>
<div id="wrapper">


<div id="mainlogo">
 <a href="http://s1287.photobucket.com/user/jakecan13/media/HeaderTest-
    1_zps78d21de6.png.html" target="_blank"><img 
   src="http://i1287.photobucket.com/albums/a628/jakecan13/HeaderTest-
1_zps78d21de6.png"  alt=404" height=55" width=370" photo HeaderTest-
1_zps78d21de6.png"/></a>

</div>





<ul id="navigation">
<li><a href="#Video">Video</a></li>
<li><a href="http://breakfastcircle.tumblr.com/">Photo</a></li>
<li><a href="#Contact">Contact</a></li>
<li><a href="#Store">Store</a></li>
</ul>



<div id="video1">
<iframe src="http://www.youtube.com/embed/GUEZCxBcM78?rel=0" width="800" height="500"
frameborder="0" allowfullscreen></iframe>

</div>


</div>

</body>
</html>
4

1 回答 1

0

问题是你用这条线把你的导航栏放在了额外的100 像素上:

#navigation{
left: 100px;
}

如果你真的需要导航超过那么远,添加一个float: left属性到#navigation.

于 2013-04-23T04:16:47.920 回答