最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

【源碼】有點(diǎn)小酷的input輸入框動(dòng)畫(huà)

2022-04-27 21:41 作者:艾恩小灰灰  | 我要投稿

HTML5+CSS3實(shí)現(xiàn)有點(diǎn)小酷的input輸入框動(dòng)畫(huà),帶動(dòng)畫(huà)的輸入框,總是讓人忍不住去點(diǎn)它。

先看效果:

源代碼:

HTML

<div class="wrapper">
 ?<div class="input-data">
 ? ?<input type="text" required>
 ? ?<div class="underline"></div>
 ? ?<label>您的姓名</label>
 ?</div>
</div>

CSS

*{
 ? ?margin: 0;
 ? ?padding: 0;
 ? ?outline: none;
 ? ?/* 這個(gè)是告訴瀏覽器:你想要設(shè)置的邊框和內(nèi)邊距的值是包含在總寬高內(nèi)的 */
 ? ?box-sizing: border-box;
}
body{
 ? ?/* 彈性布局 水平垂直居中 */
 ? ?display: flex;
 ? ?align-items: center;
 ? ?justify-content: center;
 ? ?/* 設(shè)置body最小高度為100%窗口高度 */
 ? ?min-height: 100vh;
 ? ?/* 漸變背景 */
 ? ?background: linear-gradient(200deg,#0c3483,#a2b6df);
}
.wrapper{
 ? ?width: 450px;
 ? ?background-color: #fff;
 ? ?/* 內(nèi)邊距(上下左右) */
 ? ?padding: 40px;
 ? ?/* 盒子陰影 */
 ? ?box-shadow: 0px 0px 10px rgba(0,0,0,0.1);
 ? ?border-radius: 8px;
}
.wrapper .input-data{
 ? ?/* 相對(duì)定位 */
 ? ?position:relative;
 ? ?width: 100%;
 ? ?height: 40px;
}
.wrapper .input-data input{
 ? ?width: 100%;
 ? ?height: 100%;
 ? ?border:none;
 ? ?font-size: 17px;
 ? ?border-bottom: 2px solid #c0c0c0;
}
/* 輸入框獲得焦點(diǎn)時(shí) */
.wrapper .input-data input:focus ~ label,
/* 輸入框的值為合法時(shí) */
.wrapper .input-data input:valid ~ label{
 ? ?/* label上移,同時(shí)改變字號(hào)、顏色 */
 ? ?transform: translateY(-25px);
 ? ?font-size: 15px;
 ? ?color: #2c6fdb;
}
.wrapper .input-data label{
 ? ?position: absolute;
 ? ?bottom:10px;
 ? ?left: 0px;
 ? ?color: #808080;
 ? ?/* 點(diǎn)擊label可以穿透到輸入框 */
 ? ?pointer-events: none;
 ? ?/* 給動(dòng)畫(huà)添加過(guò)渡,不會(huì)太過(guò)生硬 */
 ? ?transition: all 0.3s ease;
}
.wrapper .input-data .underline{
 ? ?position: absolute;
 ? ?bottom: 0px;
 ? ?height: 2px;
 ? ?width: 100%;
 ? ?background-color: #2c6fdb;
 ? ?/* 沿X軸放大 */
 ? ?transform: scaleX(0);
 ? ?/* 動(dòng)畫(huà)過(guò)渡 */
 ? ?transition: all 0.3s ease;
}
.wrapper .input-data input:focus ~ .underline,
.wrapper .input-data input:valid ~ .underline{
 ? ?/* 沿X軸縮小 */
 ? ?transform: scaleX(1);
}


【源碼】有點(diǎn)小酷的input輸入框動(dòng)畫(huà)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
本溪市| 思茅市| 景宁| 金门县| 东平县| 鄂托克前旗| 南岸区| 黄石市| 漳浦县| 马龙县| 湛江市| 青田县| 裕民县| 溆浦县| 苏州市| 正镶白旗| 永德县| 德兴市| 尚义县| 开阳县| 祁门县| 峨眉山市| 云安县| 镇赉县| 文昌市| 扎兰屯市| 丹巴县| 阿巴嘎旗| 苏州市| 九江市| 萨迦县| 西丰县| 郴州市| 泽库县| 绥棱县| 南漳县| 云龙县| 舒兰市| 湖北省| 嵊州市| 临邑县|