首页 > 其他 > 详细

线性渐变

时间:2020-09-26 09:13:06      阅读:41      评论:0      收藏:0      [点我收藏+]

DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>


.box1{
width: 300px;
height: 300px;
margin: 100px auto;

/*background-color: yellow;*/

/*
渐变背景不是背景颜色,而是图片
所以我们需要通过background-image
或 background 来设置渐变的效果

linear-gradient() 线性渐变
radial-gradient() 径向渐变
*/

background-image: linear-gradient(red, yellow);
background-image: linear-gradient(green, blue);
/*线性渐变默认是自上向下进行变化*/
background-image: linear-gradient(red, orange, yellow, greenyellow);
/*
可以关键字来指定渐变的方向:
to top 向上渐变
to right 向右渐变
to bottom 向下渐变
to left 向左渐变
*/
background-image: linear-gradient(to left top, red, orange, yellow, greenyellow);
background-image: linear-gradient(90deg, red, orange, yellow, greenyellow);
background-image: linear-gradient(red, orange, yellow, greenyellow);
/*
默认情况下,渐变的颜色在元素中是平均分布
*/
/*
可以在颜色后,指定颜色的范围 开始位置,结束位置,这种语法不支持老版本的浏览器
*/
/*background-image: linear-gradient(red 0px 150px, yellow 150px 300px);*/


/*
颜色后边可以指定一个长度,用来指定颜色的起始位置
*/
background-image: linear-gradient(red 100px, yellow 300px);
background-image: linear-gradient(red 20%, orange 40%, yellow 60%, greenyellow 80%);

background-image: repeating-linear-gradient(red 50px, yellow 100px , orange 200px);


background-image: linear-gradient(red 100px, yellow 300px);

/*background-position: 200px 100px;*/

background: linear-gradient(greenyellow, skyblue);


}

</style>
</head>
<body>

<div class="box1"></div>


</body>
</html>

线性渐变

原文:https://www.cnblogs.com/eric-share/p/13733169.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!