gpt4 book ai didi

html - 获取此 "simon says"游戏中间控件的标题和按钮

转载 作者:搜寻专家 更新时间:2023-10-31 08:14:18 25 4
gpt4 key购买 nike

我正在开发 Simon Says 游戏,但我无法将标题和按钮从底部放到控件部分的中间。我尝试了不同的 css 样式,但 div 似乎没有移动。

特别是 margin-top 将元素移到更靠近中间的位置。现在它们位于页面底部。这是我到目前为止所拥有的。任何帮助表示赞赏。谢谢

body {
background: url("http://cdn.backgroundhost.com/backgrounds/subtlepatterns/purty_wood.png");
font-family: 'Righteous', cursive;
color: black;
}

.container {
margin: 0 auto;
text-align: center;
}

h1 {
font-size: 70px;
}

.simonBoard {
margin: 0 auto;
/* margin-top: 100px; */
border: solid 10px black;
width: 600px;
height: 600px;
border-radius: 600px;
position: relative;
box-shadow: -10px 10px 7px 0px rgba(50, 50, 50, 0.75);
}

.pad {
margin: 0;
float: left;
position: relative;
width: 290px;
height: 290px;
z-index: 8;
border: 5px solid black;
}

.pad-green {
background-color:#0a0;
-moz-border-radius: 300px 0 0 0;
border-radius: 300px 0 0 0;
}

.pad-red {
background-color: red;
-moz-border-radius: 0 300px 0 0;
border-radius: 0 300px 0 0;
}

.pad-yellow {
background-color: yellow;
-moz-border-radius: 0 0 0 300px;
border-radius: 0 0 0 300px;
}

.pad-blue {
background-color: blue;
-moz-border-radius: 0 0 300px 0;
border-radius: 0 0 300px 0;
}

.board-controls {
display: inline-block;
border: 15px solid black;
height: 245px;
width: 245px;
border-radius: 150px;
background-color: white;
position: absolute;
z-index: 10;
top: 0; left: 0; right: 0; bottom: 0;
margin: auto;
-webkit-box-shadow: -6px 8px 5px 0px rgba(50, 50, 50, 0.75);
/* -moz-box-shadow: -6px 8px 5px 0px rgba(50, 50, 50, 0.75);
box-shadow: -6px 8px 5px 0px rgba(50, 50, 50, 0.75); */
}
<div class="container">
<div class="header">
<h1>SIMON</h1>
</div>
<div class="simonBoard">
<div class="pad pad-green"></div>
<div class="pad pad-red"></div>
<div class="pad pad-yellow"></div>
<div class="pad pad-blue"></div>
<div class="board-controls">
<div class="title">SIMON</div>
<div class="display">07</div>
<div class="start">START</div>
<div class="strict">STRICT</div>
<div class="switch">ON/OFF</div>
</div>
</div>
</div>

最佳答案

body {
background: url("http://cdn.backgroundhost.com/backgrounds/subtlepatterns/purty_wood.png");
font-family: 'Righteous', cursive;
color: black;
}

.container {
margin: 0 auto;
text-align: center;
}

h1 {
font-size: 70px;
}

.simonBoard {
margin: 0 auto;
/* margin-top: 100px; */
border: solid 10px black;
width: 600px;
height: 600px;
border-radius: 600px;
position: relative;
box-shadow: -10px 10px 7px 0px rgba(50, 50, 50, 0.75);
}

.pad {
margin: 0;
float: left;
position: relative;
width: 290px;
height: 290px;
z-index: 8;
border: 5px solid black;
}

.pad-green {
background-color:#0a0;
-moz-border-radius: 300px 0 0 0;
border-radius: 300px 0 0 0;
}

.pad-red {
background-color: red;
-moz-border-radius: 0 300px 0 0;
border-radius: 0 300px 0 0;
}

.pad-yellow {
background-color: yellow;
-moz-border-radius: 0 0 0 300px;
border-radius: 0 0 0 300px;
}

.pad-blue {
background-color: blue;
-moz-border-radius: 0 0 300px 0;
border-radius: 0 0 300px 0;
}

.board-controls {
display: inline-block;
border: 15px solid black;
height: 245px;
width: 245px;
border-radius: 150px;
background-color: white;
position: absolute;
z-index: 10;
top: 0; left: 0; right: 0; bottom: 0;
margin: auto;
-webkit-box-shadow: -6px 8px 5px 0px rgba(50, 50, 50, 0.75);
/* -moz-box-shadow: -6px 8px 5px 0px rgba(50, 50, 50, 0.75);
box-shadow: -6px 8px 5px 0px rgba(50, 50, 50, 0.75); */
}
<div class="container">
<div class="header">
<h1>SIMON</h1>
</div>
<div class="simonBoard">
<div class="pad pad-green"></div>
<div class="pad pad-red"></div>
<div class="pad pad-yellow"></div>
<div class="pad pad-blue"></div>
<div class="board-controls">
<div class="title">SIMON</div>
<div class="display">07</div>
<div class="start">START</div>
<div class="strict">STRICT</div>
<div class="switch">ON/OFF</div>
</div>
</div>
</div>

我确实设置了 .board-controlsposition:absolute

并设置.simonBoardposition:relative

我认为这不是一个好的答案。

关于html - 获取此 "simon says"游戏中间控件的标题和按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45884063/

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