H1 标题的背景图像

gal*_*exy 2 html css background-image

在我的 wordpress 主题页面标题中<?php the_title(); ?>

我的CSS:

#page h1.pagetitle {
      width:auto;
      text-align:left;
      font-size:30px;
      padding:25px 40px 25px 0px;
      text-transform:uppercase;
    }

     #page h1.pagetitle span{
     background:#202020; 
     padding:5px 40px 5px 10px;
     }
Run Code Online (Sandbox Code Playgroud)

网址:

<h1 class="pagetitle"><span><?php the_title(); ?></span></h1> 
Run Code Online (Sandbox Code Playgroud)

我想要像这个示例的箭头丝带背景图像http://www.123rf.com/photo_12816420_green-arrow-ribbon-on-wooden-desk.html

我可以直接放置背景图像或使用带有重复 x 的背景图像。但我的页面标题文本跨度宽度始终不固定。每个页面都有不同的页面标题。

所以我想使用两个图像部分:一个在文本后面使用repeat-x 的矩形和:第二个在文本字符串末尾后带有箭头(三角形)。

这样我就可以获得任何页面标题文本的箭头图像。建议我如何得到这个?

xpy*_*xpy 5

我经常使用这种技术:

h1{
    background: url('http://i49.tinypic.com/2zs1z79.png') 0 0 repeat-x;
    position:relative;
    display: inline-block;
    margin:0 25px;
    padding:0 10px;
    height:40px;
}

h1:before,h1:after {
    content:'';
    display: inline-block;
    position:absolute;
    top: 0;
    right: -20px;
    width: 20px;
    height: 100%;
    background:inherit;
    background-position:100% 100%;
}
h1:before {
    left:-20px;
    background-position: 0 100%;
}
Run Code Online (Sandbox Code Playgroud)

我使用:beforeand:after作为头部和尾部,并使用一个精灵作为图像。它很好,干净且灵活(足够)。

演示:http : //jsfiddle.net/pavloschris/5Qvn7/