炫酷的CSS3响应式表单

原创[email protected] Online Tutorials


css代码:

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #03080a;
}

.container {
    width: 80%;
    padding: 20px;
}

.container h2 {
    width: 100%;
    color: #45f3ff;
    font-size: 36px;
    text-align: center;
    margin-bottom: 10px;
}

.container .row100 {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.container .row100 .col {
    position: relative;
    width: 100%;
    padding: 0 10px;
    margin: 30px 0 10px;
    transition: 0.5s;
}

.container .row100 .inputBox {
    position: relative;
    width: 100%;
    height: 40px;
    color: #45f3ff;
}

.container .row100 .inputBox input,
.container .row100 .inputBox textarea {
    position: absolute;
    width: 100%;
    height: 100%;
    background: transparent;
    box-shadow: none;
    border: none;
    outline: none;
    font-size: 18px;
    padding: 0 10px;
    z-index: 1;
    color: #000;
}

.container .row100 .inputBox .text {
    position: absolute;
    top: 0;
    left: 0;
    line-height: 40px;
    font-size: 18px;
    padding: 0 10px;
    display: block;
    transition: 0.5s;
    pointer-events: none;
}

.container .row100 .inputBox input:focus+.text,
.container .row100 .inputBox input:valid+.text {
    top: -35px;
    left: -10px;
}

.container .row100 .inputBox .line {
    position: absolute;
    bottom: 0;
    display: block;
    width: 100%;
    height: 2px;
    background-color: #45f3ff;
    transition: 0.5s;
    border-radius: 2px;
    pointer-events: none;
}

.container .row100 .inputBox input:focus~.line,
.container .row100 .inputBox input:valid~.line {
    height: 100%;
}

.container .row100 .inputBox .textarea {
    position: relative;
    width: 100%;
    height: 100px;
    padding: 10px 0;
}

.container .row100 .inputBox textarea {
    height: 100%;
    resize: none;
    /* background-color: #000; */
}

.container .row100 .inputBox textarea:focus+.text,
.container .row100 .inputBox textarea:valid+.text {
    top: -35px;
    left: -10px;
}

.container .row100 .inputBox textarea:focus~.line,
.container .row100 .inputBox textarea:valid~.line {
    height: 100%;
}

input[type="submit"] {
    border: none;
    padding: 7px 35px;
    cursor: pointer;
    /* outline設置边框样式 */
    outline: none;
    background-color: #45f3ff;
    color: #000;
    font-size: 18px;
    border-radius: 2px;
}

html源码:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="index.css">
</head>

<body>
    <div class="container">
        <h2>Contact Us</h2>
        <div class="row100">
            <div class="col">
                <div class="inputBox">
                    <input type="text" required="required">
                    <span class="text">First Name</span>
                    <span class="line"></span>
                </div>
            </div>
            <div class="col">
                <div class="inputBox">
                    <input type="text" required="required">
                    <span class="text">Last Name</span>
                    <span class="line"></span>
                </div>
            </div>
        </div>
        <div class="row100">
            <div class="col">
                <div class="inputBox">
                    <input type="text" required="required">
                    <span class="text">Email</span>
                    <span class="line"></span>
                </div>
            </div>
            <div class="col">
                <div class="inputBox">
                    <input type="text" required="required">
                    <span class="text">Mobile</span>
                    <span class="line"></span>
                </div>
            </div>
        </div>
        <div class="row100">
            <div class="col">
                <div class="inputBox textarea">
                    <textarea required="required"></textarea>
                    <span class="text">Type your message Here...</span>
                    <span class="line"></span>
                </div>
            </div>
        </div>
        <div class="row100">
            <div class="col">
                <input type="submit" value="Send">
            </div>
        </div>
    </div>
</body>

</html>

效果展示:


  • 自适应效果:

原文地址:https://www.cnblogs.com/AhuntSun-blog/p/12021798.html

时间: 2024-11-08 16:45:31

炫酷的CSS3响应式表单的相关文章

ng2响应式表单-翻译与概括官网REACTIVE FORMS页面

本文将半翻译半总结的讲讲ng2官网的另一个未翻译高级教程页面. 原文地址. 文章目的是使用ng2提供的响应式表单技术快速搭出功能完善丰富的界面表单组件. 响应式表单是一项响应式风格的ng2技术,本文将解释响应式表单并用来创建一个英雄详情编辑器. 包含内容: 响应式表单介绍 开始搭建 创建数据模型 创建响应式的表单组件 创建组建的模板文件 引入ReactiveFormsModule 显示HeroDetailComponent 添加一个FormGroup 看看表单模型 介绍FormBuilder 验

angular 使用bootstratp模态框+响应式表单+响应式表单的验证+子窗关闭父窗口刷新

This is quite big project today 这次有以下几个功能: 1.ng-bootstrap模态框 2.响应式表单 3.响应式表单的验证 4.子窗关闭父窗口刷新 其实这几个哪一个都能写一个话题,事情太多了,时间紧任务重,一起写了吧: ng-bootstrap模态框所需要的条件(very very important),如果写错,查错非常的难哦,请慎重[反正我看不懂错误提示,出个错解决老办天]. 1.package.json加入dependencies: "@ng-boots

动态增加响应式表单

页面文件: <form *ngFor="let form of list" [formGroup]="form"> <div class="form-group"> <label>姓名:</label> <input style="color: #000;" type="text" formControlName="name">

BootStrap响应式表单

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <!--以移动设备为优先,user-scalable=no禁止用户缩放--> <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no&qu

angular6 响应式表单(登录实例)

一.表单验证 1. 只有一个验证规则: this.myGroup = this.fb.group({ email:['[email protected]',Validators.required], password:[''] }) 2. 有多个验证的时候: email:['[email protected]',Validators.compose([Validators.required,Validators.email])], 3. 有多个验证的时候,并且有自定义验证规则的: 1 ngOnI

Html5添加超酷响应式表单美化模板插件教程

一.Html结构 <form class="cbp-mc-form"> <div class="cbp-mc-column"> <label for="first_name">First Name</label> <input type="text" id="first_name" name="first_name" placehol

angular 响应式表单

原文地址:https://www.cnblogs.com/chenyishi/p/8951712.html

获取响应式表单FormGroup里的formControl对象示例

获取FormGroup里的FormControl对象,通过FormGroup对象的get("FormControlName 名") 示例: 在根模块导入 import { ReactiveFormsModule } from '@angular/forms'; @NgModule({ declarations: [ AppComponent, HeroFormComponent, FormcontrolComponent ], imports: [ BrowserModule, App

angular 响应式表单指令

响应式表单都是以 form开头的指令 第一列指令(不以name结尾)在html模版中,用 [ ] 第二列指令(以name结尾)在html模版中,不用 [ ] 原文地址:https://www.cnblogs.com/jasonlai2016/p/9747182.html