Html 我如何将元素发送到后台
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8652462/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can i send an element to the background
提问by 71GA
I have a problem. On my webpage I have implemented a clock which has absolute position, and is interfering with my dropdown menu.
我有个问题。在我的网页上,我实现了一个具有绝对位置的时钟,并且干扰了我的下拉菜单。
My html codefor the clock is as follows, where txtis a parameter i get from my JavaScript:
我的时钟html 代码如下,其中txt是我从 JavaScript 获取的参数:
<time>
<div id="txt"></div>
</time>
and my css codeis like this:
我的css 代码是这样的:
time{
border: 2px dashed red;
font-size: 80px;
font-family: circle;
position: absolute;
top: 15px;
left: 43%;
}
Because the clock is in front of my menu I cannot accesss nested unnumbered lists. What can I do to send my clock to the background?
因为时钟在我的菜单前面,所以我无法访问嵌套的未编号列表。我该怎么做才能将我的时钟发送到后台?
回答by natedavisolds
You need to set the z-index to be lower than the menus z-index.
您需要将 z-index 设置为低于菜单 z-index。
time {
z-index: 900;
}
menu {
z-index: 950;
}
回答by Aadhi Vive
Setting the time tag to be lower in z-index to other elements is a good solution. However you can also send the time tag to back. using z-index : -1 (given you have only one time element).
将时间标签在 z-index 中设置为较低的其他元素是一个很好的解决方案。但是,您也可以将时间标签发送回去。使用 z-index : -1 (假设您只有一个时间元素)。
time {
z-index:-1;
}