Set background image for font color?

后端 未结 5 906
半阙折子戏
半阙折子戏 2020-12-15 12:34

Say I have the following code:

Hello world!

And the following CSS:

span{
color:red;
}
5条回答
  •  [愿得一人]
    2020-12-15 13:15

    The technique of swapping out text for images is common for headers and page navigation, but there really aren't any pure CSS techniques that are cross-browser compatible (this is a nice technique, but isn't something you should rely on).

    If you have a finite amount of text that you want to apply the texture to, your best bet is to just replace the text with images manually, as such:

    HTML:

    Title

    CSS:

    h1.title { 
      background: url(images/title.gif) 0 0 no-repeat;
      width: 80px;
      height: 23px;
      text-indent: -10000px; }
    

提交回复
热议问题