css - 带有图像的阴影线作为 DIV 之间的垂直分隔符 - 如何放置顶部和底部图像?

标签 css

我希望在我的 DIV 之间有一条细的“阴影”线作为分隔符。因为我希望阴影线更细并且顶部和底部的不透明度更高,所以我创建了 3 个图像:中间阴影、顶部阴影和底部阴影。问题:我不知道如何将“顶部阴影”图像放置在“中间阴影”的顶部,将“底部”阴影放置在底部(没有多个 DIV)。我附上了一张在烟花中完成的图像,您可以在其中看到阴影线的示例。许多 tks enter image description here

div#content-center {
    overflow: hidden;
    background: khaki;
    background: transparent url('images/middle_shadow.png') repeat-y top left;
    padding: 0px 0px 0px 50px;
}

最佳答案

您也可以使用 :before:after 伪元素来执行此操作。 Read up on them here如果您不熟悉。

#content-center{
    background:  url('images/shadow_repeat.png') center right repeat-y;
}

#content-center:before,
#content-center:after{
    content:'';
    display:inline-block;
    position: absolute;
    background-repeat: none;

    /*size these to be what you need*/
    height:100px;
    width:100px;
}

#content-center:before{
    top:0;
    background-image: url('images/shadow_top.png');
}

#content-center:after{
    bottom:0;
    background-image:url('images/shadow_bottom.png');
}

关于css - 带有图像的阴影线作为 DIV 之间的垂直分隔符 - 如何放置顶部和底部图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15327518/

相关文章:

html - 如何自定义复选框以使其看起来与附加的图像相似?

css - 自定义 Zurb Orbit 插件

css - 停止读取 CSS

php - 指定由 PHP 文件调用的图像宽度和高度

jquery - 使用 Masonry 的响应式图片库

html - Bootstrap 3 - 与 pull-right 一起垂直对齐

html - 路由事件时应用样式(过滤器)

jquery 使用 anchor 更改固定元素文本颜色

css - 第一列的交替颜色

jquery - 如何制作响应式右导航栏图标?