gpt4 book ai didi

javascript - 具有未指定高度 CSS 的 Div

转载 作者:太空宇宙 更新时间:2023-11-04 14:51:52 26 4
gpt4 key购买 nike

我有一个带有背景图片的div,但我不想设置它的高度,因为内容会随着时间的推移而添加,我希望它能自动扩展。基本上,我想要这样的东西:

http://i.stack.imgur.com/OvLDo.jpg

重复的部分会垂直重复,根据内容创建更高的div。我希望有人对此有解决方案。

谢谢。

最佳答案

您可以创建三个部分(顶部、底部、内容)。顶部和底部(不重复)和内容(重复-y)

HTML

<div class="block">
<div class="top"></div>
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="bottom"></div>
</div>

CSS

.block {
width: 947px;
}

.top {
background: url(https://dl.dropboxusercontent.com/u/122540013/img/unspecified-height/top.png) no-repeat;
height: 60px; // set height for your image
}

.content {
background: url(https://dl.dropboxusercontent.com/u/122540013/img/unspecified-height/content.png) repeat-y;
padding: 0 57px;
overflow: hidden;
}

.bottom {
background: url(https://dl.dropboxusercontent.com/u/122540013/img/unspecified-height/bottom.png) no-repeat;
height: 60px; // set height for your image
}

演示

http://dabblet.com/gist/5865448

关于javascript - 具有未指定高度 CSS 的 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17310591/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com