css - 响应式对齐、 float 和居中图像

标签 css responsive-design css-float alignment

我正在尝试弄清楚如何编写我的 HTML 和 CSS 代码以使 3 个屏幕截图图像对齐,如下面的屏幕截图所示。

这个想法是,当用户将窗口的大小调整得更小时,左右两侧的图像应该向中心移动,或者更靠近主图像,并且主图像始终保持居中。

我的开发链接: http://leongaban.com/portfolio/athenasweb/

我的 CodePen http://codepen.io/leongaban/pen/AwJFt

enter image description here

如有提示或指导,我们将不胜感激! :D

HTML

<div class="pattern">

    <div class="athena_thumbs">

        <div class="first">
            <img src="../../images/athena1.jpg"/>
        </div>

        <div class="second">
            <img src="../../images/athena2.jpg"/>
        </div>

        <div class="third">
            <img src="../../images/athena3.jpg"/>
        </div>

    </div>

</div>

CSS

div.inner .pattern {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:url('http://leongaban.com/images/pattern_diagonal_lines.png');
    background-repeat: repeat;
    z-index:2;
 }    

.athena_thumbs {
    position: absolute;
    max-width: 1000px;
    margin: 250px auto 0;
}

.athena_thumbs .first {
    position: relative;
    margin: 0 auto;
    float: left;
    left: 25%;
    right: 25%;
    z-index: 3;
}

.athena_thumbs .second {
    position: relative;
    float: left;
    left: 10%;
    right: 5%;
    z-index: 2;
}

.athena_thumbs .third {
    position: relative;
    float: left;
    right: 10%;
    left: 5%;
    z-index: 1;
}

最佳答案

开会迟到。 但是,如果你看一下

代码笔:http://codepen.io/anon/pen/bazEr

.athena_thumbs {
    position: absolute;
    width: 90%;
    margin-left: 5%;  
    text-align: center;
    overflow: hidden;
}

.athena_thumbs .first {
    position: relative;
    margin: 0 auto;
    z-index: 3;
}

.athena_thumbs .second {
    position: absolute;
    left: 0px;
    top: 0px;
    z-index: 2;
}

.athena_thumbs .third {
    position: absolute;
    right: 0px;
    top: 0px;
    z-index: 1;
}

我认为这会让您朝着正确的方向前进。 跨浏览器检查没有任何障碍。 只是基本的相应效果或多或少到位。

希望这对您有所帮助。

关于css - 响应式对齐、 float 和居中图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15328130/

相关文章:

javascript - Ajax 选项卡设置不适用于本地主机 (EasyTabs)

html - 在第四个旁边 float 三个 div

html - 两个 div 中的段落对齐,它们之间有一个图像

html - float 重叠文本重叠图像

css - 有没有办法从 Capybara 元素获取 CSS/XPath?

css - 使用 CSS 仅隐藏 Div 的底部阴影

css - 使用 "font-variant:small-caps"处理 ß

html - 使用 Bootstrap 自动缩放文本字段

css - 是否可以给 css 属性一个负的百分比值?

html - 网格状文章布局