简体   繁体   English

在Safari中禁用平铺背景平滑

[英]Disable tiled background smoothing in Safari

Is there a way to disable background smoothing in Safari? 有没有办法在Safari中禁用背景平滑? I'm trying to make, for example, the tiled background like this: 例如,我正在尝试像这样平铺背景:

 div#dashed { width: 10rem; height: 7rem; border: 1px solid #000; background: url("https://tut.etogo.net/_files/diagonalbg.png"); } 
 <div id="dashed"> 

So, the background is like that: 因此,背景是这样的: 对角破折号

And I expect the background to look like that (zoomed): 我希望背景看起来像这样(缩放): 平铺的背景

But in Safari it looks like that: 但是在Safari中看起来像这样: 在此处输入图片说明 Zoomed: 放大: 在此处输入图片说明

So, I see Safari does some antialiasing/smoothing on the edges - is there a way to disable it? 因此,我看到Safari在边缘进行了抗锯齿/平滑处理-是否可以禁用它? I tried different "image-rendering" parameters but with no success. 我尝试了不同的“图像渲染”参数,但没有成功。 Tried that in IE, Edge, FF, Chrome and Opera - everything renders fine, but not in Safari. 在IE,Edge,FF,Chrome和Opera中进行了尝试-一切都可以正常显示,但在Safari中却不能。 maybe there's some css for that? 也许有一些CSS吗?

I think this is because your background was repeat. 我认为这是因为您的背景是重复的。 You can try it background-size:cover; background-repeat: no-repeat; 您可以尝试使用background-size:cover; background-repeat: no-repeat; background-size:cover; background-repeat: no-repeat;

Setting size for your background-image. 设置背景图像的大小。

As an alternative to using an image, you can achieve the same effect with pure CSS. 作为使用图像的替代方法,您可以使用纯CSS达到相同的效果。

 .gradient { width: 200px; height: 200px; background: repeating-linear-gradient(-45deg, #000, #fff 1px, #fff 15px); } 
 <div class="gradient"></div> 

You might want to fiddle around to reach the desired outcome. 您可能需要四处逛逛以达到所需的结果。

A bit more info, and tips can be found on https://css-tricks.com/stripes-css/ 有关更多信息,请参见https://css-tricks.com/stripes-css/

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

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