2015-04-20 52 views
0

以下是我的代碼。我希望將文字包裹在圖像上。我用q {float: left; width: 100%}。然而,文字出現在圖片下方。如何使用CSS在圖像周圍纏繞文本

<p class = "review"> 
    <img src="https://webster.cs.washington.edu/images/fresh.gif" alt="Fresh" /> 
    <q>TMNT is a fun, action-filled adventure that will satisfy longtime fans and generate a legion of new ones.</q> 
</p> 

是否有任何其他方式來包裹我的文字在圖像周圍?謝謝!

回答

0

<q>顯示屬性更改爲display:inline並刪除width屬性。這會將它與圖像對齊

0

您實際上需要將圖像浮起。這將導致你想要的行爲 - 讓文字環繞圖像。

0

您可以使用跨度每日新聞或你的CSS使用display:inline

Working demo

<span>Hello!</span><span><img src="https://webster.cs.washington.edu/images/fresh.gif" alt="Fresh" /></span><span>How are you!</span> 
1

<p class = "review"> 
 
<img src="https://webster.cs.washington.edu/images/fresh.gif" alt="Fresh" style="float:left"/> 
 
<q>TMNT is a fun, action-filled adventure that will satisfy longtime fans and generate a legion of new ones.</q> 
 
</p>

+0

這將是沒有內嵌樣式更好! –

0

你想浮動imageq

.review {width:100%;} 
 
.review img {float:left; margin:7px; vertical-align:top;}
<p class = "review"> 
 
<img src="https://webster.cs.washington.edu/images/fresh.gif" alt="Fresh" /> 
 
<q>TMNT is a fun, action-filled adventure that will satisfy longtime fans and generate a legion of new ones.</q> 
 
    <q>TMNT is a fun, action-filled adventure that will satisfy longtime fans and generate a legion of new ones.</q> 
 
    <q>TMNT is a fun, action-filled adventure that will satisfy longtime fans and generate a legion of new ones.</q> 
 
</p>