简体   繁体   English

简单的CSS z-index示例不起作用

[英]Simple CSS z-index example not working

I'm trying to make a simple html with 2 images one above other on z-index: 我正在尝试在z-index上制作一个带有两个图像的简单html:

<html>
    <head>
        <title>test</title>
        <style type="text/css">
            back {
                position: absolute;
                left: 0px;
                top:0px;
                z-index:0;
            }

            front {
                position: absolute;
                left: 0px;
                top:0px;
                z-index:1;
            }
        </style>
    </head>
    <body>
        <img id="front" src="loading.gif">
        <img id="back" src="plasma.jpg">
    </body>
<html>

but why the z-index is not working? 但是为什么Z索引不起作用?

You forgot to add # before the IDs in your CSS. 您忘记在CSS中的ID之前添加#

#back { ... }
#front { ... }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM