css - 我如何在CSS中制作具有背景的灵活div

标签 css

我正在尝试创建一个具有如下所示背景的灵活 div,关于我如何在 css 中实现它有什么建议吗?

enter image description here

最佳答案

为了获得最佳的跨浏览器兼容性,我建议将盒子分成三部分:

enter image description here

顶部和底部部件没有变化。中间的应该有 3px 的高度和宽度,并重复到 y 轴。

<div id="shadowbox">
  <div class="content">Your Content here</div>
  <div id="boxending"><!-- --></div>
</div>

#shadowbox {
 background: url(box_top_bg.gif) 0 0 no-repeat;
}

#shadowbox.content {
  background: url(box_content_bg.gif) 0 0 repeat-y;
  margin-top: //as high, as the top picture is
}

#boxending {
  background: url(box_bottom_bg.gif) 0 0 no-repeat;
}

如果您没有使用重置样式表,您可能会遇到空 div 显示行高的问题。看看这个!

关于css - 我如何在CSS中制作具有背景的灵活div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9578181/

相关文章:

javascript - 电子纸的图像映射

html - 如何使列表项与父 div 的高度相同?

javascript - 关于图像大小调整(视口(viewport))的几个问题

css - 使用 CSS 隐藏除第一个字母以外的所有文本?

html - 使用 Font Awesome 图标作为 CSS 内容

javascript - 矩阵图 : unable to style rotated column names

css - 是否有一种简短的方法来列出带有供应商前缀的 CSS3 关键帧?

html - 背景大小无法正常工作

css - Bootstrap 3 多级菜单

javascript - 在网站的所有页面中保留用户选择的背景