1-美化表单样式

1-表单样式效果
1-美化表单样式_第1张图片
1-美化表单样式_第2张图片
2-表单样式实现

html文件


<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="./css/style.css" />
    <title>Beautiful Formtitle>
  head>
  <body>
    <div class="input-wrapper">
      <div class="title">Beautiful Formdiv>
      <div class="input-data">
        <input type="text" required />
        <label>Namelabel>
        <div class="underline">div>
      div>
      <div class="input-data">
        <input type="text" required />
        <label>Schoollabel>
        <div class="underline">div>
      div>
      <div class="input-data">
        <input type="text" required />
        <label>Addresslabel>
        <div class="underline">div>
      div>
      <div class="input-data">
        <input type="text" required />
        <label>Emaillabel>
        <div class="underline">div>
      div>
      <div class="input-submit">
        <input type="button" value="Submit" />
      div>
    div>
  body>
html>

css文件

* {
  padding: 0;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  outline: none;
}
body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(-135deg, #c850c0, #4158d0);
}
.input-wrapper {
  width: 450px;
  padding: 30px;
  background-color: rgb(255, 255, 255);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.title{
  text-align: center;
  color: silver;
  font-size: 24px;
  text-transform: uppercase;
}
.input-data {
  position: relative;
  width: 100%;
  height: 40px;
  margin-top: 20px;
}
.input-data input {
  width: 100%;
  height: 100%;
  border: none;
  border-bottom: 2px solid silver;
  font-size: 17px;
}
.input-data input:focus ~ label,
.input-data input:valid ~ label {
  transform: translateY(-20px);
  color: #a952c4;
}
.input-data .underline {
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: #6b55cb;
  transition: all 0.3s ease;
  transform: scale(0);
}

.input-data input:focus ~ .underline {
  transform: scale(1);
}
.input-data label {
  position: absolute;
  left: 0;
  bottom: 10px;
  color: gray;
  pointer-events: none;
  transition: all 0.3s ease;
}

.input-wrapper .input-submit {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 80px;
}

.input-wrapper .input-submit input {
  padding: 10px 20px;
  border-radius: 50px;
  border: none;
  color: white;
  background: linear-gradient(-135deg, #c850c0, #4158d0);
}

你可能感兴趣的:(样式Demo)