[英]how to center a form using css?
從字面上看四面都有。 我看到很多教程正在使用
element.style.margin = "0 auto";
這僅以X軸為中心,而不是Y軸。
如何通過Y軸將其置於中心位置?
我用過:
#myItem {
position: fixed;
top: 50%;
left: 50%;
width: 100px;
height: 100px;
margin-top: -50px;
margin-left: -50px;
}
....之前,希望它有所幫助
在要垂直居中的元素上設置display: table-cell
和vertical-align: middle
,並在其父級容器元素上設置display: table
,使其居中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.