表單樣式

一、表單樣式模板

表單是網站和應用程序中常用的重要元素之一,良好的表單樣式可以提高用戶體驗,增強用戶對網站或應用程序的感知價值。為了提高開發效率,開發人員可以使用現成的表單樣式模板來快速實現表單樣式。目前比較流行的表單樣式模板有Bootstrap、Materialize等。下面是使用Bootstrap樣式模板實現的一個簡單表單示例:

<form>
  <div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
  </div>
  <div class="form-check">
    <input type="checkbox" class="form-check-input" id="exampleCheck1">
    <label class="form-check-label" for="exampleCheck1">Check me out</label>
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

二、表單樣式設計

表單樣式的設計應考慮到布局、顏色、字體等多個方面。表單布局應該合理、清晰,避免元素重疊或過度分散,以保證用戶能夠方便地填寫信息。表單顏色應該和網站或應用程序的整體風格保持一致,能夠傳達出正確的情感和信息。字體選擇應該遵循易讀易懂的原則,同時字型大小和字距也應該合理設置。下面是一個簡單表單設計示例:

.form-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
}

.form-wrap h2 {
  font-size: 40px;
  font-weight: bold;
  margin-bottom: 60px;
}

.form-wrap input[type="text"], 
.form-wrap input[type="email"],
.form-wrap input[type="password"] {
  width: 600px;
  height: 60px;
  margin-bottom: 20px;
  padding: 20px;
  border: none;
  border-radius: 30px;
  box-shadow: 0 0 10px 0 rgba(0,0,0,.2);
  font-size: 20px;
  font-weight: 400;
}

.form-wrap button[type="submit"] {
  width: 200px;
  height: 60px;
  border: none;
  border-radius: 30px;
  background-color: #3498db;
  box-shadow: 0 0 10px 0 rgba(0,0,0,.2);
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
}

.form-wrap button[type="submit"]:hover {
  opacity: .9;
}

三、移動端表單樣式

移動設備的屏幕相對較小,因此移動端表單樣式應該優化布局和輸入體驗。在設計表單樣式時,應該將「張冠李戴原則」考慮進去,減少用戶在輸入時的誤觸發率,並增加輸入交互體驗。下面是一個簡單的移動端表單樣式示例:

.form-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
}

.form-wrap h2 {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 40px;
}

.form-wrap input[type="text"], 
.form-wrap input[type="email"],
.form-wrap input[type="password"] {
  width: 100%;
  height: 50px;
  margin-bottom: 20px;
  padding: 15px;
  border: none;
  border-radius: 8px;
  box-shadow: 0 0 5px 0 rgba(0,0,0,.15);
  font-size: 16px;
  font-weight: 400;
}

.form-wrap button[type="submit"] {
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 8px;
  background-color: #3498db;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color .3s ease;
}

.form-wrap button[type="submit"]:hover {
  background-color: #2980b9;
}

四、form表單樣式

form表單是HTML中最基本的表單元素, HTML本身提供了大量的樣式控制屬性。可以在<form>標籤內部使用屬性來設置表單的背景顏色、字體顏色、邊框等樣式。下面是一個簡單的form表單樣式示例:

<form style="background-color: #f5f5f5; padding: 20px; border: 1px solid #ddd;">
  <div style="margin-bottom: 20px;">
    <label for="username" style="display: block;">Username</label>
    <input type="text" id="username" style="width: 100%; height: 30px; padding: 5px; border: none; border-radius: 5px; box-shadow: 0 0 5px 0 rgba(0,0,0,.2);">
  </div>
  <div style="margin-bottom: 20px;">
    <label for="password" style="display: block;">Password</label>
    <input type="password" id="password" style="width: 100%; height: 30px; padding: 5px; border: none; border-radius: 5px; box-shadow: 0 0 5px 0 rgba(0,0,0,.2);">
  </div>
  <button type="submit" style="display: block; width: 100%; height: 30px; background-color: #3498db; color: #fff; border: none; border-radius: 5px; cursor: pointer;">Submit</button>
</form>

五、好看的表單樣式

好看的表單樣式可以提高用戶的注意力和興趣,使得網站或應用程序更具有吸引力。一個好的表單樣式設計應該遵循視覺平衡、色彩搭配、元素呼應、簡潔明了等多個原則。下面是一個簡單、好看的表單樣式示例:

.form-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  background-color: #f5f5f5;
  padding: 40px;
  box-shadow: 0 0 10px 0 rgba(0,0,0,.2);
}

.header-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 40px;
}

.header-wrap img {
  width: 60px;
  height: 60px;
  margin-right: 20px;
}

.header-wrap h2 {
  font-size: 30px;
  font-weight: bold;
  color: #3498db;
}

.form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.form input[type="text"],
.form input[type="email"],
.form input[type="password"] {
  width: 100%;
  height: 50px;
  margin-bottom: 20px;
  padding: 15px;
  border: none;
  border-radius: 8px;
  box-shadow: 0 0 5px 0 rgba(0,0,0,.15);
  font-size: 16px;
  font-weight: 400;
}

.form button[type="submit"] {
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 8px;
  background-color: #3498db;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color .3s ease;
}

.form button[type="submit"]:hover {
  background-color: #2980b9;
}

六、表單css樣式

表單樣式可以使用CSS來進行控制,下面是一個使用CSS設置表單樣式的示例:

.form-wrap form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.form-wrap input[type="text"],
.form-wrap input[type="email"],
.form-wrap input[type="password"] {
  width: 100%;
  height: 50px;
  margin-bottom: 20px;
  padding: 15px;
  border: none;
  border-radius: 8px;
  box-shadow: 0 0 5px 0 rgba(0,0,0,.15);
  font-size: 16px;
  font-weight: 400;
}

.form-wrap button[type="submit"] {
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 8px;
  background-color: #3498db;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color .3s ease;
}

.form-wrap button[type="submit"]:hover {
  background-color: #2980b9;
}

七、css控制表單樣式

在CSS中,可以使用偽類選擇器來控制表單樣式,如:hover,:active,:focus等。下面是一個控制表單樣式的CSS示例:

.form-wrap input[type="text"]:focus,
.form-wrap input[type="email"]:focus,
.form-wrap input[type="password"]:focus {
  outline: none;
  box-shadow: 0 0 5px 0 rgba(0,0,0,.3);
}

.form-wrap button[type="submit"] {
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 8px;
  background-color: #3498db;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color .3s ease;
}

.form-wrap button[type="submit"]:hover {
  background-color: #2980b9;
}

.form-wrap button[type="submit"]:active {
  box-shadow: none;
  background-color: #217dbb;
}

八、表單的樣式

表單樣式包括表單元素的布局、字體、顏色、背景等方面的設置。好的表單樣式可以提高用戶體驗、增加用戶黏性,從而提升網站或應用程序的價值。下面是一個簡單的表單樣式示例:

.form-wrap {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
background-color: #f5f5f5;
padding: 40px;
box-shadow: 0 0 10px 0 rgba(0,0,0,.2);
}

.header-wrap {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 40px;
}

.header-wrap img {
width: 60px;
height: 60px;
margin-right: 20px;
}

.header-wrap h2 {
font-size: 30px;
font-weight: bold;
color: #3498db;
}

.form {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.form input[type="text"],
.form input[type="email"],
.form input[type="password"] {
width: 100%;
height: 50px;
margin-bottom: 20px;
padding: 15px;
border: none;
border-radius: 8px;
box-shadow: 0 0 5px 0 rgba(0,0,0,.15);
font-size: 16px;
font-weight: 400;
}

.form button[type="submit"] {
width: 100%;
height: 50px;
border: none;
border-radius: 8px;
background-color: #3498db;
color: #fff;
font-size: 18px;
font-weight: bold;
cursor: pointer;
transition: background-color .3s ease;
}

.form button[type="submit"]:hover {
background-color

原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/188821.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
小藍的頭像小藍
上一篇 2024-11-28 13:34
下一篇 2024-11-28 18:29

相關推薦

  • 如何使用HTML修改layui內部樣式影響全局

    如果您想要使用layui來構建一個美觀的網站或應用,您可能需要使用一些自定義CSS來修改layui內部組件的樣式。然而,修改layui組件的樣式可能會對整個頁面產生影響,甚至可能破…

    編程 2025-04-29
  • Java表單提交方式

    Java表單提交有兩種方式,分別是get和post。下面我們將從以下幾個方面詳細闡述這兩種方式。 一、get方式 1、什麼是get方式 在get方式下,表單的數據會以查詢字元串的形…

    編程 2025-04-27
  • JFXtras樣式——美化JavaFX應用的必備神器

    本文將從多個方面對JFXtras樣式進行詳細的闡述,教你如何使用JFXtras樣式來美化你的JavaFX應用。無需任何前置知識,讓我們一步步來了解。 一、簡介 JFXtras是一個…

    編程 2025-04-27
  • 如何優雅地改變滑鼠指針樣式

    我們在網頁設計中,經常會遇到需要改變滑鼠指針樣式的情況,比如當我們將滑鼠移動到一個鏈接上時,我們希望滑鼠指針變成手型,這時我們就需要用到改變滑鼠指針樣式的技巧。本文將從多個方面詳細…

    編程 2025-04-25
  • 全方位解析fomer——無需編寫HTML表單的前端庫

    一、什麼是fomer? fomer是一個基於React的前端庫,可以方便地創建表單。使用它,你不需要編寫HTML表單,只需要使用JavaScript以及一些CSS類名即可創建美麗的…

    編程 2025-04-25
  • 深入淺出:volidate表單驗證庫詳解

    表單驗證是Web開發中很重要的一部分,不僅能幫助我們輕鬆驗證所需要的輸入數據、保證數據的完整性和一致性,還能夠給用戶帶來更好的體驗。而volidate則是一款方便易用的表單驗證庫,…

    編程 2025-04-23
  • CSS URL編寫技巧:打造獨特的樣式鏈接

    在我們的網頁設計中,樣式鏈接(CSS URL)是一個非常重要的部分。它不僅可以讓我們的網頁變得更加美觀,還可以提高用戶的體驗。但是,如何打造獨特的樣式鏈接呢?本文將從以下幾個方面進…

    編程 2025-04-23
  • Vue表單提交實踐與總結

    一、vue提交表單沒反應 1、檢查表單是否綁定到正確的數據 <form v-on:submit.prevent=”submitForm”> <!– … –…

    編程 2025-04-23
  • CSS行內樣式詳解

    一、概述 CSS(Cascading Style Sheets)是一種用於描述文檔展示樣式的語言。在網頁製作中,CSS樣式是不可或缺的一部分。CSS有三種使用方式:行內、內嵌和外部…

    編程 2025-04-22
  • 如何使用CSS的nth-last-child選擇器進行網頁元素樣式的控制

    CSS是一個強大的網頁樣式描述語言,對於網頁的布局和樣式有著非常重要的作用。而選擇器是CSS中最重要的部分之一,通過不同的選擇器,我們可以對網頁中的元素進行特定的選擇和樣式控制。其…

    編程 2025-04-18

發表回復

登錄後才能評論