如果我有足够的图像,我的代码可以正常工作:它可以滚动并且一切都很好。
但是,如果图像的组合宽度小于父 div 的宽度,则它不会滚动(如预期的那样),但所有图像都向左对齐。
如何使它们与中心对齐?
我很确定这很容易,但我找不到解决方案。
如果有人可以提供帮助,我将不胜感激。
谢谢凯
它适用于这个插件:http ://www.smoothdivscroll.com/
我的 CSS 看起来像这样
#makeMeScrollable
{
width:100%;
height: 55px;
position: relative;
margin: 20px 0;
}
#makeMeScrollable div.scrollableArea img, #makeMeScrollable div.scrollableArea a
{
position: relative;
float: left;
margin: 0 10px;
padding: 0;
filter: url(stylesheets/filters.svg#grayscale); /* Firefox 3.5+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(1); /* Google Chrome & Safari 6+ */
/* If you don't want the images in the scroller to be selectable, try the following
block of code. It's just a nice feature that prevent the images from
accidentally becoming selected/inverted when the user interacts with the scroller. */
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
#makeMeScrollable div.scrollableArea img:hover, #makeMeScrollable div.scrollableArea a:hover
{
filter: none;
-webkit-filter: grayscale(0);
}
html是:
<div id = "makeMeScrollable">
<img src = "images/test.png"
id = "1" />
<img src = "images/test2.png"
id = "2" />
</div>