大家好我有一個登錄表單,從我用變換上下和左右中心這種形式:翻譯(-50%, - 50%);它在Chrome,safari,firefox和移動設備以及桌面設備上工作正常。但在opera瀏覽器中效果不佳我還爲Opera瀏覽器添加了webkit。如何在所有瀏覽器和所有移動設備中心表單
這是我demo to play with css 這裏是HTML代碼
<div class="container">
<div class="login-form-section">
<form class="login-form">
<h1 class="login-text">Login</h1>
<input type="email" class="input-lg form-control login-input" placeholder="Email" required="" autofocus="">
<input type="password" class="form-control login-input input-lg" placeholder="Password" required="">
<button class="btn btn-lg btn-yellow-submit btn-block" type="submit">
Login
</button>
<a class="forgot-pass-link" href="forgot-password.html"><span class="f-link">Forgot Password</span></a>
<a href="order.html" class="register-link"><span class="r-link">Register and Subscribe</span></a>
</form>
</div>
</div>
和我的CSS
.login-form {
max-width: 375px;
background: black;
padding: 25px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
/* -webkit-transform: translate(-50%,-50%); */
-o-transform: translate(-50%,-50%);
-moz-transform: translate(-50%,-50%);
width: 100%;
display: block;
}
是他們的任何其他方法來中心進行移動形式以及桌面像歌劇所有主流瀏覽器火狐鉻和Safari瀏覽器?現在我的代碼可以正常工作,除了歌劇,我還有爲歌劇寫的webkit。請提供一些建議。謝謝。
注意我已經嘗試用保證金:0汽車;它只爲垂直中心水平居中,我不得不重新調整在瀏覽器中向瀏覽器驗證的margin-top或padding-top。
我認爲你應該使用'Media Queries'來居中形式瀏覽器和移動設備。 – mmushtaq
我找不到任何錯誤,它在Opera上的效果也很好。 – frnt
這裏是一個例子** [小提琴](http://jsfiddle.net/mmushtaq/hABGX/109/)** – mmushtaq