在chrome浏览器中将svg图像调整为背景

PRA*_*RAH 11 css html5 svg google-chrome css3

我使用svg图像作为背景,我通过背景大小拉伸SVG图像.我希望它只是宽度明智的拉伸.它在firefox,IE9 +但Chrome中工作得非常好.请建议我如何实现它.

.homecallouts ul li {
background-image: url('blue_arow_callout.svg');
background-size: 100% 100%;
width: 21%;
height: 42px;
Run Code Online (Sandbox Code Playgroud)

请参阅jsbin代码 http://jsbin.com/uvijuc/4/

当我在firefox中调整大小只有宽度拉伸但在chrome中宽度和高度都拉伸.我只希望宽度伸展.

Ily*_*syn 20

也许添加preserveAspectRatio ="none"来打开SVG文件中的标签可能会有所帮助?

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="282.05px" height="61.974px" viewBox="286.287 26.514 282.05 61.974" enable-background="new 286.287 26.514 282.05 61.974"
     xml:space="preserve" preserveAspectRatio="none">
<polygon fill="#0063AF" points="538.337,26.514 286.287,26.514 316.287,57.5 286.287,88.488 538.337,88.488 568.337,57.5 "/>
</svg>
Run Code Online (Sandbox Code Playgroud)

JSBin的例子


Bar*_*eod 6

我没有足够的声誉进行投票或评论,所以只有再次回答它才会有效.我通过添加preserveAspectRatio ="none"解决了类似的情况.

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="591.42859"
height="250.24918"
id="svg2"
version="1.1"
preserveAspectRatio="none"
inkscape:version="0.48.2 r9819"
sodipodi:docname="background.svg">
Run Code Online (Sandbox Code Playgroud)


dez*_*man 0

我认为从技术上讲,chrome 在这方面是正确的,您需要将背景大小值调整为您实际想要的值。将它们保持在 100% 会迫使纵横比保持恒定。