如何垂直居中元素
- 上一页 翻转盒子
- 下一页 在 DIV 中居中按钮
学习如何使用 CSS 将元素垂直和水平居中。
我是垂直和水平居中的。
如何垂直居中任意元素
အကြောင်းအရာ
<style> .container { height: 200px; position: relative; border: 3px solid green; } .vertical-center { margin: 0; position: absolute; top: 50%; -ms-transform: translateY(-50%); transform: translateY(-50%); } </style> <div class="container">I am vertically centered.
</div> </div>如何垂直和水平居中
အကြောင်းအရာ
<style> .container { height: 200px; position: relative; border: 3px solid green; } .center { margin: 0; position: absolute; top: 50%; left: 50%; -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } </style> <div class="container"> <div class="center"> <p>I am vertically and horizontally centered.</p> </div> </div>ကျော်ကြားလျက် Flexbox ကို အကိုင်းအခါ အရှိန်ထိပ်ချက်များ ကို အလိုက်လျက် စီးဆင်းလိုက်ပါ
အကြောင်းအရာ
.center { display: flex; justify-content: center; align-items: center; height: 200px; border: 3px solid green; }ပါဝင်သော စာမျက်နှာ
教程:CSS စီးဆင်း
教程:CSS Flexbox
- 上一页 翻转盒子
- 下一页 在 DIV 中居中按钮