2017-04-15 139 views
2

我的代碼 - Fiddle如何清除鋸齒?

body{ 
 
    background: url('http://i.imgur.com/RECDV24.jpg'); 
 
    background-size: cover; 
 
} 
 
div{ 
 
    width: 150px; 
 
    height: 150px; 
 
    background-image: radial-gradient(circle at 0 0, transparent 28px, tomato 28px); 
 
}
<div></div>

如何去除鋸齒現象?

enter image description here

謝謝你,我會很樂意幫助!

+0

IMG { 圖像的繪製:optimizeSpeed;/* STOP SMOOTHING,GATE ME SPEED */ image-rendering:-moz-crisp-edges;/* Firefox */ 圖像渲染:-o-crisp-edges;/* Opera */ 圖像渲染:-webkit-optimize-contrast;/* Chrome(以及最終的Safari)*/ image-rendering:pixelated;/* Chrome */ 圖像渲染:優化對比度;/* CSS3建議*/ -ms-interpolation-mode:nearest-neighbor;/* IE8 + */ } –

+0

@RïshïKêshKümar'crispEdges'用於SVG,但可能會打敗提問者試圖做的事情。對於其他屬性也是如此。 – Rob

回答

4

取具有大box-shadow一種不同的方法的圓形元件上:

body { 
 
    background: url('https://i.imgur.com/RECDV24.jpg'); 
 
    background-size: cover; 
 
} 
 

 
.bitten { 
 
    height: 150px; 
 
    overflow: hidden; 
 
    position: relative; 
 
    width: 150px; 
 
} 
 

 
.bitten::before { 
 
    border-bottom-right-radius: 100%; 
 
    box-shadow: 0 0 0 1000px tomato; 
 
    content: ''; 
 
    height: 28px; 
 
    position: absolute; 
 
    width: 28px; 
 
    z-index: -1; 
 
}
<div class="bitten"></div>

+0

謝謝,它的工作原理 – Dmitriy

0

在某些瀏覽器中,您可以通過避免銳利邊緣漸變來防止鋸齒。因此,不是transparent 28px, tomato 28px,而是讓顏色之間的轉換更平滑一些,比如說1px。

body{ 
 
    background: url('https://i.imgur.com/RECDV24.jpg'); 
 
    background-size: cover; 
 
} 
 
div{ 
 
    width: 150px; 
 
    height: 150px; 
 
    background-image: radial-gradient(circle at 0 0, rgba(255,99,71,0) 28px, rgba(255,99,71,255) 30px); 
 
}
<div></div>

但是,這並不工作無處不在。要獲得更堅實的方法,請參閱其他答案。

+3

鉻以某種方式設法使這看起來參差不齊,無論有多少像素在兩個... – Ryan

+1

嗯,我不知道爲什麼我總是認爲鉻和我自己的瀏覽器一樣好。謝謝你的提醒! –

+0

是的,我真的希望它能夠工作,現在我必須重寫一些使用這種方法的頁面:([放大的Chrome以6px爲單位](https://i.stack.imgur。 com/vxcP4.png) – Ryan