2017-03-03 82 views
0

我有一個表格,我想做一個重點的CSS問題是密碼輸入我不能禁用自動對焦我什麼都試過,自動對焦=「off」時,自動對焦=「假」,但didnd的工作,我在這裏尋找其他的答案在SO和他們沒有解決我的問題自動對焦刪除

\t \t \t \t * { 
 
\t \t \t \t \t margin : 0; 
 
\t \t \t \t \t padding : 0; 
 
\t \t \t \t \t border : 0; 
 
\t \t \t \t } 
 

 
\t \t \t \t body { 
 
\t \t \t \t \t background-color: #eee; 
 
\t \t \t \t } 
 

 
\t \t \t \t .form-login { 
 
\t \t \t \t \t width : 400px; 
 
\t \t \t \t \t height: auto; 
 
\t \t \t \t \t position : absolute; 
 
\t \t \t \t \t padding : 10px 25px; 
 
\t \t \t \t \t background-color: #ddd; 
 
\t \t \t \t \t left: 50%; 
 
\t \t \t \t \t top: 50%; 
 
\t \t \t \t \t transform: translateX(-50%) translateY(-50%); 
 
\t \t \t \t \t border: none; 
 
\t \t \t \t \t border-top-right-radius: 5px; 
 
\t \t \t \t \t border-top-left-radius: 5px; 
 
\t \t \t \t } 
 
\t \t \t \t .login-logo { 
 
\t \t \t \t \t width: 125px; 
 
\t \t \t \t \t height : 125px; 
 
\t \t \t \t \t position: relative; 
 
\t \t \t \t \t border-radius : 125px; 
 
\t \t \t \t \t background: #ddd; 
 
\t \t \t \t \t margin: 0 auto; 
 
\t \t \t \t \t margin-top: 20px; 
 
\t \t \t \t } 
 
\t \t \t \t .input { 
 
\t \t \t \t \t width: 100%; 
 
\t \t \t \t \t height: 50px; 
 
\t \t \t \t \t background:gray; 
 
\t \t \t \t \t position: relative; 
 
\t \t \t \t \t margin:15px auto; 
 
\t \t \t \t } 
 

 
\t \t \t \t input[type="text"], 
 
\t \t \t \t input[type="password"]{ 
 
\t \t \t \t \t width:100%; 
 
\t \t \t \t \t height:50px; 
 
\t \t \t \t \t position: relative; 
 
\t \t \t \t \t outline :none; 
 
\t \t \t \t \t border:1px solid gray; 
 
\t \t \t \t \t border-radius: 3px; 
 
\t \t \t \t \t font-size:16px; 
 
\t \t \t \t \t font-family: 'Questrial',sans-serif; 
 
\t \t \t \t \t padding-left: 30px; 
 
    \t \t \t \t  -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ 
 
        -moz-box-sizing: border-box; /* Firefox, other Gecko */ 
 
    \t \t \t \t  box-sizing: border-box;   /* Opera/IE 8+ */ 
 
\t \t \t \t } 
 
\t \t \t \t input[type="text"]:focus, input[type="password"]{ 
 
\t \t \t \t \t border:2px solid #50C878; 
 
\t \t \t \t }
<section class="container"> 
 
\t <section class="form-login"> 
 
\t \t <section class="login-logo"> 
 
\t \t \t <img src="img/login-logo.png"> 
 
\t \t </section> 
 
\t \t \t <form class="form" name="form" method="post" action="login-m.php"> 
 
\t \t \t \t <section class ="input"> 
 
\t \t \t \t \t <input type="text" name="utilizador" value="" placeholder="Insira o nome de utilizador" required/><br> 
 
\t \t \t \t \t <i class="fa fa-user"></i> 
 
\t \t \t \t </section> \t \t 
 
\t \t \t \t <section class ="input"> \t 
 
\t \t \t \t \t <input type="password" name="palavrachave" value="" placeholder="Insira a sua palavra-chave" autofocus="off" required/><br> 
 
\t \t \t \t \t <i class="fa fa-lock"></i> 
 
\t \t \t \t </section> 
 
\t \t \t \t <a href="#">Esqueceu a palavra-chave ?</a> 
 
\t \t \t \t <p> Nome de Utilizador e/ou Palavra-chave incorreto(s)</p> 
 
\t \t \t \t <input type="submit" name ="entrar" value="Entrar"> 
 
\t \t \t </form> 
 
\t </section> 
 
</section>

+0

你應該加上':focus'您的密碼,否則風格的總是會顯示綠色邊框。 – Toxide82

回答

2

問題是不是自動對焦。從HTML中刪除auto-focus

這是這是給你的綠色邊框的CSS。

input[type="text"]:focus, input[type="password"]:focus{ 
    border:2px solid #50C878; 
} 

因爲,首先你申請邊框password field你得到green color

以下是您解決的代碼片斷

* { 
 
\t \t \t \t \t margin : 0; 
 
\t \t \t \t \t padding : 0; 
 
\t \t \t \t \t border : 0; 
 
\t \t \t \t } 
 

 
\t \t \t \t body { 
 
\t \t \t \t \t background-color: #eee; 
 
\t \t \t \t } 
 

 
\t \t \t \t .form-login { 
 
\t \t \t \t \t width : 400px; 
 
\t \t \t \t \t height: auto; 
 
\t \t \t \t \t position : absolute; 
 
\t \t \t \t \t padding : 10px 25px; 
 
\t \t \t \t \t background-color: #ddd; 
 
\t \t \t \t \t left: 50%; 
 
\t \t \t \t \t top: 50%; 
 
\t \t \t \t \t transform: translateX(-50%) translateY(-50%); 
 
\t \t \t \t \t border: none; 
 
\t \t \t \t \t border-top-right-radius: 5px; 
 
\t \t \t \t \t border-top-left-radius: 5px; 
 
\t \t \t \t } 
 
\t \t \t \t .login-logo { 
 
\t \t \t \t \t width: 125px; 
 
\t \t \t \t \t height : 125px; 
 
\t \t \t \t \t position: relative; 
 
\t \t \t \t \t border-radius : 125px; 
 
\t \t \t \t \t background: #ddd; 
 
\t \t \t \t \t margin: 0 auto; 
 
\t \t \t \t \t margin-top: 20px; 
 
\t \t \t \t } 
 
\t \t \t \t .input { 
 
\t \t \t \t \t width: 100%; 
 
\t \t \t \t \t height: 50px; 
 
\t \t \t \t \t background:gray; 
 
\t \t \t \t \t position: relative; 
 
\t \t \t \t \t margin:15px auto; 
 
\t \t \t \t } 
 

 
\t \t \t \t input[type="text"], 
 
\t \t \t \t input[type="password"]{ 
 
\t \t \t \t \t width:100%; 
 
\t \t \t \t \t height:50px; 
 
\t \t \t \t \t position: relative; 
 
\t \t \t \t \t outline :none; 
 
\t \t \t \t \t border:1px solid gray; 
 
\t \t \t \t \t border-radius: 3px; 
 
\t \t \t \t \t font-size:16px; 
 
\t \t \t \t \t font-family: 'Questrial',sans-serif; 
 
\t \t \t \t \t padding-left: 30px; 
 
    \t \t \t \t  -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ 
 
        -moz-box-sizing: border-box; /* Firefox, other Gecko */ 
 
    \t \t \t \t  box-sizing: border-box;   /* Opera/IE 8+ */ 
 
\t \t \t \t } 
 
\t \t \t \t input[type="text"]:focus, input[type="password"]:focus{ 
 
\t \t \t \t \t border:2px solid #50C878; 
 
\t \t \t \t }
<section class="container"> 
 
\t <section class="form-login"> 
 
\t \t <section class="login-logo"> 
 
\t \t \t <img src="img/login-logo.png"> 
 
\t \t </section> 
 
\t \t \t <form class="form" name="form" method="post" action="login-m.php"> 
 
\t \t \t \t <section class ="input"> 
 
\t \t \t \t \t <input type="text" name="utilizador" value="" placeholder="Insira o nome de utilizador" required/><br> 
 
\t \t \t \t \t <i class="fa fa-user"></i> 
 
\t \t \t \t </section> \t \t 
 
\t \t \t \t <section class ="input"> \t 
 
\t \t \t \t \t <input type="password" name="palavrachave" value="" placeholder="Insira a sua palavra-chave" required/><br> 
 
\t \t \t \t \t <i class="fa fa-lock"></i> 
 
\t \t \t \t </section> 
 
\t \t \t \t <a href="#">Esqueceu a palavra-chave ?</a> 
 
\t \t \t \t <p> Nome de Utilizador e/ou Palavra-chave incorreto(s)</p> 
 
\t \t \t \t <input type="submit" name ="entrar" value="Entrar"> 
 
\t \t \t </form> 
 
\t </section> 
 
</section>

1

試試這個: - 刪除autofocus="off"像下面

<input type="password" name="palavrachave" value="" 
placeholder="Insira a sua palavra-chave" required/> 

並更改密碼的風格

input[type="text"]:focus, 
input[type="password"]:focus{ 
    border:2px solid #50C878; 
}