2013-01-12 50 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>