我在正确地显示我的内容时遇到了问题。我使用html和css制作了一个计时器web应用程序,但是当我放大或缩小网页时,显示结构就会变得混乱。外部框和内部按钮不能同时放大或缩小,当缩放时,按钮也会进入下一行。我附上了他们看上去的截图。
我使用了flex框对齐组件,下面是我编写的代码:
body {
height: 100vh;
font-family: "Poppins", "PT sans", Arial, sans-serif;
background-image: url("bg.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
display: flex;
justify-content: center;
align-items: center;
}
.container {
background-color: rgba(0, 0, 0, 0.8);
border-radius: 10%;
-webkit-box-shadow: 0px 2px 7px 8px rgba(255, 255, 255, 0.40);
box-shadow: 0px 6px 12px 13px rgba(255, 255, 255, 0.40);
width: 55vh;
height: 70vh;
display: flex;
flex-direction: column;
}
.image {
margin-top: 10%;
}
.block {
display: inline-block;
}
span {
font-size: 50px;
color: white;
}
button {
align-items: center;
margin: 12px;
border-radius: 50px;
font-size: 18px;
height: 90%;
padding: 10px 40px;
z-index: 1;
cursor: pointer;
transition: 0.5s;
position: relative;
}
button:hover {
color: white;
background: none;
}
/*.button::before{
content: "";
position: absolute;
left: 0;
height: 0%;
width: 100%;
background: none;
z-index: -1;
transition: 0.5s;
}*/<body>
<div class="container">
<div class="image">
<center><img src="timer.png" width="40%" height="20%" alt="" id="timer">
<br>
<span id="countdown"> 60 </span> <span id="plural">s</span>
<br>
<div class="block">
<button id="start" name="start" class="fill" onclick="startTimer()">START</button><br>
<button id="add" name="+5" class="fill" onclick="add()">+5</button><br>
</div>
<div class="block">
<button id="pause" name="pause" class="fill" onclick="pauseTimer()">PAUSE</button> <br>
<button id="remove" name="remove" class="fill" onclick="remove()">-5</button> <br>
</div>
<div class="block2"><button id="end" name="" class="fill" onclick="endTimer()">END</button></div>
</center>
</div>
<!-- <div class="text"></div> -->
<div></div>
</div>
<script src="index.js"></script>
</body>
我刚开始,所以任何帮助都会很好。谢谢!
发布于 2021-02-26 23:03:03
我猜测您要做什么,但是如果我正确理解您的目标,您在.container上的高度和宽度值会给您带来问题。我删除了它们,并将<center>替换为<div>,Paulie评论道,它已经过时了:
body {
height: 100vh;
font-family: "Poppins", "PT sans", Arial, sans-serif;
background-image: url("bg.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
display: flex;
justify-content: center;
align-items: center;
}
.container {
text-align: center;
background-color: rgba(0, 0, 0, 0.8);
border-radius: 10%;
-webkit-box-shadow: 0px 2px 7px 8px rgba(255, 255, 255, 0.40);
box-shadow: 0px 6px 12px 13px rgba(255, 255, 255, 0.40);
display: flex;
flex-direction: column;
}
.image {
margin-top: 10%;
}
.block {
display: inline-block;
}
span {
font-size: 50px;
color: white;
}
button {
align-items: center;
margin: 12px;
border-radius: 50px;
font-size: 18px;
height: 90%;
padding: 10px 40px;
z-index: 1;
cursor: pointer;
transition: 0.5s;
position: relative;
}
button:hover {
color: white;
background: none;
}<body>
<div class="container">
<div class="image">
<div><img src="timer.png" width="40%" height="20%" alt="" id="timer">
<br>
<span id="countdown"> 60 </span> <span id="plural">s</span>
<br>
<div class="block">
<button id="start" name="start" class="fill" onclick="startTimer()">START</button><br>
<button id="add" name="+5" class="fill" onclick="add()">+5</button><br>
</div>
<div class="block">
<button id="pause" name="pause" class="fill" onclick="pauseTimer()">PAUSE</button> <br>
<button id="remove" name="remove" class="fill" onclick="remove()">-5</button> <br>
</div>
<div class="block2"><button id="end" name="" class="fill" onclick="endTimer()">END</button></div>
</div>
</div>
<!-- <div class="text"></div> -->
<div></div>
</div>
<script src="index.js"></script>
</body>
https://stackoverflow.com/questions/66392413
复制相似问题