html - 未对齐的块对象
问题描述
在我的页脚中,我有一个要居中的 div,但它却漂浮在页脚的顶部。https://codepen.io/k1n64r7hur/pen/MWvaGrP
footer {
text-align: center;
background-color: grey;
position: fixed;
bottom: 0;
width: 100%;
height: 1.5em;
display: block;
transition: bottom 0.3s;}
.test {
float: none;
background-color: blueviolet;
position: absolute;
display: inline-block;
height: 1.5em;
width: 90%;
padding: 0;
bottom: 50%;
left: 50%;
transform: translate(-50%, -50%);}
解决方案
页脚的高度需要增加。translate 的用法是将块向上拉。
footer {
//text-align: center;
background-color: grey;
position: fixed;
//bottom: 0;
width: 100%;
height: 3em;
//display: block;
transition: bottom 0.3s;
}
.test {
text-align:center;
//float: none;
background-color: blueviolet;
//position: absolute;
//display: inline-block;
height: 3em;
width: 90%;
padding: 5px 5%;
//bottom: 50%;
left: 50%;
//transform: translate(-50%, -50%);
}
document.getElementById("footbar").style.bottom = "-3rem";
推荐阅读
- typescript - 找不到 TypeScript 模块文件
- r-markdown - 使用 stargazer 创建回归表时无法更改 NULL 长度错误
- python - 没有从 Yahoo-Finance 获取数据
- grouping - 在 graylog、prometheus、grafana 等工具中对历史警报进行分组
- java - 在没有用户和密码数据的情况下使用 java 在 WebSphere MQ 上配置 jms
- python - 如何使用额外的图像相关参数在 Keras 中创建自定义成本函数?
- r - 在R中加载xlsx包的java版本错误
- angular - 如何在单击highcharts angular中的x范围图时动态创建时间线图
- ios - 如何在通过控制器移动时隐藏 UINavigationBar?
- ruby-on-rails - 我应该验证类型列吗?(导轨,STI)