簡體   English   中英

CSS 登錄表單出現奇怪的效果,如何解決?

[英]CSS strange effect on login form, how to solve it?

剛開始玩 HTML 和 CSS,我嘗試創建一個注冊表單。

在將一些 css 應用到我的 html 之后,我單擊輸入框后出現了奇怪的行為,請參見附件中的 gif。 看起來我的表單在點擊時改變了不透明度。

奇怪的

這里的代碼

 .body{ background-image: linear-gradient(to right top, #0b5ad0, #0794e7, #004093, #0069bf); height: 100vh; width: 100vw; }.center{ display: inline-block; background-color: #000; color: #fff; opacity: .5; height: 50%; width: 50%; position: relative; left: calc(50%/2); top: 25%; border-radius: 10px; text-align: center; }.title{ text-transform: uppercase; font-size: 2vh; }.cont{ display: inline-block; width: 75%; text-align: left; position: relative; top: 0; margin-top: 0.5vh; } label{ font-size: 1.5vh; } input{ width: 100%; height: 30px; border-radius: 0.5vh; margin-top: 5px; }
 <.DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Sign Up</title> <link rel="stylesheet" href="signup:css"> </head> <body class="body"> <div class="center"> <h1 class="title">Sign Up New User</h1> <form class="submit_form"> <div class="cont"> <label for="Name">First name:</label><br> <input type="text" id="Name" name="fname"> </div> <div class="cont"> <label for="Surname">Surname:</label><br> <input type="text" id="Surname" name="fsurname"> </div> </form> </div> </body> </html>

在“.center”class 中,我刪除了不透明度:0.5並添加了使用 RGB 顏色這樣的背景顏色:rgb(0 0 0 / 50%); 用於設置透明背景。

 .body{ background-image: linear-gradient(to right top, #0b5ad0, #0794e7, #004093, #0069bf); height: 100vh; width: 100vw; }.center{ display: inline-block; background-color: rgb(0 0 0 / 50%); color: #fff; height: 50%; width: 50%; position: relative; left: calc(50%/2); top: 25%; border-radius: 10px; text-align: center; }.title{ text-transform: uppercase; font-size: 2vh; }.cont{ display: inline-block; width: 75%; text-align: left; position: relative; top: 0; margin-top: 0.5vh; } label{ font-size: 1.5vh; } input{ width: 100%; height: 30px; border-radius: 0.5vh; margin-top: 5px; }
 <.DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Sign Up</title> <link rel="stylesheet" href="signup:css"> </head> <body class="body"> <div class="center"> <h1 class="title">Sign Up New User</h1> <form class="submit_form"> <div class="cont"> <label for="Name">First name:</label><br> <input type="text" id="Name" name="fname"> </div> <div class="cont"> <label for="Surname">Surname:</label><br> <input type="text" id="Surname" name="fsurname"> </div> </form> </div> </body> </html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM