是否可以在使用 CSS 的网页上为文本使用图像 Sprite ?
<html>
<head>
<style>
p { background-image: url('font.gif') }
p 'character' { width: 4px; height: 5px }
p 'a' { background-position: 0 0 }
p 'b' { background-position: -6px 0 }
p 'c' { background-position: -10px 0 }
etc...
</style>
</head>
<body>
<p>This is some test text. It doesn't mean anything.</p>
</body>
</html>
最佳答案
我不确定您为什么要以这种方式将图形用于文本,但请尝试使用此代码。
<html>
<head>
<style>
p { background-image: url('font.gif');width: 4px; height:5px;display:inline-block;}
p .A { background-position: 0 0 }
p .B { background-position: -6px 0 }
p .C { background-position: -10px 0 }
</style>
</head>
<body>
<p class="C"></p><p class="A"></p><p class="B"></p>
</body>
</html>
关于html - 使用图像 Sprite 和 CSS 的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31554905/