HTML CSS 模仿京东页面做出的页面。但是打开页面最下面有个左右滑动栏。导致页面不居中。该怎么解决?

html-css025

HTML CSS 模仿京东页面做出的页面。但是打开页面最下面有个左右滑动栏。导致页面不居中。该怎么解决?,第1张

这是因为你html元素里面的某个属性设置的宽度超出了屏幕范围,如body的宽度你设置了2000px,但是你屏幕的分辨率是1920的,2000>1920,所以会出现滚动条。这个你得检察一下,或者源码发上来,我给你检查。

给你一个类似的,需要展开的菜单你加一个样式默认隐藏,然后在JS里加一个事件显示就好了

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>CSS+XHTML代码</title>

</head>

<style type="text/css">

/* ================================================================

This copyright notice must be untouched at all times.

The original version of this stylesheet and the associated (x)html

is available at http://www.cssplay.co.uk/menus/page_menu2.html

Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.

This stylesheet and the associated (x)html may be modified in any

way to fit your requirements.

=================================================================== */

body {

background: #fff

font-family: "Lucida Grande", Helvetica, Arial, sans-serif

font-size: 12px

}

#hoverpage ul#outer li div p {font-size:12pxline-height:16pxmargin:5px 0 15px 0}

#hoverpage ul#outer li div h2 {line-height:1emcolor:#585font-size:1.5emfont-weight:normalmargin-top:0font-family:verdana, sans-serif}

#hoverpage ul#outer li div h3 {line-height:1emcolor:#66afont-size:1.2emfont-weight:normalmargin-top:0}

#hoverpage ul#outer li div h3.clear {clear:left}

#hoverpage {width:650pxheight:450pxborder:1px solid #aaabackground:#fffposition:relativez-index:500overflow:hiddentext-align:left}

#hoverpage table {border-collapse:collapsemargin:-1px}

#hoverpage ul#outer {background:transparentpadding:0margin:0list-style:none}

#hoverpage ul#outer li.page {display:inline} /* needed for IE to function correctly */

#hoverpage ul#outer li.page a.menuitem {text-decoration:none}

#hoverpage ul#outer li.page i {position:absolutedisplay:blockheight:25pxright:500pxbackground:transparentcursor:defaultz-index:100text-align:righttext-decoration:nonecolor:#080font-style:normalcursor:pointer}

#hoverpage ul#outer li.p1 i {top:30px}

#hoverpage ul#outer li.p2 i {top:55px}

#hoverpage ul#outer li.p3 i {top:80px}

#hoverpage ul#outer li.p4 i {top:105px}

#hoverpage ul#outer li.p5 i {top:130px}

#hoverpage ul#outer li.page div {display:blockwidth:600pxheight:400pxpadding:25pxfont-weight:normalcolor:#444}

#hoverpage ul#outer li.p1 div {background:#fff url(page1_back.jpg)}

#hoverpage ul#outer li.p2 div {background:#fff url(page2_back.jpg)}

#hoverpage ul#outer li.p3 div {background:#fff url(page3_back.jpg)}

#hoverpage ul#outer li.p4 div {background:#fff url(page4_back.jpg)}

#hoverpage ul#outer li.p5 div {background:#fff url(page5_back.jpg)}

#hoverpage ul#outer li div img {border:1px solid #888float:rightmargin:0 10px 5px 0}

#hoverpage ul#outer li div p.big {line-height:1emcolor:#004font-size:1.5em}

#hoverpage ul#outer li div a {color:#00ctext-decoration:underline}

#hoverpage ul#outer li div em {display:blockwidth:190pxheight:230pxfloat:leftbackground:transparent url(current.gif) no-repeatmargin-right:10px}

#hoverpage ul#outer li.p1 div em {background-position: 21px 0}

#hoverpage ul#outer li.p2 div em {background-position: 21px 25px}

#hoverpage ul#outer li.p3 div em {background-position: 21px 50px}

#hoverpage ul#outer li.p4 div em {background-position: 21px 75px}

#hoverpage ul#outer li.p5 div em {background-position: 21px 100px}

#hoverpage ul#outer li.page div a:hover {text-decoration:none}

#hoverpage ul#outer li.page a:hover {white-space:normal} /* for IE6 */

#hoverpage ul#outer :hover div {position:absoluteleft:0top:0}

#hoverpage ul#outer a:hover i {color:#66afont-weight:bold} /* for IE6 */

#hoverpage ul#outer :hover a i {color:#66afont-weight:bold}

#hoverpage ul#outer div ul li {line-height:20pxfont-size:0.9emcolor:#256list-style-type:disc}

#hoverpage ul#outer div ul li a {line-height:20pxfont-size:1.1emcolor:#c00}

#hoverpage ul#outer div dl dd {line-height:20pxfont-size:1.1emcolor:#448}

#hoverpage ul#outer div dl dt {line-height:30pxfont-size:1.3emcolor:#333}

</style>

<body>

<div id="hoverpage">

<ul id="outer">

<li class="page p1"><a href="#nogo" class="menuitem"><i>Products</i><!--[if IE 7]><!--></a><!--<![endif]-->

<!--[if lte IE 6]><table><tr><td><![endif]-->

<div>

<em></em>

<img src="bags.jpg" alt="" />

<h2>Products</h2>

<h3>Lorem Ipsum</h3>

<ul>

<li><a href="#nogo1">Integer nonummy neque.</a></li>

<li><a href="#nogo1">Aliquam accumsan.</a></li>

<li><a href="#nogo1">Nulla in sapien eget eros.</a></li>

<li><a href="#nogo1">Nam varius ante et risus.</a></li>

<li><a href="#nogo1">Phasellus at erat id metus.</a></li>

<li><a href="#nogo1">Donec malesuada ultricies.</a></li>

<li><a href="#nogo1">Duis quis purus sit amet.</a></li>

<li><a href="#nogo1">Morbi porta dapibus enim.</a></li>

</ul>

<h3 class="clear">Product Information</h3>

<p>Suspendisse potenti. Donec viverra molestie enim. Fusce fermentum, erat id cursus aliquam, mauris augue volutpat dolor, in interdum purus pede dictum diam. Morbi interdum diam at ligula. Morbi laoreet. Morbi mollis tristique justo. Etiam accumsan fermentum ipsum. Phasellus vestibulum, leo in dapibus ultricies, nisi nulla fermentum tortor, eu lobortis nibh urna ac dui. Aliquam erat volutpat. Curabitur vitae sapien sed libero dictum pellentesque. Praesent quis enim nec tellus congue hendrerit. Ut tellus. Morbi rhoncus elit lobortis libero.</p>

</div>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

<li class="page p2"><a href="#nogo" class="menuitem"><i>Services</i><!--[if IE 7]><!--></a><!--<![endif]-->

<!--[if lte IE 6]><table><tr><td><![endif]-->

<div>

<em></em>

<img src="service.jpg" alt="" />

<h2>Services</h2>

<h3>Curabitur eget</h3>

<ul>

<li><a href="#nogo2">Suspendisse potenti.</a><br />Quisque at ante nec lacus cursus malesuada.</li>

<li><a href="#nogo2">Donec viverra molestie enim.</a><br />Sed ac tortor nec augue hendrerit pulvinar.</li>

<li><a href="#nogo2">Pellentesque habitant.</a><br />Nullam rhoncus hendrerit orci.</li>

<li><a href="#nogo2">Vivamus non turpis.</a><br />Sed lacinia egestas mi.</li>

</ul>

<h3 class="clear">Available Services</h3>

<p>Proin scelerisque justo quis ante. Maecenas vehicula orci quis arcu. Nam dictum lectus quis ipsum. In felis. Cras eu lectus. Nam sed est ut orci venenatis faucibus. Ut molestie massa non massa. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Curabitur eget magna a odio vestibulum laoreet. Vivamus faucibus tincidunt massa. Sed a nunc. Quisque varius sagittis libero.</p>

</div>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

<li class="page p3"><a href="#nogo" class="menuitem"><i>Latest Information</i><!--[if IE 7]><!--></a><!--<![endif]-->

<!--[if lte IE 6]><table><tr><td><![endif]-->

<div>

<em></em>

<img src="news.jpg" alt="" />

<h2>Latest Information</h2>

<h3>Fusce fermentum</h3>

<ul>

<li><a href="#nogo3">Donec posuere enim a sapien.<br />Malesuada fames ac turpis egestas.</a></li>

<li>Vivamus dignissim tincidunt quam.</li>

<li>Nullam varius vestibulum mauris.</li>

<li>Curabitur faucibus varius dui.<br /><a href="#nogo3">Cras suscipit viverra felis. Nullam diam.</a></li>

<li>Vivamus convallis volutpat nunc.</li>

<li>Sed porttitor dui vel nunc.</li>

</ul>

<h3 class="clear">Latest Product Information</h3>

<p>Nam porttitor congue diam. Donec in mi. Fusce ac neque. Donec quis justo. Nunc non justo quis augue sagittis volutpat. Etiam quis ligula commodo augue tempus pulvinar. Morbi ante arcu, aliquam ut, consequat et, consequat sed, sem. Cras suscipit viverra felis. Nullam diam. Duis eros purus, ornare sit amet, viverra sed, laoreet ac, pede.</p>

</div>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

<li class="page p4"><a href="#nogo" class="menuitem"><i>Press Release</i><!--[if IE 7]><!--></a><!--<![endif]-->

<!--[if lte IE 6]><table><tr><td><![endif]-->

<div>

<em></em>

<img src="press.jpg" alt="" />

<h2>Press Release</h2>

<h3>Quisque varius</h3>

<dl>

<dt>11th June 2007</dt>

<dd>In feugiat scelerisque pede.</dd>

<dd>Morbi iaculis eleifend ante.</dd>

<dd>Maecenas fringilla scelerisque erat.</dd>

<dd>Nam <a href="nogo5">accumsan</a>egestas eros.</dd>

</dl>

<h3 class="clear">News and Information</h3>

<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse vitae sem. <a href="nogo5">Class aptent taciti</a>sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Donec ut nunc. <a href="nogo5">In dictum, dui nec vehicula vehicula</a>, neque leo faucibus est, porta vehicula nisi odio eu tellus.</p>

</div>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

<li class="page p5"><a href="#nogo" class="menuitem"><i>Contact us</i><!--[if IE 7]><!--></a><!--<![endif]-->

<!--[if lte IE 6]><table><tr><td><![endif]-->

<div>

<em></em>

<img src="contact.jpg" alt="" />

<h2>Contact us</h2>

<h3>Donec condimentum</h3>

<ul>

<li>Phasellus vitae arcu et mauris facilisis ornare.</li>

<li>Nullam ultrices <a href="#nogo5">urna nec erat</a>facilisis faucibus.</li>

<li>Ut cursus posuere eros.</li>

<li>Vestibulum <a href="#nogo5">dapibus</a>tortor eu nisl.</li>

<li>Proin ac mauris non lacus pharetra aliquet.</li>

</ul>

<h3 class="clear">Contact Details</h3>

<p>Praesent vehicula interdum massa. Nunc velit erat, pulvinar vitae, tempor non, porttitor non, ipsum. Nullam venenatis, quam a tincidunt semper, neque velit dictum quam, at mattis mauris mauris a dolor. Aliquam urna. <a href="nogo5">Ut pellentesque dapibus quam.</a>Mauris dapibus dictum felis. Praesent tellus quam, aliquet in, malesuada aliquet, pretium non, eros. Cras aliquam ligula vitae nunc.</p>

</div>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

</ul>

</div>

<br>

<br>

<br>

<div>

</div>

</body>

</html>

<script language=javascript ></script>

在html head内引用

<link href="你写好的样式表" rel="stylesheet" type="text/css">

不懂 可以问我

望采纳!