我的页面上有一个 jquery slider ,当页面宽度足以容纳它时,它会居中,但与窗口的左边缘对齐,并在窗口较小时移动。下面是我的 CSS - 我错过了什么吗?
#billboardWrapper {height:600px;width:100%;margin:-170px 0 0 0px; position:relative; overflow:hidden; /*border-width: 0 20px 20px 20px; border-style:solid; border-color: {{settings.billboard_color}}; /* can't use border shorthand. IE9 has a rendering bug, see more notes in the ie8.css file */ }
#billboard {height:600px;width:1000px;position:relative;/*background:#1c1c1c;*/ background-position: 50% 0pt;}
#billboardPrev,
#billboardNext { display:block; text-indent:-9999px; position:absolute; left:40px; top:270px; width:30px; height:30px; cursor:pointer; background: url(arrows.png) no-repeat 0 0; z-index:99;}
#billboardNext {left:auto; right:40px; background-position:0 -92px; }
.slide {height:600px;width:1000px;display:none; }
.slide img {height:600px; width:100%; background-position: 50% 0pt;
.slideLeftLayout .slideTitle,.slideLeftLayout .slideText,.slideLeftLayout .slideLink {left:50px;}
.slideRightLayout .slideTitle,.slideRightLayout .slideText,.slideRightLayout .slideLink {right:50px;text-align:right;}
最佳答案
也许它偶然位于较大屏幕的中心。
居中通常在以下情况下有效:
width: (any-FIXED-WIDTH-value); - Good spot Bram Vanroy ;)
margin: auto;
我看不到...
您确实也应该添加 HTML,如果可能的话,启动 jsfiddle 并包含链接。这样其他用户就可以使用它并为您解决问题,并且我们也可以更好地理解您的代码。
希望有帮助
关于css - 带有 css 的中心 jquery slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10705478/