适应窗口的图像过早调整尺寸

时间:2015-06-26 07:42:08

标签: javascript jquery html css

我有这个分隔符,里面有图像。当我从右到左水平重新调整窗口大小时,图像会在浏览器的右端到达之前开始下降。当浏览器的右端到达时,有什么帮助使图像相互向下移动?

JSFIDDLE:https://jsfiddle.net/prtdaay1/2/

CSS:

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
ol, ul {
    list-style: none;
}
html {
    background-color: #FFFFFF;
    -webkit-font-smoothing: antialiased;
}
body {
    background-color: #ffffff;
    font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5em;
    color: #545454;
    background-color: #ffffff;
    text-align: center;
    max-width:1600px; 
    overflow: hidden;
    overflow-y: scroll;
}
h1, h2, h3, h4, h5, h6 {
    color: #222;
    font-weight: 600;
    line-height: 1.3em;
}
h2 {
    margin-top: 1.3em;
}
.custom-class {
    text-align: right;
    margin-top:-130px;
    margin-right: 20px;
}
a {
    color: #000000;
    text-decoration: none;
}
b, strong {
    font-weight: 600;
}
samp {
    display: none;
}
img {
    -webkit-animation: colorize 2s cubic-bezier(0, 0, .78, .36) 1;
    animation: colorize 2s cubic-bezier(0, 0, .78, .36) 1;
    background: transparent;
    border-style:none;
    border-radius: 4px;
    display: block;
    margin: 1.3em auto;
    max-width: 95%;
}
.logo {
    text-align: center;
    margin-top:40px;
}
li {
    list-style-type: none;
    font-size: 1.5em;
    padding-top: 8px;
    text-align:center;
    border-style: none;
}


.menu li {
    position: relative;
    top: 180px;
    left: 0px;
}
#item7 {
    transition: opacity .8s, left .8s ease-out;
    -moz-transition: opacity .8s, left .8s ease-out;
    -webkit-transition: opacity .8s, left .8s ease-out;
    -o-transition: opacity .8s, left .8s ease-out;
    margin-left:105px 
}
#item6 {
    transition: opacity 1s, left 1s ease-out;
    -moz-transition: opacity 1s, left 1s ease-out;
    -webkit-transition: opacity 1s, left 1s ease-out;
    -o-transition: opacity 1s, left 1s ease-out;
    margin-left: 95px;
}
#item5 {
    transition: opacity 1.2s, left 1.2s ease-out;
    -moz-transition: opacity 1.2s, left 1.2s ease-out;
    -webkit-transition: opacity 1.2s, left 1.2s ease-out;
    -o-transition: opacity 1.2s, left 1.2s ease-out;
    margin-left: 60px;
}
#item4 {
    transition: opacity 1.4s, left 1.4s ease-out;
    -moz-transition: opacity 1.4s, left 1.4s ease-out;
    -webkit-transition: opacity 1.4s, left 1.4s ease-out;
    -o-transition: opacity 1.4s, left 1.4s ease-out;
    margin-left: 123px;
}
#item3 {
    transition: opacity 1.6s, left 1.6s ease-out;
    -moz-transition: opacity 1.6s, left 1.6s ease-out;
    -webkit-transition: opacity 1.6s, left 1.6s ease-out;
    -o-transition: opacity 1.6s, left 1.6s ease-out;
    margin-left: 113px;
}
#item2 {
    transition: opacity 1.8s, left 1.8s ease-out;
    -moz-transition: opacity 1.8s, left 1.8s ease-out;
    -webkit-transition: opacity 1.8s, left 1.8s ease-out;
    -o-transition: opacity 1.8s, left 1.8s ease-out;
    margin-left: 130px;
}
#item1 {
    transition: opacity 2s, left 2s ease-out;
    -moz-transition: opacity 2s, left 2s ease-out;
    -webkit-transition: opacity 2s, left 2s ease-out;
    -o-transition: opacity 2s, left 2s ease-out;
    margin-left: 117px;
}

#item1>button{background:none;border:none;outline:none;cursor:pointer;font-size: 1em;}
#item2>button{background:none;border:none;outline:none;cursor:pointer;font-size: 1em;}
#item3>button{background:none;border:none;outline:none;cursor:pointer;font-size: 1em;}
#item4>button{background:none;border:none;outline:none;cursor:pointer;font-size: 1em;}
#item5>button{background:none;border:none;outline:none;cursor:pointer;font-size: 1em;}
#item6>button{background:none;border:none;outline:none;cursor:pointer;font-size: 1em;}
#item7>button{background:none;border:none;outline:none;cursor:pointer;font-size: 1em;}

.permahover li {
    opacity: 1;
    left: -33%;
}
.headlines li {
    font-size:1.5em;
    color:#000000;
    transition: all 0.5s;
    cursor: pointer;
}
.headlines:hover li, .headlines.active li {
    /* PARENT HOVER */
    opacity:0.4;
    cursor: pointer;
    /* Dim all */
}
.headlines li:hover, .headlines li.active {
    /* SINGLE HOVER */
    opacity: 1;
    /* Max one */
    color:#000000;
    cursor: pointer;
}

#first
{  display: none;
     width: 50%;
    height: 220px;
    top: 20%;
    margin: auto;

    position: relative;


}
#first img 
{
     height: 100px;
    width: 100px;
    float:left;
    margin-right: 5%;
    cursor: pointer;
}

#second
{

    width: 50%;
    height: 220px;
    margin:auto;
    padding-left: 170px;
    margin-top: -215px;

}
#second img 
{
    height: 100px;
    width: 100px;
    float:left;
    margin-right: 5%;
    cursor: pointer;
}

#third
{
    display: none;
    width: 50%;
    height: 220px;
    margin:auto;
    padding-left: 150px;
    margin-top: -215px;

}
#third img 
{
    height: 100px;
    width: 100px;
    float:left;
    margin-right: 5%;
    cursor: pointer;
}



@-webkit-keyframes colorize {
    0% {
        -webkit-filter: grayscale(100%);
    }
    100% {
        -webkit-filter: grayscale(0%);
    }
}

@keyframes colorize {
    0% {
        filter: grayscale(100%);
    }
    100% {
        filter: grayscale(0%);
    }
}

}

<!-- slider css-->

#wrapper {
    width: 10%;
    padding: px 0;

}

#slider-container {
    padding: 20px 50px;
    height: 300px;
    top:-18%;
    left: 50px;
    width: 700px;
    overflow: hidden;
    position: relative;
}

.slider-view-area {
    overflow: hidden;
    max-height: 300px;

}

#nav p {
    position: absolute;
    top: 40px;
    left: 0px;
    cursor:pointer;
    color:grey;


}
#prev {
    margin-left: 520px;
    font-size: 30px;
}
#next {
    right: -440px;
    font-size: 30px;
}

#mask {
    width: 5000px;
    height: 100%;

}

.item {
    width: 1200px;
    height: 100%;
    float: left;

}
.content img {
    height: 100px;
    width: 17%;
    float:left;
    margin-right:  10px;
    margin-bottom: 10px;
    cursor: pointer;
}
.content {
    width: 50%;
    height: 220px;
    top: 30px;
    left: 
    margin: auto;

    position: relative;
}
.content a {
    position: relative;
    top: -17px;
    left: 170px;
}
.selected {
    background: #fff;
    font-weight: 700;
}
.clear {
    clear:both;
}

.hidden {
    display: none;
}

1 个答案:

答案 0 :(得分:0)

尝试修复这些id的风格

#second {
    height: 220px;
    margin: -215px auto auto;
    padding-left: 170px;
    width: 50%;
    }


#third {
   display: none;
   height: 220px;
   margin: -215px auto auto;
   padding-left: 150px;
   width: 50%;
   }

而不是使用最大宽度并避免填充,您可以使用margin:auto来显示在中心。