国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > CSS > 正文

CSS3代碼實(shí)例:CSS3制作網(wǎng)頁登陸表單

2024-07-11 09:01:31
字體:
供稿:網(wǎng)友

武林網(wǎng)(www.survivalescaperooms.com)文章簡介:這個(gè)表單效果是很普通,但其制作采用的方法卻很有創(chuàng)新,其中用到老技術(shù)的是@font-face制作icon、box-shadow制作陰影等,最亮點(diǎn)是使用了calc()函數(shù)來計(jì)算定位的值。

這個(gè)表單效果是很普通,但其制作采用的方法卻很有創(chuàng)新,其中用到老技術(shù)的是@font-face制作icon、box-shadow制作陰影等,最亮點(diǎn)是使用了calc()函數(shù)來計(jì)算定位的值。這可是一種新玩法,雖然前面有介紹過這個(gè)屬性的使用方法,后期的制作中卻很少使用他,這個(gè)案例讓我再次領(lǐng)略了calc()函數(shù)的功能。如果你喜歡,也可以嘗試一下,自己動手豐衣足食。

HTML結(jié)構(gòu)

表單的結(jié)構(gòu)層出不窮,但我更喜歡Bootstrap中表單的結(jié)構(gòu),當(dāng)然這個(gè)例子中白牙同學(xué)是沒使用那種結(jié)構(gòu),但也是很清晰,也很簡單:

<form action="" method="post" class="login-form">
  <div class="username">
    <input type="text" name="username" placeholder="emma.watson@gmail.com" autocomplete="on" />
    <span class="user-icon icon">u</span>
  </div>
  <div class="password">
    <input type="password" name="password" placeholder="*******" />
    <span class="password-icon icon">p</span>
  </div>
  <div class="account-control">
    <input type="checkbox" name="Remember me" id="Remember me" value="Remember me" checked="checked" />
    <label for="Remember me" data-on="c" class="check"></label>
    <label for="Remember me" class="info">Remember me</label>
    <button type="submit">Login</button>
  </div>
  <p class="not-registered">Not a registered user yet?<a>Sign up now!</a></p>
</form>
CSS代碼

常用到的樣式代碼就不另外單獨(dú)介紹了,具體的可以參考樣式代碼中的注解:

/*基本樣式*/
body {
  background: url(bg.jpg) no-repeat center fixed;
  background-size: 100% 100%;/*讓背景圖全屏顯示,常用來制作全屏背景*/
}
.content {
  width:600px;
  height:420px;
  margin:50px auto;
}
/*登錄表單form樣式*/
.login-form {
  width:400px;
  height:177px;
  margin:70px auto 0;
  padding-top:73px;
  position:relative;/*為用戶頭像定位做一個(gè)參照點(diǎn)*/
  background-image:-*-linear-gradient(top,rgb(255,255,255),rgb(242,242,242));/*漸變效果制作*/
  box-shadow:0 3px 3px rgba(21,62,78,0.8);/*陰影效果實(shí)現(xiàn)*/
}
/*使用偽類制作用戶頭像效果*/
.login-form:before {
  content:"";
  position:absolute;
  top:-50px;
  left:150px;
  width:102px;
  height:102px;
  padding:2px;
  border:1px solid rgb(216,216,219);
  background:#fff url("profilepicture.jpg") no-repeat 2px 2px;/*加載用戶頭像*/
}
/*注冊提示信息*/
.not-registered {
  position:absolute;
  color:rgb(153,153,153);
  font-weight:bold;
  top:calc(100% + 20px);/*相當(dāng)于bottom:-66px(div.not-registered自身的高度46px加上向下移動的20px)*/
  background-color:rgb(255,255,255);
  width:400px;
  height:46px;
  margin:0 auto;
  line-height:46px;
  text-align: center;
  box-shadow:0 3px 3px rgba(21,62,78,0.8);
}
.not-registered a {
  margin-left:5px;
  text-decoration: none;
  color:rgb(52,119,182);
  cursor: pointer;
}
/*表單內(nèi)部元素樣式設(shè)置*/
.login-form div {
  width:216px;
  height:28px;
  margin:20px auto;
  position:relative;
  line-height:28px;
  border:none;
}
/*用戶和密碼的icon制作*/
.login-form .user-icon,
.login-form .password-icon {
  display:inline-block;
  font-family: 'loginform-icon';
  font-size:15px;
  text-align:center;
  line-height:28px;
  color:rgb(153,153,153);
  position:absolute;
  left:1px;
  top:1px;
  background-color:rgb(255,255,255);
  border:none;
  border-right:1px solid rgb(229,229,232);
  width:30px;
  height:28px;
  transition: all 300ms linear;
}
/*表單input的樣式*/
.login-form .username input, .login-form .password input {
  height:100%;
  width:calc(100% - 40px);/*使用calc計(jì)算表單的寬度(其中40px是用來放icon的空間)*/
  padding-left:40px;
  border-radius:2px;
  border:1px solid;
  border-color:rgb(229,229,232) rgb(220,220,221) rgb(213,213,213) rgb(220,220,221);
  display:block;
  transition: all 300ms linear;
}
/*使用偽類制作三角效果*/
.login-form .icon:before, .login-form .icon:after {
  content:"";
  position:absolute;
  top:10px;
  left:30px;
  width:0;
  height:0;
  border:4px solid transparent;
  border-left-color:rgb(255,255,255);
}
.login-form .icon:before {
  top:9px;
  border:5px solid transparent;
  border-left-color:rgb(229,229,232);
}
/*表單焦點(diǎn)狀態(tài)下效果*/
.login-form .username input:focus, .login-form .password input:focus {
  border-color:rgb(69,153,228);
  box-shadow:0 0 2px 1px rgb(200,223,244);
}
.login-form .username input:focus + span, .login-form .password input:focus + span {
  background:-*-linear-gradient(top,rgb(255,255,255),rgb(245,245,245));
  color:rgb(51,51,51);
}
.login-form .username input:focus + span:after, .login-form .password input:focus + span:after {
  border-left-color:rgb(250,250,250);
}.login-form .account-control label {
  margin-left:24px;
  font-size:12px;
  font-family: Arial, Helvetica, sans-serif;
  cursor:pointer;
}
/*按鈕效果*/
.login-form button[type="submit"] {
  color:#fff;
  font-weight:bold;
  float:right;
  width:68px;
  height:30px;
  position:relative;
  background:-*-linear-gradient(top,rgb(74,162,241),rgb(52,119,182)) 1px 0 no-repeat,
       -*-linear-gradient(top,rgb(52,118,181),rgb(36,90,141)) left top no-repeat;
  background-size:66px 28px,68px 29px;
  border:none;
  border-top:1px solid rgb(52,118,181);
  border-radius:2px;
  box-shadow:inset 0 1px 0 rgb(86,174,251);
  text-shadow:0 1px 1px rgb(51,113,173);
  transition: all 200ms linear;
}
.login-form button[type="submit"]:hover {
  text-shadow:0 0 2px rgb(255,255,255);
  box-shadow:inset 0 1px 0 rgb(86,174,251),0 0 10px 3px rgba(74,162,241,0.5);
}
.login-form button[type="submit"]:active {
  background:-*-linear-gradient(top,rgb(52,119,182),rgb(74,162,241)) 1px 0 no-repeat,
       -*-linear-gradient(top,rgb(52,118,181),rgb(36,90,141)) left top no-repeat;
}
/*自定義復(fù)選框效果*/
.login-form .account-control input {
  width:0px;
  height:0px;
}
.login-form label.check {
  position:absolute;
  left:0;
  top:50%;
  margin:-8px 0;
  display:inline-block;
  width:16px;
  height:16px;
  line-height: 16px;
  text-align:center;
  border-radius:2px;
  background:-*-linear-gradient(top,rgb(255,255,255),rgb(246,246,246)) 1px 1px no-repeat,
       -*-linear-gradient(top,rgb(227,227,230),rgb(165,165,165)) left top no-repeat;
  background-size:14px 14px,16px 16px;
}
.login-form .account-control input:checked + label.check:before {
  content:attr(data-on);
  font-family:loginform-icon;
}
/*調(diào)用服務(wù)器字體*/
@font-face {
  font-family: 'loginform-icon';
  src: url("font/loginform-icon.eot");
  src: url("font/loginform-icon.eot?#iefix") format('embedded-opentype'),
    url("font/loginform-icon.woff") format('woff'),
    url("font/loginform-icon.ttf") format('truetype'),
    url("font/loginform-icon.svg#loginform-icon") format('svg');
  font-weight: normal;
  font-style: normal;
}

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 上蔡县| 都江堰市| 竹北市| 抚远县| 穆棱市| 鲜城| 泸西县| 伊宁县| 固始县| 贵州省| 河源市| 呼玛县| 桂阳县| 霞浦县| 富锦市| 马公市| 纳雍县| 保康县| 如东县| 娱乐| 封丘县| 二连浩特市| 平武县| 天峨县| 芮城县| 项城市| 新兴县| 昌黎县| 上虞市| 美姑县| 塔城市| 青铜峡市| 集安市| 缙云县| 宁国市| 澳门| 四平市| 扶沟县| 崇信县| 阳曲县| 涡阳县|