使用IE11缩放/拉伸图像但不使用Chrome / Firefox

时间:2017-03-31 21:20:57

标签: css internet-explorer-11 swiper

在IE11下显示图像时,

Swiper(?)表现不佳。这些图像在Chrome和Firefox上完美呈现。

Screenshot

And you can see this live here

这是代码(代表它的价值,它是产生它的laravel)

<div class="row">
    <div class="col-xs-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <i class="fa fa-car"></i> {{ trans('navs.general.pictures') }}
            </div>

            <div class="panel-body">
                    <div class="swiper-container">
                        <div class="swiper-pagination"></div>
                        <div class="swiper-button-next"></div>
                        <div class="swiper-button-prev"></div>
                        <div class="swiper-wrapper">
                            @foreach($car->getMedia('vehicules') as $i)
                             <div class="swiper-slide" style="background-image:url({{ $i->getUrl() }})">
                             <img data-src="{{ $i->getUrl() }}" src="{{ $i->getUrl() }}" alt="Photo">
                            </div>
                            @endforeach
                        </div>
                    </div>
            </div>
        </div><!-- panel -->
    </div><!-- col-md-10 -->

</div><!--row-->
@section('after-scripts')
<script src='/js/swiper/swiper.jquery.js'></script>
<script>
  $(document).ready(function () {
    //initialize swiper when document ready
    var mySwiper = new Swiper ('.swiper-container', {
      // Optional parameters
      pagination: '.swiper-pagination',
      paginationClickable: true,
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
    })
  });
</script>
@stop
@section('before-styles')
<link rel="stylesheet" href="/css/swiper/swiper.css">
<style>
    html, body {
        position: relative;
        height: 100%;
    }
    .swiper-container {
        width: 100%;
        height: 100%;
    }
    .swiper-slide {
        text-align: center;
        font-size: 18px;
        background: #fff;
        width: auto;
        /* Center slide text vertically */
        display: -webkit-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-box-pack: center;
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-box-align: center;
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
    }
    </style>
@stop

编辑: 这修好了它:

.swiper-container img {
    width: 100%;
 }

1 个答案:

答案 0 :(得分:0)

图片本身有max-width: 100%;。实际宽度由.swiper-container .swiper-container-horizontal定义,但在div之间有width: 100%个{{1}}层。

这个问题可能比理解更容易解决。我在Linux上,但我会做出一些猜测。

可能是因为图像没有宽度,IE使用最大宽度。

尝试在图像上定义宽度。

尝试删除max-width,和/或将其应用于父级。