gpt4 book ai didi

javascript - Image or Div behind Div (HTML web development)

转载 作者:行者123 更新时间:2023-11-28 02:36:25 24 4
gpt4 key购买 nike

在我开始解释我的问题之前,我想弄清楚我在做什么。我正在制作一个您在“电梯”中的网站。当您按下电梯的 6 个按钮中的任何一个时,门就会打开,信息会出现在空白处。但是,当我实际尝试将任何内容放入空白区域时,div“rightdoor”和“leftdoor”向下移动并且我尝试放置的信息保留在 ontop...

我的问题是,如何防止div 去干什么?以及如何将 div 放在另一个 div 后面?

@-webkit-keyframes leftdooropen {
from {
right: 0%;
}

to {
right: 50%;
}
}

@-webkit-keyframes rightdooropen {
from {
left: 50%;
}

to {
left: 100%;
}
}

@-webkit-keyframes leftdoorclose {
from {
right: 50%;
}

to {
right: 0%;
}
}

@-webkit-keyframes rightdoorclose {
from {
left: 100%;
}

to {
left: 50%;
}
}

body, html {
height: 100%;
margin: 0;
}

#leftdoor {
background-image: url("Door.png");
position: relative;
/* Full height */
height: 100%;
width: 50%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

#rightdoor {
position: relative;
left: 50%;
background-image: url("Door.png");
height: 100%;
width: 50%;
bottom: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
vertical-align: top;
}

.lframe {
position: relative;
height: 100%;
width: 10px;
left: 100%;
z-index: 1;
}

.rframe {
position: relative;
height: 100%;
width: 10px;
right: 0%;
z-index: 2;
}

.myButton {
background: #3498db;
background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
background-image: -moz-linear-gradient(top, #3498db, #2980b9);
background-image: -ms-linear-gradient(top, #3498db, #2980b9);
background-image: -o-linear-gradient(top, #3498db, #2980b9);
background-image: linear-gradient(to bottom, #3498db, #2980b9);
-webkit-border-radius: 28;
-moz-border-radius: 28;
border-radius: 28px;
font-family: Arial;
color: #ffffff;
font-size: 20px;
padding: 10px 20px 10px 20px;
text-decoration: none;
}

.myButton:hover {
background: #3cb0fd;
background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
text-decoration: none;
}

#celevator {
z-index: -2;
position: relative;
}

#1 {
position: relative;
bottom: 1000px;
}
<html>
<link rel="stylesheet" href="Design.css">

<head>

</head>

<body>

<div id="leftdoor">
<img class="lframe" src="frame.png">
</div>

<div id="1">

</div>
<div id="rightdoor">

<img class="rframe" src="frame.png">

<button class="myButton" style="position:relative; left:80%; bottom:75%;" onclick="openelevator(this)">1</button>
<a href="#" class="myButton" style="position:relative; left:71.9%; bottom:68%;" onclick="openelevator(this)">2</a>
<a href="#" class="myButton" style="position:relative; left:63.8%; bottom:61%;" onclick="openelevator(this)">3</a>
<a href="#" class="myButton" style="position:relative; left:55.9%; bottom:54%;" onclick="openelevator(this)">4</a>
<a href="#" class="myButton" style="position:relative; left:48%; bottom:47%;" onclick="openelevator(this)">5</a>
<a href="#" class="myButton" style="position:relative; left:38%; bottom:35%;" onclick="openelevator(this)">Earth</a>
<a href="#" class="myButton" style="position:relative; left:25%; bottom:27%;" onclick="openelevator(this)">> | <</a>

</div>
</body>

最佳答案

我不清楚你的第一个问题“如何防止 div 去做什么?”。如果您能提供一个正常工作的示例,我们就能得到一个清晰的想法。

但是对于您的第二个问题“如何将 div 放在另一个 div 后面?”,您的意思是这样的吗?

.container{
border: 1px solid #ccc;
width: 400px;
height: 450px;
background: #eee;
}
.div-1, .div-2{
width: 200px;
height: 300px;
background: #6e6ebf;
position: absolute;
left: 50px;
top: 50px;
}
.div-2{
left: 100px;
top: 100px;
background: #6ebfad;
}
<div class="container">
<div class="div-1">
Div 1
</div>
<div class="div-2">
Div 2
</div>
</div>

关于javascript - Image or Div behind Div (HTML web development),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47049518/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com