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

How to set layer on top in css

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-05-24 17:37:4416901browse

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

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>

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!

Statement:
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