2013-01-12 51 views
0

我在div中使用圖像作爲文本框,並且該圖像上有一個邊框/浮雕圖案,因此文本覆蓋了該部分,看起來很糟糕,所以我想定位文本CCA 15個像素的權利,但不管我試過不行將文本定位在文本框中的背景圖片

HTML:

<div id=textarea> 
    <h2> Tardis -time music festival </h2> 
    <p> 
    <br/> Hello fellow time travelers, 
    <br/> Do you enjoy Music as much as Time travel? 
    <br/> If you do this is the right festival for you! 
    <br/> You don't even have to travel, we come to you, 
    <br/> And take you tot he biggest time adventure of your life!! 
    <br/> experience birth of music, the first rock song and much much more. 
    </p> 
</div> 

和css:

#textarea{ 
    background-image:url(images/text.png); 
    background-repeat:no-repeat; 

    border:none; 
    width: 910px; 
    height:300px; 
    color:#CAAA5B; 
    padding:3px; 
    margin-right:4px; 
    margin-bottom:8px; 
    float:right; 
} 

回答

1

如果你想將你的DIV containin摹文本向右只使用一個位置移動...例:

#textarea{ 
postion:relative; 
left:15px; 
} 

這可能會改變你的背景圖像很好,但如果這樣做,你可以添加其他的div只是文本,不會影響圖像在周圍的div。

div id=textarea> 
<div id="text"> 
       <h2> Tardis -time music festival </h2> 
     <p> 
      <br/> Hello fellow time travelers, 
      <br/> Do you enjoy Music as much as Time travel? 
      <br/> If you do this is the right festival for you! 
      <br/> You don't even have to travel, we come to you, 
      <br/> And take you tot he biggest time adventure of your life!! 
      <br/> experience birth of music, the first rock song and much much more. 
        </p> 
        </div></div> 

<style> 
#text{ 
postion:relative; 
left:15px; 
} 
</style> 
+0

出於某種原因,沒有工作,我相當convinved我的CSS有個性,討厭我現在出於某種原因,但我在整個p標籤 –

+0

@TrogdoraOresic填充固定它:你有沒有嘗試兩個例子?同時將你的上下文代碼粘貼到http://jsfiddle.net/的jsfiddle中,然後發佈鏈接,以便更好地瞭解你的上下文代碼,以查看導致錯誤的原因。 –

+0

我也嘗試過兩種方法,但它對代碼沒有任何影響,但是我固定它就像這樣,即使它是一種硬編碼,但它起作用,所以我不會碰它 –

-1

你嘗試只是瞄準在你的CSS的DIV內的元素?

<style> 
#textarea p h2 { 
postion:relative; 
left:15px; 
} 
</style>