【发布时间】:2021-02-26 20:29:35
【问题描述】:
我无法正确对齐显示我的内容。我使用 html 和 css 制作了一个计时器网络应用程序,但是当我在网页中放大或缩小时,显示结构会变得混乱。外框和内按钮不会一起放大或缩小,放大时按钮也会进入下一行。我附上了它们的外观截图。
我使用弹性盒子来对齐组件 这是我写的代码:
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>
我刚开始,所以任何帮助都会很棒。谢谢!
【问题讨论】:
-
缩放的期望结果是什么?一切都变大了还是一切都保持不变?
-
<center>是一个过时的元素,不应再使用。 -
@MikeB 按钮和框随着比例减小而增加
标签: html css forms button flexbox