【问题标题】:How to make Nivo Slider 100% height of the browser?如何使 Nivo Slider 100% 浏览器高度?
【发布时间】:2014-08-07 05:50:23
【问题描述】:

我正在使用 Nivo Slider 开发一个网站:Website Demo

问题是,滑块部分不会 100% 跟随浏览器的高度。我该怎么做?

我一直在检查并发现这个 css 代码:

.nivoSlider {
  position:relative;
  width:100%;
  height:auto;
  overflow: hidden;
  left:0;
  margin-top:100px;
}

根据我的 CSS 知识,我们可以将 height:auto; 更改为 height:100% 以使滑块 100% 高度。唉,它不起作用!

我在这里错过了什么?

更新

发现滑块的图片占满了大小,写在这里:

.nivoSlider img {
  position: absolute;
  top: 0px;
  left: 0px;
  max-width: none;
  max-height: 100%; // I ADDED THIS TO MAKE 100% HEIGHT AND IT WORKS!!!
}

尽管如此,图像现在正在被拉伸,我怎样才能使图像剪切而不是拉伸?

【问题讨论】:

    标签: css nivo-slider


    【解决方案1】:

    看看下面的课程。您已指定900px 高度。

    .nivoSlider:after {
    content: '';
    background: transparent url(../../images/parallax_slider/pattern.png) repeat top left;
    position: absolute;
    height: 900px;
    left: 0;
    top: 0;
    width: 100%;
    z-index: 5;
    }
    

    【讨论】:

    • 忘记提了,但是我试过了,还是不行。不过我发现了一些东西,即将滑块内的 img 设置为 max-height: 100%;它可以工作,但现在图像被拉伸了。我正在寻找解决方案。
    猜你喜欢
    • 2013-09-12
    • 1970-01-01
    • 2010-12-07
    • 1970-01-01
    相关资源
    最近更新 更多