Home > Web Front-end > CSS Tutorial > How to set layer on top in css

How to set layer on top in css

醉折花枝作酒筹
Release: 2023-01-06 11:15:15
Original
16920 people have browsed it

In CSS, you can use the "z-index" attribute to set the layer on top. You only need to set the "z-index:auto" style to the layer element. The z-index attribute sets the stacking order of elements. Elements with a higher stacking order will always be in front of elements with a lower stacking order.

How to set layer on top in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

Method: Set styles for elements

 z-index:auto
Copy after login

auto can be defined as a value (integer number). The larger it is, the higher it is placed. For example, it can be defined as: z-index:999.

The premise is that div is a positioned element.

Example:

<html>
<head>
<style type="text/css">
img.x
{
position:absolute;
left:0px;
top:0px;
z-index:-1
}
</style>
</head>

<body>
<h1>这是一个标题</h1>
<img  class="x" src="/i/eg_mouse.jpg" / alt="How to set layer on top in css" > 
<p>默认的 z-index 是 0。Z-index -1 拥有更低的优先级。</p>
</body>

</html>
Copy after login

Effect:

How to set layer on top in css

Recommended learning: css video tutorial

The above is the detailed content of How to set layer on top in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template