艺术框架内的文本

时间:2012-12-20 00:07:15

标签: css image background border margin

我在这里感到沮丧,试图让我的div正确排队!我试图将我的文本放在艺术框架的图像中。 html是:

<div id="frame">
<div id="songtext">
<p>lorem ipsum dolor...</p>
</div>
</div>

CSS是:

#frame {
background:url(images/gold-frame-trans-bg.png) no-repeat; 
margin-left:auto;
margin-right:auto;
margin-top:0px;
width:650px;
height:750px;
}

#songtext {
width:336px;
height:410px;
margin-left:auto;
margin-right:auto;
margin-top:140px; 
overflow:auto;
}

当我这样做时,图像的顶部与文本的顶部对齐,位于屏幕顶部下方140px处。但如果我改变     #songtext {margin-top:140px;}  至     #songtext {padding-top:140px;) 文本显示在正确的位置,但滚动条仍然从页面顶部开始,中断图像。当我向上滚动时,文本会滚动图像,而不是隐藏在图像下面。 (这有意义吗?) 如果你想在视觉上看到它,这是页面: http://studentaccess.emporia.edu/~asmith40/AVAwebsite/seemsimpossible.html

1 个答案:

答案 0 :(得分:0)

你可以这样做:

#songtext {
 height: 410px;
 margin-left: 160px(or similar);
 margin-right: auto;
 margin-top: 140px;
 overflow: auto;
 position: absolute;
 width: 336px;

}