2016-12-02 167 views
0

我見過很多禁用圖像抗鋸齒的方法,但是如何將其應用於「背景圖像」?我有一個背景圖像的div,並且別名代碼不能使用它。有人不能幫忙嗎?HTML在背景圖像上禁用抗鋸齒

+0

所有權利。你有什麼到目前爲止已經試過? –

+0

@dreamhunter我試過這個:http://stackoverflow.com/questions/14068103/disable-antialising-when-scaling-images不起作用... – Legomite

回答

0

你試過image-rendering: pixelated;對你的背景圖片div的Class

如果沒有,你可以嘗試在CSS-Tricks

本教程這裏是夏日。 原始作者

.pixelated { 
 
     image-rendering: pixelated; 
 
} 
 

 
.resize { 
 
    width: 45%; 
 
    clear: none; 
 
    float: left; 
 
} 
 
.resize:last-of-type { 
 
    float: right; 
 
} 
 
.resize img { 
 
    width: 100%; 
 
} 
 

 
img { 
 
    margin-bottom: 20px; 
 
    max-width: 100%; 
 
} 
 

 
body { 
 
    background-color: #444; 
 
    color: #fff; 
 
    padding: 2em; 
 
}
<div class="original"> 
 
    <h1>Original image size</h1> 
 
    <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/14179/qrcode.png" alt="" /> 
 
</div> 
 
<div class="resize"> 
 
    <h2> 
 
    <code>image-rendering: auto;</code> 
 
    </h2> 
 
    <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/14179/qrcode.png" alt="" /> 
 
</div> 
 
<div class="resize"> 
 
    <h2> 
 
    <code>-rendering: pixelated;</code> 
 
    </h2> 
 
    <img class="pixelated" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/14179/qrcode.png" alt="" /> 
 
</div>

+0

我已經試過了,加上這些方法http:// stackoverflow.com/questions/14068103/disable-antialising-when-scaling-images但它不適用於背景圖像 – Legomite