html - 将 div 与图像水平对齐,并能够水平滚动它们

标签 html css

您好,我正在尝试制作一个网站,看起来就像我开车经过各个城市一样。

当我水平滚动网页时,背景中的图像不断变化。

Some thing like this, but I want to add the images as a div and not an image.

here is my jsfiddle

HTML

<body>
    <div style="height:400px; width:100%; clear:both;"></div>
    <div class="image-holder">
        <img src="http://www.japaneseammo.com/wp-content/uploads/2014/12/bigstock-Mt-Fuji-with-fall-colors-in-j-48491102.jpg" alt="">
    </div>
    <div class="image-holder">
        <img src="http://www.japaneseammo.com/wp-content/uploads/2014/12/bigstock-Mt-Fuji-with-fall-colors-in-j-48491102.jpg" alt="">
    </div>
        <div class="image-holder">
        <img src="http://www.japaneseammo.com/wp-content/uploads/2014/12/bigstock-Mt-Fuji-with-fall-colors-in-j-48491102.jpg" alt="">
    </div>
            <div class="image-holder">
        <img src="http://www.japaneseammo.com/wp-content/uploads/2014/12/bigstock-Mt-Fuji-with-fall-colors-in-j-48491102.jpg" alt="">
    </div>
                <div class="image-holder">
        <img src="http://www.japaneseammo.com/wp-content/uploads/2014/12/bigstock-Mt-Fuji-with-fall-colors-in-j-48491102.jpg" alt="">
    </div>
    <!-- Image of me just standing or probably an image created in Sketch -->
    <div id="my-">

    </div>
</body>

CSS

    .container{ 
    width:50%; 
    margin:0 auto; 
}
.container span{ 
    width:30%; 
    margin:0 1%;  
}
#walking-man{
    position: fixed;
    width: 300px;
    height: 100px;
    background-color: red;
}

谢谢

最佳答案

简单的 html:

<div class="background">
    <img src="your image" alt="">
    <img src="your image" alt="">
    <img src="your image" alt="">
    <img src="your image" alt="">
</div>

<div class="content"></div>

和 CSS:

.background {
    position:absolute;
    z-index:-1;
    top:0;
    left:0;
    white-space:nowrap;
}
.background img {
    display:inline-block;
}

FIDDLE

关于html - 将 div 与图像水平对齐,并能够水平滚动它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33150226/

相关文章:

html - 字体渲染不流畅

php - 将空白区域回显为 html 字符

IE8 中的 CSS 问题

javascript - 动态附加元素后重新应用样式属性

CSS 在 div 后添加行

html - 固定 Header 与内容重叠,无法用 padding 或 margin 修复

css - 带有 Canvas 元素的 OpenType 样式集

带有作者的 HTML5 block 引用

html - CSS 网格不适用于 IE 或 Edge

CSS3 导航超链接倾斜