在 CSS3 中,可以使用 linear-gradient()(线性渐变) 和 radial-gradient()(径向渐变) 来实现渐变背景。下面给你常见用法和示例。
background: linear-gradient(direction, color1, color2, ...);
background: linear-gradient(red, blue);
background: linear-gradient(to right, red, blue);
background: linear-gradient(to bottom right, red, yellow, blue);
background: linear-gradient(45deg, red, blue);
background: linear-gradient(to right, red 0%, green 50%, blue 100%);
background: radial-gradient(shape size at position, color1, color2);
background: radial-gradient(circle, red, yellow, blue);
background: radial-gradient(circle at center, red, blue);
background: radial-gradient(circle at top left, red, blue);
background: radial-gradient(ellipse, red, blue);
background: repeating-linear-gradient(
45deg,
red 0px,
red 10px,
blue 10px,
blue 20px
);
background: repeating-radial-gradient(
circle,
red 0px,
red 10px,
blue 10px,
blue 20px
);
.box {
width: 300px;
height: 200px;
background: linear-gradient(135deg, #ff7e5f, #feb47b);
}
HTML:
<div class="box"></div>
background: -webkit-linear-gradient(top, red, blue);
background: -moz-linear-gradient(top, red, blue);
background: linear-gradient(to bottom, red, blue);
如果你需要 某个具体效果(如渐变按钮、动画渐变、微信小程序渐变),可以告诉我,我可以直接给你写完整代码。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。