Home >Web Front-end >HTML Tutorial >div css background gradient color code example
Use CSS to make the DIV background color gradient, suitable for browsers such as IE and Chrome.
Code:
<style type="text/css"> .jbkeleyi{ height: 300px; width:100px; margin:0px auto; background-image: -moz-linear-gradient(top, #F00, #000); background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #00FF00), color-stop(1,#FF0000)); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00FF00', endColorstr='#FF0000', GradientType='0'); } </style> </head> <body> 用CSS是p颜色渐变:<br /> <p class="jbkeleyi">从绿到红<br /><br />keleyi.com</p>
Rendering:
In addition, multi-browser compatible code:
FILTER: progid:DXImageTransform.Microsoft. Gradient(gradientType=0,startColorStr=#b8c4cb,endColorStr=#f6f6f8); /*IE*/
background:-moz-linear-gradient(top,#b8c4cb,#f6f6f8);/*Firefox* /
background:-webkit-gradient(linear, 0% 0%, 0% 100%, from(#b8c4cb), to(#f6f6f8));/*Google*/
Related articles:
HTML5 Canvas: Draw gradient color
css gradient color omitted Detailed introduction to mark embedded font text shadow