Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use css to realize multiple color gradients

Shulou Source: shulou.com Published: 2022-06-02 01:06:15 10月01日 Update

This article "how to use css to achieve multiple color gradients" article, the article sample code is very detailed, with a certain reference value, interested friends must refer to, for "how to use css to achieve multiple color gradients", Xiaobian sorted out the following knowledge points, please follow the pace of Xiaobian step by step slowly understand, then let us enter the topic.

I created common buttons in HTML and provided them with common and specific class names as well as styles to decorate the buttons.

HTML

Button1

Button2

Button3

Button4

Button5

CSS

.button {

Float:left

Height:40px

Line-height:40px

Margin-right:20px

Padding:015px

Color:#fff

Font-weight:bold

Font-size:16px

Font-family:arial

Background-color:#555

Border-radius:5px;border:solid1pxrgba (0. 0. 5)

}

Give each button a unique color (regular background color).

CSS

.button1 {background-color:orange;}

.button2 {background-color:red;}

.button3 {background-color:green;}

.button4 {background-color:RoyalBlue;}

.button5 {background-color:OrangeRed;}

Now, it's easy to make all these gradients. Instead of using full-color gradients, such as red and crimson, I use a gradient with a black background color with an opacity of 0% until the black background color has an opacity of 65%.

Then add this gradient to the transparency of the common button class.

CSS

.button {

Background-image:linear-gradient (rgba (0re0penol 0) 0) 0% recorder rgba (0pc0penol 0.65) 100%)

}

Well, now we've finished using only one gradient in CSS to make multiple gradients.

Complete code:

.button {

Float:left

Height:40px

Line-height:40px

Margin-right:20px

Padding:015px

Color:#fff

Font-weight:bold

Font-size:16px

Font-family:arial

Background-color:#555

Border-radius:5px

Border:solid1pxrgba (0. 0. 5)

Background-image:linear-gradient (rgba 0) 0) 0% W3C*/)

}

.button1 {background-color:orange;}

.button2 {background-color:red;}

.button3 {background-color:green;}

.button4 {background-color:RoyalBlue;}

.button5 {background-color:OrangeRed;}

Button1

Button2

Button3

Button4

Button5

What is the full name of css? the full name of css is Cascading Style Sheets (cascading style sheets), a computer language used to express file styles such as HTML or XML. CSS can not only modify the web page statically, but also format the elements of the web page dynamically with various scripting languages.

The above is all the content of the article "how to use css to achieve multiple color gradients". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Color multiple buttons common style background transparency code full name content knowledge class name red web page language black reference unique next theme Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Apple Shulou Technology Shulou Tech Info Shulou Information