从指南针v0.12开始,可能会重复部分精灵,但重复仅适用于x轴。
由于报价泡泡的中间部分只是一个扁平的颜色,因此您可以使用CSS对其进行设计,并将现有的精灵用于报价泡泡的顶部和底部。
有很多方法可以使用纯css3来做到这一点,但是如果您想使用图像在旧版本的IE中使用此工作,则可以在单个html元素的伪元素之前和之后使用。
尝试......
使用此文件结构:
images/
tooltip/
top.png
bottom.png
tooltip-sfc34d436c9.png <-- Sass will create this file.
sass/
sprite.sass
sprite.html
stylesheets/
sprite.css
而且sprite.html
包含此:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link href="stylesheets/sprite.css" rel="stylesheet" />
</head>
<body>
<div class="tooltip">
To be, or not to be, that is the question.
</div>
</body>
</html>
而且sprite.sass
包含此:
// Sprite setup
$tooltip-sprite-dimensions: true
@import "tooltip/*.png"
// Tooltip styles
$tooltip-top-image: "tooltip/top.png"
$tooltip-top-width: image-width($tooltip-top-image)
$tooltip-top-height: image-height($tooltip-top-image)
$tooltip-bottom-image: "tooltip/bottom.png"
$tooltip-bottom-width: image-width($tooltip-bottom-image)
$tooltip-bottom-height: image-height($tooltip-bottom-image)
$tooltip-width: $tooltip-top-width
$tooltip-h-padding: 10px
.tooltip
position: relative
width: $tooltip-width - ($tooltip-h-padding * 2)
background: #8aa5bb
padding: $tooltip-top-height $tooltip-h-padding $tooltip-bottom-height
&:before
content: ""
position: absolute
top: 0
left: 0
+tooltip-sprite(top)
&:after
content: ""
position: absolute
bottom: 0
left: ($tooltip-width - $tooltip-bottom-width)/2
+tooltip-sprite(bottom)
而sprite.css
编译这个sprite.css
:
.tooltip-sprite, .tooltip:before, .tooltip:after {
background: url('../images/tooltip-sfc34d436c9.png') no-repeat;
}
.tooltip {
position: relative;
width: 232px;
background: #8aa5bb;
padding: 15px 10px 13px;
}
.tooltip:before {
content: "";
position: absolute;
top: 0;
left: 0;
background-position: 0 -13px;
height: 15px;
width: 252px;
}
.tooltip:after {
content: "";
position: absolute;
bottom: 0;
left: -3px;
background-position: 0 0;
height: 13px;
width: 258px;
}
完成的提示将是这样的:
只有A CSS的解决方案:HTTP:// CSS-技巧。com/examples/ShapesOfCSS /#talkbubble – feeela
感谢您的css-only链接:) 但我真的很想使用精灵的东西,因为IE支持 – M00ly