How to prevent the background image from getting blurry

痞子三分冷 提交于 2019-11-27 16:55:56

问题


I need to know how to get the background image to not be blurry when text is over it in CSS as it spoils the look of my website if it's blurry.

My CSS is:

background: #ff0000 url(img/rain.jpg) top center repeat-y; 
background-size: 100%; 

But when I load it up where there is text that line goes blurry and I don't want it to so how do I do this?

Fiddle example


回答1:


Try to add:

image-rendering: -webkit-optimize-contrast;




回答2:


Try adding this to the code: image-rendering: pixelated; For me it worked perfectly. you can also try - image-rendering: -webkit-optimize-contrast;




回答3:


use of background-size: cover;background-position:50% 50%; will help you..

* {
font-family: Calibri, Comic Sans MS, Serif;
background: #ff0000 url(http://www.coolguysite.co.uk/blog/templates/default/img/rain.jpg)   top center repeat-y;
background-size: cover;
background-position:50% 50%;
}

UPDATED FIDDLE




回答4:


I got it by doing:

background: transparent;

to the h2 and p elements.




回答5:


Here's the cross browser technique:

 image-rendering: crisp-edges;
 image-rendering: -moz-crisp-edges;          /* Firefox */
 image-rendering: -o-crisp-edges;            /* Opera */
 image-rendering: -webkit-optimize-contrast; /* Webkit (non-standard naming)*/
 -ms-interpolation-mode: nearest-neighbor;   /* IE (non-standard property) */



回答6:


You can use image-rendering: pixelated. Here is an example from the Mozilla Developer Network:

.pixelated {
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
}

https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering

https://jsfiddle.net/9dtj2wkq/



来源:https://stackoverflow.com/questions/18677983/how-to-prevent-the-background-image-from-getting-blurry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!