What is the difference between opacity and Rgba in CSS?

Source: Internet
Author: User

This article shares with you the main isCsstwo properties related to transparency inOpacityand theRgba, mainly around these two CSSattribute differences and considerations, I hope youLearningCSS has helped. Grammar 1. Rgbafirst it is a property value, and the syntax isRgba(R,g,b,a) -Ris a red value, a positive integer| percentage -Gis a green value, a positive integer| percentage -BIs a blue value, a positive integer| percentage -Ato beAlpha(transparency), a value of0 ~ 1between the decimals,0.0(fully transparent) to1.0(completely opaque) -the positive integer above is the decimal0 ~ 255a percentage of any value between0% ~ 100%any value between the //Example:. box1{ //not limited to background color, can be text color, shadow, etc. background: Rgba (0,0,255,0.4); } 2. Opacity Opacityis a property, not a property value, and the syntax is: Opacity: Value|inherit; Valueopacity, from0.0(fully transparent) to1.0(completely opaque) //Example. box2{ background: rgb (0,0,255); Opacity: 0.4; } the Difference ·have aOpacityall descendant elements of a property are inheritedOpacityProperties, andRGBAdescendant elements do not inherit opaque properties ·look at the effect below: //part of the code. box1{ background: Rgba (0,0,255,0.4); }.box2{ background: rgb (0,0,255); Opacity: 0.4; }
It's not hard to see -RgbaIt 's just a background color with a transparent effect . -and thereOpacityThe descendants of a property element inherit this transparent property, including, but not limited to, text images, etc.Source: Network

What is the difference between opacity and Rgba in CSS?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.