【问题标题】:center jquery slider with css带有 css 的中心 jquery 滑块
【发布时间】:2012-05-29 03:32:26
【问题描述】:

我的页面上有一个 jquery 滑块,当页面足够宽以适应它时它居中,但与窗口的左边缘对齐并在窗口较小时移动。下面是我的 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;}

【问题讨论】:

  • 抱歉,这里有什么问题?

标签: css jquery-plugins slider css-float centering


【解决方案1】:

也许它是偶然在大屏幕上居中的。

居中通常在以下情况下起作用:

width: (any-FIXED-WIDTH-value); - Good spot Bram Vanroy ;)
margin: auto;

我看不到...

你也应该添加你的 HTML,如果可能的话,启动一个 jsfiddle 并包含链接。这样其他用户可以使用它并为您解决它,我们也可以更好地理解您的代码。

希望有帮助

【讨论】:

  • 没有任何价值! 'auto' 不会使 div 居中。 '任何固定宽度'会更好。
  • @rick donohue 使其居中,但在屏幕分辨率较小时遇到更多问题。我在这里发布了一个新的和改进的问题:stackoverflow.com/questions/10717424/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-09
  • 2013-09-21
  • 2019-12-25
  • 1970-01-01
  • 2010-09-16
  • 1970-01-01
相关资源
最近更新 更多