Can you overlay a transparent css3 gradient over a background image?

只谈情不闲聊 提交于 2019-11-29 22:18:08
Yoann

I have do this for one of my website, Hope it's work for you;

body {
	margin: 0;
	padding: 0;
	background: url('https://i.stack.imgur.com/MUsp6.jpg') repeat;
}

body:before {
	content: " ";
	width: 100%;
	height: 100%;
	position: absolute;
	z-index: -1;
	top: 0;
	left: 0;
	background: -webkit-radial-gradient(top center, ellipse cover, rgba(255,255,255,0.2) 0%,rgba(0,0,0,0.5) 100%);
}
Alan

The example from this answer won't work with resizeable divs.

Your code would work fine. But as I understand it, CSS reads from the right to the left. So you would have to use the following:

div {
    background: -webkit-radial-gradient(top center, ellipse cover, rgba(255,255,255,0.2) 0%,rgba(0,0,0,0.5) 100%), url('http://www.google.co.uk/logos/classicplus.png') repeat;
}

Example: http://sapphion.com/2011/11/css3-background-gradient-on-top-of-an-image/

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