CSS3 Gradients gradient effect
CSS3 Gradients is a new function used to design gradient effects . In traditional web design, if you want to design a gradient background color or a block with a gradient color, you need to deal with it through the design of the picture, but it is With the development of CSS3, such traditional design thinking has changed. CSS3 has introduced a function called Gradients, which can design different gradient effects. Only through Gradients adjustments, such as gradient direction and color presented by gradients , Gradient rendering shape, you can easily make the browser produce the gradient effect itself, which can be applied to the background gradient effect of the web page itself or the gradient visual effect outside the area. The advantage is that you don’t need to design the gradient image first. , Reduce the waste of bandwidth, and the effect of gradual enlargement is better than the traditional picture-based gradation, because the gradient is automatically generated by the browser, the advantages are of course not to mention.
CSS3 Gradients currently has two gradient effects, namely Linear Gradients and Radial Gradients. The settings of the two are not the same, and the actual visual effects are of course different. This article Will provide their practical examples in order for readers and friends for reference.
Browser support for CSS3 Gradients
- Support for IE 10.0 and above.
- Google Chrome 26.0 and above are supported.
- FireFox 16.0 and above are supported.
- Apple Safari 6.1 and above are supported.
- Opera 12.1 and above are supported.
Browser applicable prefix
- Google Chrome and Apple Safari use -webkit-
- Mozilla FireFox uses -moz-
- Opera uses -o-
radial gradient syntax: background: radial-gradient(ellipse or circle, color 1, color 2,. .....);
CSS3 Gradients Linear Gradients effect example
Gradients can set the direction of the linear gradient, the default value is from top to bottom, and also allows web designers to set it to be from left to right, from right to left or even diagonal Linear expression, respectively express the following example grammar.
Linear gradient effect from top to bottom (default value)
#T2B{
width:200px;
height:150px;
background: -webkit-linear-gradient(yellow,red);
background: -o-linear-gradient(yellow,red);
background : -moz-linear-gradient(yellow,red);
background: linear-gradient(yellow,red);
}
</style>
<div id="T2B"></div>
Linear gradient effect from left to right
#L2R{
width:200px;
height:150px;
background: -webkit-linear-gradient(left,yellow,red);
background: -o-linear-gradient(right,yellow, red);
background: -moz-linear-gradient(right,yellow,red);
background: linear-gradient(to right,yellow,red);
}
</style>
<div id="L2R"></div>
Diagonal linear gradient effect ( from bottom left to top right )
#B2R{
width:200px;
height:150px;
background: -webkit-linear-gradient(left top,yellow,red);
background: -o-linear-gradient(bottom right, yellow,red);
background: -moz-linear-gradient(bottom right,yellow,red);
background: linear-gradient(to bottom right,yellow,red);
}
</style>
<div id="B2R"> </div>
Linear gradient effect using angle adjustment
#UA{
width:200px;
height:150px;
background: -webkit-linear-gradient(90deg,yellow,red);
background: -o-linear-gradient(90deg,yellow, red);
background: -moz-linear-gradient(90deg,yellow,red);
background: linear-gradient(90deg,yellow,red);
}
</style>
<div id="UA"></div>
CSS3 Gradients Radial Gradients effect example
#ellipse{
width:200px;
height:100px;
background: -webkit-radial-gradient(ellipse,white,orange);
background: -o-radial-gradient(ellipse,white, orange);
background: -moz-radial-gradient(ellipse,white,orange);
background: radial-gradient(ellipse,white,orange);
}
#circle{
width:200px;
height:100px;
background: -webkit-radial -gradient(circle,white,orange);
background: -o-radial-gradient(circle,white,orange);
background: -moz-radial-gradient(circle,white,orange);
background: radial-gradient(circle, white,orange);
}
</style>
<div id="ellipse">ellipse</div>
<div id="circle">circle</div>
Post a Comment
0 Comments