我正在尝试弄清楚如何编写我的 HTML 和 CSS 代码以使 3 个屏幕截图图像对齐,如下面的屏幕截图所示。
这个想法是,当用户将窗口的大小调整得更小时,左右两侧的图像应该向中心移动,或者更靠近主图像,并且主图像始终保持居中。
我的开发链接: http://leongaban.com/portfolio/athenasweb/
我的 CodePen http://codepen.io/leongaban/pen/AwJFt
如有提示或指导,我们将不胜感激! :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/