FlexSlider: Center current image

夙愿已清 提交于 2019-12-03 21:00:06

I just had this same trouble and the answer lies in the CSS.

My HTML format is like this :

<div id="slider" class="flexslider">
<ul class="slides" >
<li><img src='images/slideshows/image04.jpg' /></li>
<li><img src='images/slideshows/image06.jpg' /></li>
<li><img src='images/slideshows/image07.jpg' /></li>

</ul>
</div>

And I had to change the CSS for the img and the li to make it work from this:

.flexslider .slides > li {display: none; -webkit-backface-visibility: hidden;} 
.flexslider .slides img {width: 100%; display: block;}

to this:

.flexslider .slides > li {display: none; -webkit-backface-visibility: hidden; background-color: #ffffff; text-align: center;} 
.flexslider .slides img {width: auto; display: inline;}

For me I had to add the background color because part of another slide was showing up on the left, and the white just matches my page layout.

Hope that helps.

legit

In the flexslider.css file under the section:

/* FlexSlider Necessary Styles*/ 

change:

.flexslider .slides img {width: auto; display: block;}

to this:

.flexslider .slides img {width: auto; display: block; margin-left: auto; margin-right: auto;}

To set Image Horizontally center in Flexslider, just make changes in flexslider.css file as below.

Find .flexslider .slides img and make changes as below.

.flexslider .slides img {
  width: auto;
  display: block;
  margin: 0 auto;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!