使用媒体查询使滑块响应

时间:2015-03-19 22:27:59

标签: jquery html css responsive-design slider

这是一个页面:http://simply-black.stonerbunting.com

我试图让这个网站变得敏感。我尝试了几种stackoverflow解决方案,但主页上的滑块没有正确响应。

我尝试使用这个css:

.slider-wrapper .slider li .slide{
    height: 250px;
    background-position: left top;
    background-repeat: no-repeat;
    background-size: 100% 100%;
}
.slider-wrapper{
    width: 100%;
    height: 473px;
}
.slider-wrapper .slider{
    width: 100%;
}
.slider-wrapper .slider li{
width: 100%;
}

使用jcarousel自定义滑块。你能指导正确的方向吗?

感谢您宝贵的时间.. :)

1 个答案:

答案 0 :(得分:1)

不确定这对你的结果有多好。我在Firefox中玩它似乎工作正常:

/* Breakpoint: 768px - Set to whatever value you want. You might want to duplicate this query and change the height of .slider-wrapper .slider li to target different screen resolutions */ 

@media (max-width: 768px) {

    .container { 
        padding: 0;
        width: 100%;
    }

    .slider-wrapper{
        width: 100% !important;
        height: auto;
    }

    .slider-wrapper .slider {
        width: 2000%;
    }

    .slider-wrapper .slider li {
        width: 5% !important;
        position: relative;
        min-height: 300px; /* change this to whatever value you want */
    }

    .slider-wrapper .slider li .slide {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background-size: cover;
    }

    /* Text */
    .slider-wrapper .slider li .overlay {
        width: 60%; /* change this to whatever value you want */
        top: 10%;
        /*display: none; */ /* uncomment display:none; to hide text on smaller screens if needed */
    }

    .slider-wrapper .slider li .overlay .text {
        padding: 10px;
    }

}

/* iPad - landscape */

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) {

    .slider-wrapper .slider li {
        min-height: 722px;
    }

}

/* iPad - Portrait */

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) {

    .slider-wrapper .slider li {
        min-height: 973px;
    }

    /* optional - make navbar reach the bottom of the page */
    .container { position: absolute !important; height: 100%; top: 0; right: 0; bottom: 0; left: 0; }
    .navbar { height: 95% }

}