我正在尝试将导航栏放在一起,如下所示:
http://s7.postimage.org/jhfi6rbp7/gallerybar.jpg
所有正方形都是单独的图像,我想对齐包含橙色条.jpg的div标签的左侧。
这是我到目前为止所做的:
<div id="rule">
<img src="../images/rule2.jpg" width="750" height="1" >
<div id=" gallery">
<img src="../images/portfolio/gallery_bplogo_active.jpg" alt="Logo Design" width="112" height="112"/>
<img src="../images/portfolio/gallery_bpprint.jpg" width="112" height="112" alt="Magazine and Newspaper Ads" />
<img src="../images/portfolio/gallery_bpradio.jpg" width="112" height="112" alt="Radio Spot" />
<img src="../images/portfolio/gallery_bptelevision.jpg" width="112" height="112" alt="TV Spot" />
<img src="../images/portfolio/gallery_bpvehiclewrap.jpg" width="112" height="112" />
</div>
</div>
#rule {
border:0;
text-align: center;
}
#gallery {
height: 115px;
margin: 20px;
position: absolute;
border: 20 px;
border-color:#FFF;
}
我无法弄清楚如何将图像垂直居中在条形图上 - 它们坚持在它下面漂浮。
答案 0 :(得分:0)
试试这个:
#gallery img {float: left; margin-right: 10px;}
答案 1 :(得分:0)
您的图片需要在img标记内对齐。
img {
vertical-align:middle;
}
答案 2 :(得分:0)
尝试以下解决方案http://jsfiddle.net/chrisdanek/CN3Tb/
#gallery {
padding: 0 20px;
position: relative;
}
#gallery img {
position: relative;
background: #fff;
}
#gallery:before {
position: absolute;
content: "";
border: 1px solid orange;
top: 50%;
left: 0;
right: 0;
}
<div id="gallery">
<img src="image.jpg" width="112" height="112">
<img src="image.jpg" width="112" height="112">
<img src="image.jpg" width="112" height="112">
<img src="image.jpg" width="112" height="112">
</div>
我删除了不必要的标记并简化了CSS。