javascript - 过早适应窗口调整大小的图像

标签 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;
}

最佳答案

尝试修复这些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 在中心显示,而不是使用最大宽度并避免填充。

关于javascript - 过早适应窗口调整大小的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31067699/

相关文章:

javascript - 在调整大小时获取 div 内容的高度 - vanilla javascript

javascript - _.assign 仅当属性存在于目标对象中时

javascript - Chart.js 在初始化时设置事件段

jquery - 如何在日期时间选择器中添加时间

javascript - 按 unix 时间戳数据属性对元素进行排序

javascript - 影响链接 :focus 上的表行 CSS

JavaBeans - 按字母顺序排序

javascript - 如何将项目添加到本地存储

javascript - 根据当前过滤器过滤源数组,并将其某些值放入 ng-repeat 项

javascript - 如何将图像和视频交换到另一个 div?