0

尝试使用:before跨度在主要内容的边缘添加背景图像。

基本上应该是这样的:

在此处输入图像描述

我将三角形作为背景图像,但似乎无法使其正确放置或根本无法显示。

见 JS 小提琴:

http://jsfiddle.net/Y6rMs/1/

4

3 回答 3

2

如果你愿意,你可以在没有图像的情况下做到这一点

http://jsfiddle.net/Y6rMs/26/

#bottomWide span.ribbon:before {
    content: "";
    width: 0; 
    height: 0; 
    position: absolute;
        top:0;
        left: -40px;
    border-top: 20px solid transparent; 
    border-right: 40px solid #0099ff; 
    border-bottom: 20px solid transparent;
}

这是您可以使用 css 创建的其他一些形状的列表 http://css-tricks.com/examples/ShapesOfCSS/

于 2013-04-12T16:26:19.980 回答
0

这里是
jsfiddle.net/trajce/Y6rMs/27/

#bottomWide span.ribbon{
    position:relative;
    background-color:#C1C976;
    padding:5px 2%;
    float:right; 
}
#bottomWide span.ribbon:before{
    content:'';
    height:38px;
    width:25px;
    background-image:url(http://i.imgur.com/7nrYgTn.png);
    background-position:center left; <-
    background-repeat:no-repeat;
    position:absolute; 
    top:0;
    left:-30px; <- just play with this values a bit
    height:40px; <-
    width:30px; <-
}
于 2013-04-12T16:27:41.093 回答
0

I got it to show up here, I think you can get the rest... I added display: block; and removed your background-position rule.

于 2013-04-12T16:22:27.460 回答