这是我的图像:
我不知道如何使文字Lieu,Suchy,Prix,CHF 2 250在图像中对齐。因为我也是新手,所以我想知道我所做的是否正确。
.boxes-images img {
width: 100%;
}
.boxes-images h4 {
text-align: center;
background-color: #8C1211;
color: #FFFFFF;
padding: 10px 0px 10px 0px;
font-weight: bold;
margin-top: 0px;
margin-bottom: 0px;
}
.boxes-images .details {
background-color: #D6D6D6;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
}

<div class="text-page">
<div class="row">
<div class="col-sm-3 boxes-images">
<img src="images/automobile.jpg">
<h4>IMMOBILIER</h4>
<div class="details">
<p>Magnifique et spacieux 4,5 pieces: 1mios de loyer</p>
<p>Lieu<span>suchy</span>
<p>
<p>Prix<span>CHF 2'250</span>
</p>
</div>
</div>
<div class="col-sm-3 boxes-images">
<img src="images/automobile.jpg">
<h4>IMMOBILIER</h4>
<div class="details">
<p>Magnifique et spacieux 4,5 pieces: 1mios de loyer</p>
<p>Lieu<span>suchy</span>
<p>
<p>Prix<span>CHF 2'250</span>
</p>
</div>
</div>
<div class="col-sm-3 boxes-images">
<img src="images/automobile.jpg">
<h4>IMMOBILIER</h4>
<div class="details">
<p>Magnifique et spacieux 4,5 pieces: 1mios de loyer</p>
<p>Lieu<span>suchy</span>
<p>
<p>Prix<span>CHF 2'250</span>
</p>
</div>
</div>
<div class="col-sm-3 boxes-images">
<img src="images/automobile.jpg">
<h4>IMMOBILIER</h4>
<div class="details">
<p>Magnifique et spacieux 4,5 pieces: 1mios de loyer</p>
<p>Lieu<span>suchy</span>
<p>
<p>Prix<span>CHF 2'250</span>
</p>
</div>
</div>
<div class="col-sm-3 boxes-images">
<img src="images/automobile.jpg">
<h4>IMMOBILIER</h4>
<div class="details">
<p>Magnifique et spacieux 4,5 pieces: 1mios de loyer</p>
<p>Lieu<span>suchy</span>
<p>
<p>Prix<span>CHF 2'250</span>
</p>
</div>
</div>
<div class="col-sm-3 boxes-images">
<img src="images/automobile.jpg">
<h4>IMMOBILIER</h4>
<div class="details">
<p>Magnifique et spacieux 4,5 pieces: 1mios de loyer</p>
<p>Lieu<span>suchy</span>
<p>
<p>Prix<span>CHF 2'250</span>
</p>
</div>
</div>
<div class="col-sm-3 boxes-images">
<img src="images/automobile.jpg">
<h4>IMMOBILIER</h4>
<div class="details">
<p>Magnifique et spacieux 4,5 pieces: 1mios de loyer</p>
<p>Lieu<span>suchy</span>
<p>
<p>Prix<span>CHF 2'250</span>
</p>
</div>
</div>
<div class="col-sm-3 boxes-images">
<img src="images/automobile.jpg">
<h4>IMMOBILIER</h4>
<div class="details">
<p>Magnifique et spacieux 4,5 pieces: 1mios de loyer</p>
<p>Lieu<span>suchy</span>
<p>
<p>Prix<span>CHF 2'250</span>
</p>
</div>
</div>
</div>
</div>
&#13;
答案 0 :(得分:1)
鉴于您的标记,最简单的方法是将span
元素浮动到这些父p
元素中:
.boxes-images .details p span{
float: right;
}
或者使用bootstraps .pull-right
class:
.pull-right {
float: right !important;
}
答案 1 :(得分:0)
只需将float:right
添加到位于span tag
内的p tag
即可。您甚至可以使用p
或span
为pseudo element
分配class
和span tag
之间的间距。
.boxes-images .details > p > span{
float:right;
}
/*Using Pseudo element*/
.boxes-images .details > p > span:before{
content:'';
margin-left:50%;
background:#111;
}
/* Add pull-right to span tag works and you don't need to add any custom css,
as pull-right is pre-defined class of bootstrap that floats your element to right,
so add that to all your span tag too work*/
<div class="details">
<p>Magnifique et spacieux 4,5 pieces: 1mios de loyer</p>
<p>Lieu<span class="pull-right">suchy</span>
<p>
<p>Prix<span class="pull-right">CHF 2'250</span>
</p>
</div>