html - 按钮不为移动设备调整大小
问题描述
道歉。在一些帮助之后,我无法让按钮居中并正确安装在移动设备上。我有一个隐藏的 div,所以当你点击它出现的按钮时,它似乎工作正常。我认为我没有很好地构建 CSS,所以任何帮助都将不胜感激。谢谢。
HTML
<div class="container">
<button type="button" data-toggle-page="#home" class="button">Home
designing</button>
</div>
<div id="home" class="page">
<div class="section">
<h2 class="kitchen">Kitchen</h2>
</div>
<div class="section">
<h2><a style="text-decoration: none" href="Lounge">Lounge</a></h2>
</div>
<div class="section">
<h2><a style="text-decoration: none" href="Dining">Dining room</a></h2>
</div>
<div class="section">
<h2><a style="text-decoration: none" href="Hall">Hallway</a></h2>
</div>
</div>
CSS
body {
font-family: 'Montserrat', sans-serif;
background: url(image.jpg) no-repeat center center;
background-attachment: fixed;
background-size: 100% 100%;
}
.container {
text-align: center;
max-width: 100%;
}
.button {
background-color: rgba( 0, 0, 0, 0);
/* text-align: center;*/
margin-top: 200px;
font-size: 100px;
color: #fff;
font-family: 'Montserrat Subrayada', sans-serif;
border: none;
outline: none;
}
.page {
position: absolute;
visibility: hidden;
pointer-events: none;
text-align: center;
}
解决方案
您可以使用flexbox使元素居中:
.container {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
max-width: 100%;
}
align-items: center;
将垂直居中。
justify-content: center;
将水平居中。
推荐阅读
- sql-server - 查询以查找 10 岁以上的儿童
- animation - 更改(动画)gif中特定颜色的所有像素?
- python-3.x - 如何在文件中查找模式并使用python在文件中注释该模式
- javascript - 如何在 Babylon.js(Y 轴)中反转 backUVs 图像?
- cypress - 如何在继续测试之前等待传递给赛普拉斯自定义命令的回调完成?
- angular - Angular Material MatDialog 未正确销毁
- java - onClick 方法无法捕获未保存到图库的图像和文件
- ruby-on-rails - Rspec 删除 activerecord 列,命名为测试行为的方法
- javascript - 有什么方法可以知道 npm 包是否具有特定于操作系统的构建要求?
- python - 如何跨 Slurm 集群上的多个节点运行 MPI Python 脚本?错误:警告:无法在 2 个节点上运行 1 个进程,将 nnodes 设置为 1