通過之前的內容學習了HTML和CSS基礎知識之後,我們就可以上手寫一些”徒有其表“的網頁了~在這個過程中,我們可以參考別人的網頁設計和代碼,多多學習總結。
下面是一個登陸界面的代碼,來自 黑子Kuroko,網頁製作:一個簡易美觀的登錄界面。代碼不多,但是效果還挺好看的,我把其中的HTML和CSS代碼寫了比較詳細的註釋。
做出來的效果是這樣的:
HTML部分:
CSS部分:
/*主體部分*/
body {
background-image: url("images/login/loginBac.jpg");; /*設置背景圖片*/
background-size: 100%; /*設置圖片大小充滿全部界面*/
background-repeat: no-repeat; /*平鋪設置*/
}
/*login_frame,用於容納登錄功能界面*/
#login_frame {
width: 400px; /*設置尺寸*/
height: 260px;
padding: 13px;
position: absolute; /*設置位置*/
left: 50%;
top: 50%;
margin-left: -200px;
margin-top: -200px;
background-color: rgba(240, 255, 255, 0.5); /*設置背景顏色*/
border-radius: 10px; /*設置圓角*/
text-align: center;
}
/*子元素選擇器*/
form p > * {
display: inline-block;
vertical-align: middle;
}
/*image_logo,用於展示logo*/
#image_logo {
margin-top: 22px;
}
/*設置標籤樣式*/
.label_input {
font-size: 14px;
font-family: 宋體;
width: 65px;
height: 28px;
line-height: 28px;
text-align: center;
color: white;
background-color: #3CD8FF;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
/*設置輸入樣式*/
.text_field {
width: 278px;
height: 28px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border: 0;
}
/*設置btn_login*/
#btn_login {
font-size: 14px;
font-family: 宋體;
width: 120px;
height: 28px;
line-height: 28px;
text-align: center;
color: white;
background-color: #3BD9FF;
border-radius: 6px;
border: 0;
float: left;
}
/*設置forget_pwd和僞類*/
#forget_pwd {
font-size: 12px;
color: white;
text-decoration: none;
position: relative;
float: right;
top: 5px;
}
#forget_pwd:hover {
color: blue;
text-decoration: underline; /*下劃線*/
}
#login_control {
padding: 0 28px;
}
希望大家也能寫出棒棒的網頁~撒花~
之後在更新更多代碼分析吧~