将文本放在文本框内的CSS中(背景图像)

时间:2013-01-12 20:06:16

标签: html css textarea

我在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;
}

2 个答案:

答案 0 :(得分:1)

如果您想将包含文字的div移到右侧,只需使用位置转换......例如:

#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>

答案 1 :(得分:-1)

您是否尝试过定位CSS中div中的元素?

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