简体   繁体   English

如何使flexslider图像具有响应性?

[英]How do you make flexslider images responsive?

Currently, I am using width: 100% to make my image scale with the window size. 目前,我正在使用width:100%使我的图像缩放与窗口大小。

I would like to know how I can make the image scale down and not become distorted. 我想知道如何使图像缩小并不会失真。

I simply changed the image width too width: 100% and changed height to height:auto to fix this for anyone that might need to know. 我只是简单地将图像的宽度更改为width:100%,并将height更改为height:auto,以解决可能需要知道的任何问题。

eg. 例如。

img {
    width: 100%;
    height:auto;
}

EDIT: 编辑:

To ensure image widths don't go larger than their containers 为了确保图像宽度不超过其容器

img {
    max-width: 100%;
    width: 100%;
    height:auto;
}

I did this and it worked out for me. 我做到了,对我来说很有效。 I did not want the big slider on the homepage so i resized it, then i found out it was not responsive anymore. 我不希望主页上有大滑块,所以我调整了它的大小,然后发现它不再响应了。 I added some codes and tested it, some did not work, some did. 我添加了一些代码并对其进行了测试,有的没有用,有的没有用。 Finally this is the code to and resize the slider, and keep it responsive!! 最后,这是调整滑块大小并保持其响应的代码!

.flexslider {max-width: 700px; margin: -20; padding: 0;}
.flexslider .slides > li {display: none; -webkit-backface-visibility: hidden;} /* Hide the slides before the JS is loaded. Avoids image jumping */
.flexslider .slides img { 
 display: block;
 max-width: 100%; height: auto; margin: - auto;
}

 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM