如何从该图像制作一个垂直可扩展的 DIV 框?
我想从此图像为我的网站创建一个样式化的 DIV 框:
如何使用 CSS 和 HTML 来做到这一点。
我将图像剪切为三个不同的部分:
但是我不知道如何将它们与 Div 一起使用来创建我的垂直消耗品盒子。
感谢您的帮助!
I would like to create from this image a styled DIV box for my website :
How can I do that using CSS and HTML.
I cut the image in three different parts :
However I don't know how to use them with Divs to create my vertically expendable box.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我假设您希望内容从顶部开始,但也扩展到第二个。如果是这种情况,那么您将需要在背景图像上进行一些重叠。
HTML
CSS
示例位于 http://www. jsfiddle.net/gaby/s8XZQ/
I assume that you want your content to start inside the top one, but expand to the second one as well. If that is the case then you will need some overlap on the background-images.
HTML
CSS
Example at http://www.jsfiddle.net/gaby/s8XZQ/
这可以通过 CSS3 功能(如边框半径、盒子阴影和渐变)来完成。这是一个示例。应该适用于 Opera、Firefox、Chrome 和 Safari。
另外,您可以使用 :before 和 :after CSS 伪元素来执行此操作,就像其他两个答案一样。
编辑:对于 Internet Explorer,所有这些功能都可以通过行为文件实现,例如 PIE。
This could be done with CSS3 features like border-radius,box-shadow and gradient. Here's an example. Should work in Opera, Firefox, Chrome and Safari.
Also, you can do this with :before and :after CSS pseudo-elements, like in other two answers.
Edit: For Internet Explorer all those features are possible with behavior file, like PIE.
试试这个:
HTML:
CSS:
调整 CSS 中的填充,使其与顶部图像和底部图像的高度相匹配,并调整容器宽度,使其与图像的宽度相匹配。
Try this:
HTML:
CSS:
Adjust the paddings in the CSS so that they match the height of your topimage and bottomimage, and the container width so that it matches the image's widths.
使用三个单独的 div,并将中间一个的顶部内边距设置为顶部的负高度。所以:
Use three separate divs, and set the top padding of the middle one to the minus height of the top one. So: