简体   繁体   English

CSS SVG背景-周围有奇怪的透明线

[英]css SVG background - strange transparent line around

I have tried to use svg image as background-image in css. 我试图将svg图像用作CSS中的背景图像。 And I have faced with strange behavior. 而且我遇到了奇怪的行为。 Element that has svg background has strange transparent line around. 具有svg背景的元素周围有奇怪的透明线。

In the example below it is shown as line between the first and the second div. 在下面的示例中,它显示为第一和第二div之间的线。 Size of the line changes depending on width of the element. 线的大小根据元素的宽度而变化。

http://jsfiddle.net/mahnunchik/g1ux4e7o/ http://jsfiddle.net/mahnunchik/g1ux4e7o/

Screenshot from jsfiddle: jsfiddle的屏幕截图:

在此处输入图片说明

It reproduces at least in Chrome 37 and FF 32 on Windows and Linux 它至少可以在Windows和Linux上的Chrome 37和FF 32中重现

Svg image is quite simple: SVG图像非常简单:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 76" enable-background="new 0 0 1920 76">
  <path fill="#DE4943" d="M0 76L1921 0 0 0z"/>
</svg>

Any idea how to fix that? 任何想法如何解决? Or how to explain that? 或如何解释?

Try adding preserveAspectRatio="none" to your <svg> element. 尝试在<svg>元素中添加preserveAspectRatio="none"

Also you don't need the enable-background attribute. 另外,您不需要enable-background属性。

尝试将stroke-width =“ 0”添加到路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM