背景色渐变

2021-06-01  本文已影响0人  HS_d119

1、从顶部开始的线性渐变。起点是红色,慢慢过渡到蓝色 Internet Explorer 9 及之前的版本不支持渐变

background: -webkit-linear-gradient(red, blue);
background: -o-linear-gradient(red, blue);
background: -moz-linear-gradient(red, blue);
background: linear-gradient(red, blue);

2、从左边开始的线性渐变。起点是红色,慢慢过渡到蓝色

background: -webkit-linear-gradient(left, red , blue);
background: -o-linear-gradient(right, red, blue);
background: -moz-linear-gradient(right, red, blue);
background: linear-gradient(to right, red , blue);

3、从左上角开始(到右下角)的线性渐变。起点是红色,慢慢过渡到蓝色

background: -webkit-linear-gradient(left top, red , blue);
background: -o-linear-gradient(bottom right, red, blue);
background: -moz-linear-gradient(bottom right, red, blue);
background: linear-gradient(to bottom right, red , blue);

4、角度渐变


#grad1 {
  height: 100px;
  background: -webkit-linear-gradient(0deg, red, blue); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(0deg, red, blue); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(0deg, red, blue); /* Firefox 3.6 - 15 */
  background: linear-gradient(0deg, red, blue); /* 标准的语法(必须放在最后)*/
}
#grad2 {
  height: 100px;
  background: -webkit-linear-gradient(90deg, red, blue); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(90deg, red, blue); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(90deg, red, blue); /* Firefox 3.6 - 15 */
  background: linear-gradient(90deg, red, blue); /* 标准的语法(必须放在最后) */
}
#grad3 {
  height: 100px;
  background: -webkit-linear-gradient(180deg, red, blue); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(180deg, red, blue); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(180deg, red, blue); /* Firefox 3.6 - 15 */
  background: linear-gradient(180deg, red, blue); /* 标准的语法(必须放在最后)*/
}
#grad4 {
  height: 100px;
  background: -webkit-linear-gradient(-90deg, red, blue); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(-90deg, red, blue); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(-90deg, red, blue); /* Firefox 3.6 - 15 */
  background: linear-gradient(-90deg, red, blue); /* 标准的语法(必须放在最后)*/
}
上一篇 下一篇

猜你喜欢

热点阅读