首頁 > web前端 > css教學 > 主體

同型UI表單

WBOY
發布: 2023-08-26 23:49:08
轉載
761 人瀏覽過

同型UI表單

NeumorphismUI 是最近流行的設計趨勢,它將擬物化與現代風格結合。

當應用於表單時,NeumorphismUI 是一種值得考慮的設計風格。它可以使用戶介面感覺更加有形和交互,最終提高表單的整體可用性。

在本文中,我們將探討不同類型的 NeumorphismUI 表單,並為每種表單提供範例和最佳實務。

範例

在此範例中,我們建立了一個登入表單來增強增強的體驗。首先,我們首先以非擬態風格設計外形,賦予其現代而優雅的外觀。我們添加了微妙的陰影效果來創造深度和維度的錯覺,使其從背景中脫穎而出。

使用者可以在輸入欄位中輸入使用者名稱和密碼,將滑鼠停留在每個輸入欄位上時,該欄位將出現帶有陰影效果的凸起。

在輸出中,使用者看到登入表單具有視覺吸引力、實用且使用者友好。

索引.html

#
<html>
<head> 
   <title>Neumorphic Login Form</title> 
   <style>
      @import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"); 
      * {  
         box-sizing: border-box; 
         margin: 0; 
         padding: 0; 
      } 
      body { 
         font-family: 'Lato', sans-serif; 
         display: flex; 
         align-items: center; 
         justify-content: center; 
         flex-direction: column;
         width: 100%; 
         height: 100vh;
         background-color: #e6e6e6; 
      }  
      .container { 
         background-color: #e6e6e6; 
         border-radius: 20px; 
         box-shadow: -5px -5px 10px #ffffff, 5px 5px 10px #b7b7b7; 
         padding: 30px; 
      } 
      h1 { 
         text-align: center; 
         margin-bottom: 30px; 
         font-size 2rem; 
      } 
      h2{ 
         margin-bottom: 2rem; 
         color: #333; 
      } 
      form { 
         display: flex; 
         flex-direction: column;  
      }  
      .input-container { 
         position: relative; 
         margin-bottom: 20px; 
      }  
      input { 
         width:100%;
         background-color: #e6e6e6; 
         border: none; 
         border-radius: 10px; 
         box-shadow: inset -5px -5px 10px #ffffff, inset 5px 5px 10px #b7b7b7; 
         padding: 15px 20px; 
         font-size 1rem; 
         transition: box-shadow 0.2s ease; 
      } 
      input:focus { 
         outline: none; 
         box-shadow: inset -5px -5px 10px #b7b7b7, inset 5px 5px 10px #ffffff; 
      } 
      i {
         position: absolute; 
         top: 50%; 
         transform: translateY(-50%); 
         right: 20px; 
         color: #b7b7b7; 
         transition: transform 0.2s ease, color 0.2s ease; 
      }  
      input:focus + i { 
         transform: translateY(-50%) translateX(10px); 
         color: #777777;  
      } 
      button { 
         background-color: #ff7f50; 
         border: none;  
         border-radius: 10px; 
         color: #ffffff;  
         font-size: 1.2rem; 
         padding: 15px;  
         margin-top: 20px; 
         cursor: pointer;  
         transition: box-shadow 0.2s ease;  
      }  
      button:hover {  
         box-shadow: -5px -5px 10px #ffffff, 5px 5px 10px #b7b7b7; 
      } 
   </style>
</head> 
<body> 
   <h2>Neumorphism UI - Form Animation </h2> 
   <div class="container"> 
      <h1>Neumorphic Login Form</h1> 
      <form> 
         <div class = "input-container"> 
            <input type = "text" placeholder = "Username" required> 
            <i class="fas fa-user"></i> 
         </div> 
         <div class = "input-container"> 
            <input type = "password" placeholder = "Password" required>  
            <i class="fas fa-lock"></i> 
         </div> 
         <button type = "submit"> Sign in </button> 
      </form> 
   </div> 
</body> 
</html>
登入後複製

範例

在此範例中,我們建立了一個漸變 NeumorphismUI 表單。此表單包括使用者電子郵件、訊息的文字輸入欄位和提交按鈕。 CSS 樣式包括漸層背景、柔和的圓形形狀以及微妙的陰影,以創建 NeumorphismUI 效果。

索引.html

#
<html>
<head>
   <title> Gradient Form</title>
   <style>
      body {
         font-family: 'Lato', sans-serif;
         display: flex;
         align-items: center;
         justify-content: center;
         flex-direction: column;
         width: 100%;
         height: 100vh;
         background: linear-gradient(to bottom, #a6c0fe, #3f6bfe);
      }
      .neumorphism-form {
         display: flex;
         flex-direction: column;
         align-items: center;
         padding: 2rem;
         border-radius: 1rem;
      }
      .gradient {
         background: linear-gradient(to bottom, #a6c0fe, #3f6bfe);
         box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.1);
      }
      .neumorphism-form h2 {
         color: #fff;
         font-size: 2rem;
         margin-bottom: 1rem;
      }
      .neumorphism-form label {
         font-size: 1.2rem;
         margin-bottom: 0.5rem;
      }
      .message,
      .neumorphism-form input {
         padding: 0.5rem;
         border: none;
         border-radius: 0.5rem;
         background-color: #f7f7f7;
         box-shadow: inset 4px 4px 8px rgba(255, 255, 255, 0.5),
         inset -4px -4px 8px rgba(0, 0, 0, 0.1);
         margin-bottom: 1rem;
         width: 100%;
      }
      .neumorphism-form button {
         background-color: #3f6bfe;
         color: #fff;
         border: none;
         border-radius: 0.5rem;
         padding: 0.5rem 1rem;
         font-size: 1.2rem;
         box-shadow: 4px 4px 8px rgba(163, 177, 198, 0.5),
         -4px -4px 8px rgba(255, 255, 255, 0.2);
         cursor: pointer;
      }
      .neumorphism-form button:hover {
         transform: translateY(-2px);
         box-shadow: 2px 2px 4px rgba(163, 177, 198, 0.5),
         -2px -2px 4px rgba(255, 255, 255, 0.2);
      }
   </style>
</head>
<body>
   <form class = "neumorphism-form gradient">
      <h2> Contact Us </h2>
      <input type = "email" id = "email" name = "email" placeholder = "Email">
      <textarea class = "message" id =" " cols = "30" rows = "10" placeholder = "Write Your Message..."> </textarea>
      <button type = "submit"> Submit </button>
   </form>
</body>
</html>
登入後複製

範例

在此範例中,我們建立了一個深色模式 Neumorphism UI 表單,允許使用者訂閱電子報。之後,我們為主體添加了線性漸變背景色,並為表單提供了帶有負值和正值的框陰影以創建同態效果。

在輸出中,使用者可以觀察到具有同態效果的暗模式表單,其中表單元素似乎從背景中略微凸起。

Index.html -

<html>
<head>
   <title> Dark Mode Form</title>
   <style>
      body {
         font-family: "Lato", sans-serif;
            display: flex;
         align-items: center;
         justify-content: center;
         flex-direction: column;
         width: 100%;
         height: 100vh;
         background: linear-gradient(150deg, #333, #111);
      }
      .neumorphism-form {
         display: flex;
         flex-direction: column;
         align-items: center;
         padding: 2rem;
         border-radius: 1rem;
      }
      .dark-mode {
         box-shadow: -4px -4px 4px rgba(255, 255, 255, 0.08),
         4px 4px 4px rgba(0, 0, 0, 0.56), 0 0 0 rgba(255, 255, 255, 0.08) inset,
         0 0 0 rgba(0, 0, 0, 0.56) inset;
         border: 1px solid rgba(0, 0, 0, 0.08);
      }
      .neumorphism-form h2 {
         font-size: 1.5rem;
         margin-bottom: 1.5rem;
         color: #64dd178f;
      }
      .neumorphism-form input[type="email"] {
         padding: 0.5rem;
         background-color: transparent;
         box-shadow: -2px -2px 2px rgba(255, 255, 255, 0.08),
         2px 2px 2px rgba(0, 0, 0, 0.56),
         -2px -2px 2px rgba(255, 255, 255, 0.08) inset,
         2px 2px 2px rgba(0, 0, 0, 0.56) inset;
         border: 1px solid rgba(0, 0, 0, 0.08);
         margin-bottom: 1rem;
         width: 100%;
            color: #ffff;
      }
      .neumorphism-form button {
            background-color: transparent;
            color: #ff40408f;
            border-radius: 0.5rem;
         padding: 0.5rem 1rem;
         font-size: 1.2rem;
         box-shadow: -2px -2px 4px rgba(100, 221, 23, 0.12),
         4px 4px 4px rgba(0, 0, 0, 0.56), 0 0 0 rgba(100, 221, 23, 0.12) inset,
         0 0 0 rgba(0, 0, 0, 0.56) inset;
         border: 1px solid rgba(0, 0, 0, 0.08);
         cursor: pointer;
      }
      .neumorphism-form button:hover {
         transform: translateY(-2px);
         border: solid 1px #64dd178f;
      }
   </style>
</head> 
<body>
   <form class = "neumorphism-form dark-mode"> 
      <h2> Subscribe to Newsletter </h2>
      <input type = "email" id = "email" name = "email" placeholder = "Enter your email">
      <button type = "submit"> Subscribe </button>
   </form>
</body>
</html>
登入後複製

結論

使用者已經學會如何使用 neumorphismUI 建立具有視覺吸引力的表單,例如漸層表單、深色模式表單和簡單表單。他們還學習如何使用 CSS 來創建同態設計,為表單提供現代而真實的外觀。

以上是同型UI表單的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:tutorialspoint.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!