z-index, opacity, visibility
-
z-index
: Thez-index
property in CSS3 specifies the stack order of an element. Elements with a higherz-index
value will appear in front of elements with a lowerz-index
value. By default, elements have az-index
value of "auto", which means they will be stacked in the order they appear in the document. -
opacity
: Theopacity
property in CSS3 sets the transparency level of an element. The value can range from 0 (fully transparent) to 1 (fully opaque). This property is useful for creating partially transparent elements or making elements appear or disappear gradually. -
visibility
: Thevisibility
property in CSS3 sets whether or not an element is visible. The values for thevisibility
property can be eithervisible
orhidden
. If an element has avisibility
value ofhidden
, it will not be displayed on the page, but it will still take up space in the layout.
These properties allow you to control the appearance and stacking of elements on a web page, and can be used to create a wide range of visual effects. For example, you can use z-index
and opacity
together to create overlapping elements with varying levels of transparency. You can also use visibility
to show or hide elements dynamically based on user interaction or other conditions.
Z-Index
'z-index' specify the stack of element, which element should be display on top . maximum value is display at top of all elemens. It works with property 'position' absolute,relative, fixed or sticky.
p{
z-index: 9999; /* Bring in front of all elements which have lower z-index */
}
div{
z-index: -100; /* send back to all elements which have Higher z-index */
}
Opacity
Change the opacity of any html element. It make the html element transparent.
p{
opacity: 80%;
opacity: 0.6;
}
Visibility
visibility is used to hide the html element.
p{
visibility: hidden;
visibility: visible;
}