Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does semi-transparent CSS properties mean in Google Chrome Dev Tools?

Please see the following picture:

enter image description here

Why is padding-top and margin-top fully opaque, but padding-right etc. not?

like image 505
Randomblue Avatar asked Nov 09 '11 22:11

Randomblue


People also ask

What is transparent in CSS?

Image Transparency with the CSS Opacity Property The opacity property takes values from 0.0 to 1.0 , with 1 being the default value for all elements. The lower the value, the more transparent. So if an element is given an opacity of 0 , it would be invisible.

What is CSS opacity?

The opacity CSS property sets the opacity of an element. Opacity is the degree to which content behind an element is hidden, and is the opposite of transparency.

Which element is used to represent the transparency of an element in CSS?

The opacity property specifies the opacity/transparency of an element.

How do you make text transparent in CSS?

To set the opacity of a background, image, text, or other element, you can use the CSS opacity property. Values for this property range from 0 to 1. If you set the property to 0, the styled element will be completely transparent (ie. invisible).


1 Answers

I believe they are semi-transparent because they're not explicitly defined.

Consired following sheet:

selector1 {
    margin: 20px;
}

selector2 {
    margin: 20px;
    margin-top: 10px;
}

selector3 {
    margin: 10px 20px 30px;
}

In first example (selector1) all margin-* properties will be semi-transparent because non is explicitly defined - shortcut is being used.

In second example (selector2) only margin-top will be fully opaque, as it's defined in its own property.

In last example (selector3), margin-top and margin-bottom are defined explicitly, therefore the will be fully opaque. However margin-left and margin-right are defined by a single value, so they will be semi-transparent.


Semi-transparent color is also applied to default values, for instance:

background: red url(...) no-repeat;

This property defined background-color, background-image and background-repeat explicitly, however background-position, background-clip, background-size etc. are not defined (default values are used) so they will be seen as semi-transparent.

like image 97
Crozin Avatar answered Sep 28 '22 01:09

Crozin