Preface
.testDiv { width:400px; height:400px; border:1px solid #f00; /* How to write IE filters; gradientType : 1 represents horizontal direction, 0 represents vertical linear gradient; startColorstr is the starting color, endColorstr is the ending color; Colors support hexadecimal notation or English words. Of course, transparency is also supported [hexadecimal] #AAFF0000 [AA is transparency (00 is completely transparent, FF is completely opaque)], the last six digits are the standard hexadecimal color writing; */ /*IE6~7*/ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ccff7700", endColorstr="#eeccc222", GradientType=1); /*IE8*/ -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ccff7700", endColorstr="#eeccc222", GradientType=1); }
This article mainly introduces the native implementation of gradient effects under CSS3!!! [Mainstream browsers and mobile browsers can be used arbitrarily] CSS3 linear gradient compatibility Standard syntax (contains two parameters, the first parameter can be an angle or English direction , the second is the gradient start, multiple color values are allowed!)
### Gradient angle (deg is the abbreviation of degree, which means angle)
Rendering Code <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style type="text/css" media="screen"> div { width: 200px; height: 200px; border: 1px solid #ccc; box-sizing: border-box; text-align: center; line-height: 200px; float: left; margin: 10px; } /* My class names here are abbreviations: u :up, d: down, l:left, r:right, b:bottom, 2: to; Positive angles are clockwise, negative ones are counterclockwise; the angle represents when it reaches a certain angle and starts to spread to other ranges; I was also confused when I first started, but I learned it after writing more. As of the time I wrote this article, the gradient standard specifications are more complete, and many of them do not require prefixes; In order to take into account the mobile terminal, webkit cannot be discarded */ .u2d { background: -webkit-linear-gradient(180deg, #590BCC, #18CC6C); background: linear-gradient(180deg, #590BCC, #18CC6C); } .d2u { background: -webkit-linear-gradient(0deg, #590BCC, #18CC6C); background: linear-gradient(0deg, #590BCC, #18CC6C); } .l2r { background: -webkit-linear-gradient(90deg, #590BCC, #18CC6C); background: linear-gradient(90deg, #590BCC, #18CC6C); } .r2l { background: -webkit-linear-gradient(-90deg, #590BCC, #18CC6C); background: linear-gradient(-90deg, #590BCC, #18CC6C); } .rb2lu { background: -webkit-linear-gradient(-45deg, #590BCC, #18CC6C); background: linear-gradient(-45deg, #590BCC, #18CC6C); } .lb2ru { background: -webkit-linear-gradient(45deg, #590BCC, #18CC6C); background: linear-gradient(45deg, #590BCC, #18CC6C); } .ru2lb { background: -webkit-linear-gradient(-135deg, #590BCC, #18CC6C); background: linear-gradient(-135deg, #590BCC, #18CC6C); } .lu2rd { background: -webkit-linear-gradient(135deg, #590BCC, #18CC6C); background: linear-gradient(135deg, #590BCC, #18CC6C); } .mclg1 { background: -webkit-linear-gradient(135deg, #D6C4F0, #F6B5B5, #18CC6C, #1AB25E); background: linear-gradient(135deg, #D6C4F0, #F6B5B5, #18CC6C, #1AB25E); } .mclg2 { background: -webkit-linear-gradient(135deg, #1FB4DC ,#18CC6C , #8B1A1A,#677C67,#BED128); background: linear-gradient(135deg, #1FB4DC ,#18CC6C , #8B1A1A,#677C67,#BED128); } .mclg3 { background: webkit-linear-gradient(135deg, #590BCC, #18CC6C, #B5D821, #22CB33, #BA8787, #050201); background: linear-gradient(135deg, #590BCC, #18CC6C, #B5D821, #22CB33, #BA8787, #050201); } .mclg4 { background: -webkit-linear-gradient(-135deg, rgba(20,20,20,.9) ,rgba(50,50,50,.6),rgba(60,125,70,.7), rgba(150,150,150,.8),rgba(200,200,200,.9),rgba(80,125,6,.75),rgba(175,75,75,.5)); background: linear-gradient(-135deg, rgba(20,20,20,.9) ,rgba(50,50,50,.6),rgba(60,125,70,.7), rgba(150,150,150,.8),rgba(200,200,200,.9),rgba(80,125,6,.75),rgba(175,75,75,.5)); } </style> </head> <body> <div class="u2d">Top-down</div> <div class="d2u">Bottom-up</div> <div class="l2r">From left to right</div> <div class="r2l">From right to left</div> <div class="rb2lu">Lower right corner to upper left corner</div> <div class="lb2ru">Lower left to upper right</div> <div class="ru2lb">Upper right corner to lower left corner</div> <div class="lu2rd">Upper left corner to lower right corner</div> <div class="mclg1">Four color gradients</div> <div class="mclg2">Five color gradients</div> <div class="mclg3">Six color gradients</div> <div class="mclg4">Color with transparent gradient</div> </body> </html> Summarize With the emergence of CSS3, linear gradients no longer need to rely solely on PS to be realized... front-end partners can also create all kinds of cool gradient effects by themselves!!! Hahahahaha~~~ This is the end of this article about the detailed example code of how to implement linear gradient in CSS3. For more relevant CSS3 linear gradient content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: Introduction to JavaScript built-in objects
>>: Use DIV mask to solve the problem that directly checking the checkbox with the mouse is invalid
This article mainly introduces the sample code of...
Ubuntu is a free and open source desktop PC opera...
In MySQL operation and maintenance, a R&D col...
Related reading: MySQL8.0.20 installation tutoria...
1. Install components yum install epel-rpm-macros...
MySql is a data source we use frequently. It is v...
What is element-ui element-ui is a desktop compon...
If the server's images are hotlinked by other...
Add monitoring host Host 192.168.179.104 is added...
Regular expressions are often used to search and ...
Table of contents Update the image from an existi...
In many cases, you need to process the background...
We often encounter this problem: how to use CSS t...
1. Environment and preparation 1. Ubuntu 14.04 2....
Preface: Fully encapsulating a functional module ...