如何在css中居中滑块?
我在一个主题上安装了这个插件。这个主题有一个滑块,但我不喜欢它。所以我安装了这个 我试过用这个如何在css中居中滑块?,css,wordpress,slider,center,Css,Wordpress,Slider,Center,我在一个主题上安装了这个插件。这个主题有一个滑块,但我不喜欢它。所以我安装了这个 我试过用这个 #wpcontent_slider_container{ position:relative; margin: 0 auto; } 还有这个 #wpcontent_slider_container{ position:relative; margin-left:auto; margin-right:auto; } 什么也没发生 我必须在div中放入一些内容吗?更改宽度 #wpcontent_sl
#wpcontent_slider_container{
position:relative;
margin: 0 auto;
}
还有这个
#wpcontent_slider_container{
position:relative;
margin-left:auto;
margin-right:auto;
}
什么也没发生
我必须在div中放入一些内容吗?更改宽度
#wpcontent_slider_container{
width: 500px;
margin:0 auto;
}
改变宽度
#wpcontent_slider_container{
width: 500px;
margin:0 auto;
}
在#wpcontent_slider_容器的
父元素中添加
text-align:center;
要将#wpcontent_滑块(容器
在#wpcontent_滑块)容器的
父元素中居中对齐,请添加
text-align:center;
#wpcontent_slider_container{
text-align: center;
}
要居中对齐#wpcontent_滑块_容器
#wpcontent_slider_container{
text-align: center;
}
或者使用标记
或者使用Tag如果你知道滑块的宽度,这里有一个小补丁,它在居中对齐很难实现时对我有效
#sliderDiv{
position:relative;
left:50%;
margin-left:-(half the width of the div);
(ex. if div is at 500px it would be margin-left:-250px;)
}
虽然不漂亮,但它很管用。不过,您可能必须隐藏外部容器的水平溢出。如果您知道滑块的宽度,这里有一个小补丁,它在居中对齐很难实现时对我有效
#sliderDiv{
position:relative;
left:50%;
margin-left:-(half the width of the div);
(ex. if div is at 500px it would be margin-left:-250px;)
}
虽然不漂亮,但它很管用。不过,您可能必须隐藏外部容器的水平溢出。我也有同样的问题。我就是这样解决的:
#wpcontent_slider_container {
margin-left: auto !important;
margin-right: auto !important;
}
#wpcontent_slider {
/* Your styling here */
}
如果没有“!important”的东西,CSS对我也不起作用 我也有同样的问题。我就是这样解决的:
#wpcontent_slider_container {
margin-left: auto !important;
margin-right: auto !important;
}
#wpcontent_slider {
/* Your styling here */
}
如果没有“!important”的东西,CSS对我也不起作用 最后,我可以解决我网页中滑块位置的问题
只需修改style.css
,.main\u img{float:left;margin:15px 10px 0 60px}
,更改值。最后,我可以解决我网页中滑块位置的问题
只需修改style.css
,.main_img{float:left;margin:15px 10px 0 60px}
,更改值。使用自动上的“margin right”和“margin left”!重要的事情对我也起了作用。事实上,即使不使用,它也可以工作!重要命令。使用自动上的“右边距”和“左边距”!重要的事情对我也起了作用。事实上,即使不使用,它也可以工作!重要命令。要将此#wpcontent_slider_容器或#wpcontent_slider_容器中的内容居中放置这是我想要的样子,请尝试用JSFIDLE重新创建问题,以便我们可以编辑小提琴并修复它。css应该是宽度:x,边距:10px自动;父对象也应该有一个宽度,可能是浮动的:左;您想将此#wpcontent_slider_容器或#wpcontent_slider_容器中的内容放在中心位置这就是我想要的样子尝试用JSFIDLE重新创建问题,以便我们可以编辑小提琴并修复它。css应该是宽度:x,边距:10px自动;父对象也应该有一个宽度,可能是浮动的:左;我尝试了所有的建议,但什么都没发生。我做错了什么?我尝试了所有的建议,但什么都没发生。我做错了什么?我尝试了所有的建议,但什么都没发生。我做错了什么?这是现场项目吗?通过这里的链接,我尝试了所有的建议,但什么都没有发生。我做错了什么?这是现场项目吗?此处的过去链接尝试#wpcontent_slider_container{位置:绝对;左边距:Xpx;边距顶部:Xpx;}…再次相同。此外,我在css中没有任何其他绝对位置。请尝试#wpcontent_slider_container{位置:绝对;左边距:Xpx;边距顶部:Xpx;}…再次尝试相同的位置。而且我在css中没有任何其他绝对位置。