有一个带背景的页面。以前是作为 img:src 给出的。但我不能在上面插入文字。因此,我将该代码更改为背景图像。到目前为止一切正常。
然后我要插入的文本很长,它超过了背景的高度。我必须添加一个卷轴。我插入了 max-height 但在这里感到困惑。
这里的页面是:http://www.heptasarim.com/test/cezayir2/menuler2.html
后台地址:/cezayir/images/menuorta.png
HTML:
<div id="menuorta2">
<p style="background-image:url(images/menuorta.png); background-repeat:no-repeat; width:812px; height:404px;" id="myazi">
<span class="mbaslik">Kokteyl Prolonge Menü</span><br />
<strong>menü:</strong><br />
<strong>soğuk gezenler:</strong><br />
biberli zeytin ve marine somon<br />
tartolet içinde nar ekşili patlıcan salata<br />
hindi füme badem turşu ve hardal<br />
marine zeytin ve peynir şiş<br />
<strong>sıcak gezenler:</strong><br />
şişte ızgara limon ve kalamar<br />
susamlı et<br />
sigara böreği<br />
<strong>sıcak büfe:</strong><br />
dana külbastı<br />
kuru erikli tavuk<br />
patlıcan beğendi<br />
pilav ve salata<br />
<strong>tatlılar:</strong><br />
bal kabaklı cheese cake<br />
portakallı irmik helvası<br />
</p>
</div>
CSS:
#menuorta {
top:165px;
left:50px;
position:absolute;
z-index:0;
}
#menuorta2 {
top:127px;
left:20px;
position:absolute;
z-index:1;
}
#myazi {
color:#401c17;
font-weight:100;
font-family:Bookman Old Style;
font-size:13px;
padding:40px 65px;
max-height:200px;
overflow:hidden;
}
.mbaslik {
font-weight:bold;
font-size:16px;
}
固定:
background: url(../image/menuorta.png) no-repeat;
.. 和/
非常非常感谢大家。特别是@ferne97
最佳答案
将它设置为你想要的宽度和高度,并添加一个 overflow-y: scoll;
到它。
#myazi {
width: 600px;
height: 200px;
overflow-y: scroll;
}
如果你想让背景比滚动区域大,像这样在里面放另一个div..
<div id="myazi">
<div class="inner-scroll">
<!-- content here -->
</div>
</div>
然后在css中添加这个..
#myazi {
background: url(path/image.png) no-repeat;
width: 800px; /* width of actual image */
height: 600px; /* height of actual image */
}
.inner-scroll {
width: 600px; /* width of content area */
height: 200px; /* height of content area */
overflow-y: scroll;
}
关于css - 背景图片和滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14845213/