html - 无法将对象居中到页面中间
问题描述
我正在尝试将“注册”框居中放置在屏幕的中心,但无论我尝试什么,一切都停留在页面的左侧。目前,我试图以“主要内容”为中心。
在我的 .html 和 style.css 中,我有以下内容:
.signbox {
position: fixed;
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -100px;
}
<div class="singbox">
<h2>Main Content</h2>
<p>Other info about the site goes here</p>
</div>
我已经使用这个网站来解决这个问题,但正如你从截图中看到的那样,它不起作用。-> https://css-tricks.com/quick-css-trick-how-to-center-an-object-exactly-in-the-center/
解决方案
使拼写singbox
正确signbox
.signbox {
position: fixed;
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -100px;
}
<div class="signbox">
<h2>Main Content</h2>
<p>Other info about the site goes here</p>
</div>
推荐阅读
- firebase - 如何将 Dart Aqueduct API 与 Google Firestore 连接?
- css - 在 jsx 和 scss 中为必填字段添加星号
- regex - JSX 文件中的正则表达式不起作用,试图删除在名称周围返回的引号“”
- java - 在 Spring Boot 中处理无效的 PathVariables
- google-cloud-platform - 如何在 Google Cloud Platform 中找到 MerchantsCenter 创建的存储桶
- python - 在 Z3py 中使用多字节字符作为函数和排序名称
- javascript - timepicker.js - 在某些情况下时间选择器位置错误
- schema - 总价和每单位微数据的价格
- java - Jenkins kubernetes 插件:提供的端口:50000 不可访问
- git - git - 重置提交次数