老师请看一下这是什么问题

来源:5-2 编程练习

慕斯卡3102410

2020-01-08 14:46:00

<html>
<head>
    <style type="text/css">
       #one{
             width: 100px;
       	     height: 100px;
	     background: red;
	     /* 请在此添加代码*/
             float:left;
             z-index: 2;
       }
        #two{
        	width: 100px;
       		height: 100px;
		background: green;
		/* 请在此添加代码*/
		position:absolute;
		top:25px;
		left:25px;
		z-index: 1;
       }
    </style>
 </head>

<body>
<div id="one">
    
</div>
<div id="two">

</div>
</body>
</html>


写回答

2回答

好帮手慕小尤

2020-01-08

同学你好,z-index 是要在定位元素上奏效。修改后代码如下:

http://img.mukewang.com/climg/5e158b0c09fd02a003390251.jpg

如果我的回答解决了你的疑惑,请采纳!祝学习愉快!

0

慕斯卡3102410

提问者

2020-01-08

z-index是要在绝对位置上才能使用吗

0

0 学习 · 9666 问题

查看课程