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;
}
4

2 回答 2

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>
于 2013-01-12T20:11:01.497 回答
-1

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

<style>
#textarea p h2 {
postion:relative;
left:15px;
}
</style>
于 2013-01-12T20:54:49.057 回答