首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >屏幕4个角落的4个按钮

屏幕4个角落的4个按钮
EN

Stack Overflow用户
提问于 2022-02-10 20:28:27
回答 1查看 194关注 0票数 0

我正在做一个学校项目,我需要在屏幕的4个象限中放置4个按钮。然而,第一个按钮在它和屏幕顶部以及侧面之间有一个很小的差距。

代码:

game.html

代码语言:javascript
复制
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>Game</title>
<link rel="stylesheet" href="css/game.css">
</head>
<body>
<div id="container">
<button class="button">A</button>
<button class="button">B</button>
<button class="button">C</button>
<button class="button">D</button>
</div>
</body>
</html>

game.css

代码语言:javascript
复制
body {
  background-color: black;
  overflow: hidden;
  position: fixed;
}
h1, h2 {
  color: white;
  font-family: Ubuntu Mono;
}
#container {
  width: 100%;
  min-height: 100%;
  height: 100%;
}
.button {
  border: none;
  color: white;
  width: 50%;
  height: 50vh;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-family: Ubuntu Mono;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
  position: fixed;
}
.button: nth-child(1) {
  background-color: #bf0000;
  top: 0;
  left: 0;
}
.button:nth-child(2) {
  background-color: #001fbf;
  top: 0;
  right: 0;
}
.button:nth-child(3) {
  background-color: #e6c52d;
  bottom: 0;
  left: 0;
}
.button:nth-child(4) {
  background-color: #1fbf1f;
  bottom: 0;
  right: 0;
}

但是,我在这里看到了输出:

我怎样才能消除第一个按钮的间隙?

(如果你想要的话,帮我看看颜色:D)

如有任何帮助,将不胜感激!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-10 20:48:31

这是CSS中的一个错误。

代码语言:javascript
复制
.button:nth-child(1) {
  background-color: #bf0000;
  top: 0;
  left: 0;
}

删除.button后的空格:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71071864

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档