Jquery 如何将此CSS居中?
这是CSS-Jquery 如何将此CSS居中?,jquery,css,center,Jquery,Css,Center,这是CSS- #slider ul, #slider li, #slider2 ul, #slider2 li{ margin:0; padding:0; list-style:none; } #slider2{margin-top:1em;} #slider li, #slider2 li{ /* define width and height of list item (slide) entire slider a
#slider ul, #slider li,
#slider2 ul, #slider2 li{
margin:0;
padding:0;
list-style:none;
}
#slider2{margin-top:1em;}
#slider li, #slider2 li{
/*
define width and height of list item (slide)
entire slider area will adjust according to the parameters provided here
*/
width:500px;
height:250px;
overflow:hidden;
}
#prevBtn, #nextBtn,
#slider1next, #slider1prev{
display:block;
width:30px;
height:77px;
position:absolute;
left:-30px;
top:71px;
z-index:1000;
}
#nextBtn, #slider1next{
left:696px;
}
#prevBtn a, #nextBtn a,
#slider1next a, #slider1prev a{
display:block;
position:relative;
width:30px;
height:77px;
background:url(../images/btn_prev.gif) no-repeat 0 0;
}
#nextBtn a, #slider1next a{
background:url(../images/btn_next.gif) no-repeat 0 0;
}
/* numeric controls */
#slider img{
width:500px;
height:300px;
}
ol#controls{
margin:1em 0;
padding:0;
height:28px;
}
ol#controls li{
margin:0 10px 0 0;
padding:0;
float:left;
list-style:none;
height:28px;
line-height:28px;
}
ol#controls li a{
float:left;
height:28px;
line-height:28px;
border:1px solid #ccc;
background:#b32d45;
color:white;
padding:0 10px;
text-decoration:none;
}
ol#controls li.current a{
background:#5DC9E1;
color:#fff;
}
ol#controls li a:focus, #prevBtn a:focus, #nextBtn a:focus{outline:none;}
我想将#滑块居中
HTML
- 形象
- 图2
有两种主要方法:
使用text align:Center
将#滑块的父级文本居中
如果滑块是同一水平定位中的唯一元素,则可以在滑块上使用居中边距:#滑块{margin:0px auto;}
#滑块具有定义的宽度,因此,如果将其左右边距设置为“自动”,则滑块将居中。不需要子代选择器“img”,因为您将其用作图像列表的容器。除非您希望每个图像都在滑块id内居中
#slider
{
margin:0px auto;
width:500px;
height:300px;
}
当只需一行css就可以轻松完成jQuery时,所有关于jQuery的讨论都是多余的。使用css还是jQuery?换句话说,jQuery标记与此有什么关系?您希望以什么为中心?@andrew我希望整个滑块都居中。@BalusC,这是一个名为easyslider的jquery插件。@Sarthakss:可以在这里找到该插件,它已经居中了
#slider
{
margin:0px auto;
width:500px;
height:300px;
}