在css中如何设置图片的叠放次序?

html-css010

在css中如何设置图片的叠放次序?,第1张

将图片放在不同的div中,div要使用绝对定位,然后通过z-index来调整上下层的位置,如:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html charset=gb2312" />

<title>无标题文档</title>

<style>

ab{ position:relative}/*这个要用相对定位*/

.ab1{ position:absolute z-index:10}

.ab2{ position:absolute z-index:20}

.ab3{ position:absolute z-index:30}

</style>

</head>

<body>

<div class="ab">

<div class="ab1"><img src="01.jpg" /></div>

<div class="ab2"><img src="02.jpg" /></div>

<div class="ab3"><img src="03.jpg" /></div>

</div>

</body>

</html>

注意:最外层的div要用相对定位,然后调整里面z-index的数值来实现叠放层次

1、首先准备一个空的HTML5结构,如下图所示,然后在body中添加两个h标签,如下图所示。

2、然后在style标签下书写CSS样式,给h标签的伪元素添加content内容。

3、除了可以运用content添加纯文本内容外,也可以运用它添加文字符号,如下图所示,先定义符号,然后添加符号。

4、接下来就是运用content属性添加图片了,这也是比较常用的功能,如下图所示。

5、最后,来看一下运用content的counter属性来给指定的元素进行计数,如下图所示,h1标签会被添加上序号。