2015-09-10 49 views
0
<div class="site-rating" itemscope="" itemtype="http://schema.org/Product"> 
     <span itemprop="name">Example.com</span> 
     <div itemprop="aggregateRating" itemscope="" itemtype="http://schema.org/AggregateRating"> 
     was rated <span itemprop="ratingValue">4</span>/5 based on <a href="#reviews" rel="nofollow"><span itemprop="reviewCount">178</span> reviews</a> 
     </div> 
</div> 

此代碼顯示以下內容:HTML文本是沒有CSS樣式一行更高的附加

enter image description here

我試過white-space:nowrap,但它不工作。

如何將example.com文本移動到與其他文本相同的行中?

回答

1

嘗試這樣的:Demo

.site-rating span,.site-rating div{ 
    display:inline; 
} 

white-space不會在你的情況下工作。如果您使用display inline to span和位於site-rating內部的div,則可以將兩個對齊在同一行中。

1

allcote 1號到你內心的div

和下面的樣式

#innerDiv { 
 
    display:inline; 
 
    }
<div class="site-rating" itemscope="" itemtype="http://schema.org/Product"> 
 
     <span itemprop="name">Example.com</span> 
 
     <div id="innerDiv" itemprop="aggregateRating" itemscope="" itemtype="http://schema.org/AggregateRating"> 
 
     was rated <span itemprop="ratingValue">4</span>/5 based on <a href="#reviews" rel="nofollow"><span itemprop="reviewCount">178</span> reviews</a> 
 
     </div> 
 
</div>

1

你必須移動Example.com跨度同一div內的所有其他跨度元素,像這樣:

<div class="site-rating" itemscope="" itemtype="http://schema.org/Product"> 
     <div itemprop="aggregateRating" itemscope="" itemtype="http://schema.org/AggregateRating"> 
     <span itemprop="name">Example.com</span> 
     was rated <span itemprop="ratingValue">4</span>/5 based on <a href="#reviews" rel="nofollow"><span itemprop="reviewCount">178</span> reviews</a> 
     </div> 
</div> 

在輸出然後你會看到:

Example.com 被評爲4/5,基於178評論