Home >Web Front-end >HTML Tutorial >Sample code for html background color gradient effect implemented through CSS styles
You can easily implement background color gradient in html. Here is an example implemented through CSS. If you are interested, you can refer to it.
Screenshot of the effect:
Implementation code:
The code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title></title> <style type="text/css"> .linear{ width:100%; height:600px; FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=##15A216,endColorStr=#fafafa); /*IE*/ background:-moz-linear-gradient(top,#15A216,#fafafa);/*火狐*/ background:-webkit-gradient(linear, 0% 0%, 0% 100%,from(#15A216), to(#fafafa));/*谷歌*/ background-image: -webkit-gradient(linear,left bottom,left top,color-start(0, #15A216),color-stop(1, #fafafa));/* Safari & Chrome*/ filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#15A216', endColorstr='#fafafa'); /*IE6 & IE7*/ -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#15A216', endColorstr='#fafafa')"; /* IE8 */ } </style> </head> <body> <p class="linear"></p> </body> </html>
More achieved through CSS styles For related articles on HTML background color gradient effect sample code, please pay attention to the PHP Chinese website!