2013-11-28 27 views

回答

4

嘗試插入一個div內的圖像,並把文字上這樣說:

<div class="img"> 
    <p>your text</p> 
</div> 

CSS:

.img{ 
    background: url('http://findicons.com/files/icons/941/web_design/32/page_text.png') no-repeat; 
    height:100%; 
} 

DEMO

後,您可以模式您的文字,你想要

如果你不想使用像backgrou一樣的圖像第二,你只想把文字在你的元素的中心試試這個:

<div class="container"> 
    <img src="http://findicons.com/files/icons/941/web_design/32/page_text.png" /> 
    <span>your text</span> 
    <br style="clear:both;" /> 
</div> 

CSS

.container{ 
    width:100%; 
    height:100px; 
} 

.container span{ 
    line-height:30px; 
    float:left; 
} 

.container img{ 
    float:left; 
} 

DEMO2

+0

嗯,這可以工作,但圖像的一部分已經消失了(在底部),我需要在css中爲每個圖像創建一個新的代碼,這是20+。 – user2989236

+0

編輯答案和demo1現在圖像已滿@ user2989236 –

+0

好吧,感謝您的幫助,工作! – user2989236

0

演示: http://jsfiddle.net/5ser6/1/

<div class="thingy"> 
    <img src="http://findicons.com/files/icons/941/web_design/32/page_text.png" alt="" />   
     <p>Text</p> 
    <br style="clear:both;"> 
    </div> 


    * {font-family:arial} 
    .thingy img {float:left;} 
    .thingy {height:32px;float:left;} 
    .thingy p {float:left;margin:0 0 0 10px;padding:0;line-height:32px;} 

如果你的框架有一個clearfix,你不需要清楚:兩者,只是在外部div上放一個clearfix。

+0

你在堆疊這些嗎?他們去哪裏。如果你使用它,它將需要在主包裝上清除以堆疊,或者你在包裝上粘貼一個包裝。 – Christina