【发布时间】:2015-08-24 22:20:15
【问题描述】:
我仍然有很多麻烦,现在甚至很难描述这个问题。黄色文本区域应位于粉色 div 的边缘(右侧边缘),并且此黄色区域 div 与左侧的其他区域(包含绿色和红色区域)之间应有 30px 的边距。
如果我添加 'float:right;' 问题就解决了在“home-featured-class-3”中,但这会产生一个新问题,即把黄色文本区域 div 移到顶部。
如何使黄色文本 div 向右浮动,同时在中心垂直浮动? (不调整任何东西的高度/宽度)
HTML 和 CSS:
.home-featured-class-3{
width: 630px;
height:auto;
margin:0 0 0 30px;
display: inline-block;
vertical-align: middle;
background:#CF0;
}
.home-featured-class-4{
width:298px;
height:auto;
margin:0 0px 0 0;
border: 1px solid #211c20;
display: inline-block;
vertical-align: middle;
}
.home-featured-class-A{
width:960px;
height:auto;
background:#C3C;
vertical-align:middle;
}
.clear {
clear: both;
}
h6{
font-family:arial,verdana,helvetica,sans-serif;
font-size:18px;
color:#201c1f;
text-decoration:none;
text-transform:uppercase;
font-weight:100;
margin:0;
padding:10px;
background:#DB1D1D;
text-align:center;
border-top:1px solid #211c20;
}
h6 a:link{
color:#201c1f;
text-decoration:none;
}
h6 a:visited{
color:#201c1f;
text-decoration:none;
}
h6 a:hover{
color:#201c1f;
text-decoration:underline;
}
#home-featured-classes-wrap{
width:auto;
height:auto;
margin: 30px 0 0 0;
}
.home-featured-class:hover .products {
text-decoration: underline;
}
.home-featured-class-end{
width:298px;
height:auto;
margin:0 0 0 0;
border: 1px solid #211c20;
float:left;
}
.home-featured-class-end:hover .products {
text-decoration: underline;
}
<div id="home-featured-classes-wrap">
<div class="home-featured-class-A">
<div class="home-featured-class-4"><a href="products.html"><img name="RP-TEXT" src="http://upload.wikimedia.org/wikipedia/commons/d/de/Color-Green.JPG" width="298" height="148" alt="RP-TEXT" style="background-color: #3366FF" /></a>
<h6 class="products"><a href="products.html" title="RP-TEXT">RP-TEXT</a></h6>
</div>
<div class="home-featured-class-3">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</div>
<div class="clear"></div>
</div>
</div>
【问题讨论】: