码迷,mamicode.com
首页 > 其他好文 > 详细

form表单

时间:2018-09-17 00:01:09      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:classname   line   isp   like   cti   eset   das   font   method   

<!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>from</title>
</head>
<style>
    form{
        width: 700px;
        margin: 0 auto;
    }
    h1{
        text-align: center;
    }
    .asd{
        width: 80%;
    }
    .asd span{
        width: 80px;
        display: inline-block;
        text-align: right;
        margin: 10px 0;
    }
    .headImg{
        display: none;
        width: 200px;
    }
    .sub{
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: aquamarine;
        height: 60px;
        border-radius: 5px;
        box-shadow: 2px 2px 4px #888;
    }
    .sub .btn{
        background-color: #4CAF50; 
        border-radius: 20px;
        border: none;
        color: white;
        padding: 15px 32px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 16px;
        margin: 4px 2px;
        cursor: pointer;
    }
</style>
<body>
    <form action="" method="post">
        <h1>个人信息</h1>
        <div class="asd">
            <span>姓名:</span><input type="text" name="xingming">
        </div>
        <div class="asd">
            <span>电话号码:</span><input type="tel" name="tel" id="">
        </div>
        <div class="asd">
            <span>邮箱:</span><input type="email" name="email" id="">
        </div>
        <div class="asd">
            <span>生日:</span><input type="date" name="bir" id="">
        </div>
        <div class="asd">
            <span>个性签名:</span><input type="text" name="sign">
        </div>
        <div class="asd">
            <span>性别:</span><input type="radio" name="six"><input type="radio" name="six">
        </div>
        <div class="asd">
            <span>爱好:</span>
            篮球<input type="checkbox" name="like" id="">
            足球<input type="checkbox" name="like" id="">
            羽毛球<input type="checkbox" name="like" id="">
            乒乓球<input type="checkbox" name="like" id="">
        </div>
        <div class="asd">
            <span>喜欢的颜色:</span><input type="color" name="color" id="">
        </div>
        <div class="asd">
            <span>上传头像:</span><input id="files" type="file" name=""><img class="headImg" src="" alt="">
        </div>
        <div class="sub">
            <input class="btn" type="submit" value="提交">
            <input class="btn" type="reset" value="重置">
        </div>
    </form>
    <script>
        var f = document.getElementById(files)
        var img = document.getElementsByClassName(headImg)[0]
        f.onchange = function () {
            var files = f.files,
                reader = new FileReader();
            if(files && files[0]){
                reader.onload = function (ev) {
                    img.src = ev.target.result;
                }
                reader.readAsDataURL(files[0]);
                img.style.display = inline-block
            }
        }
    </script>
</body>
</html>

 

form表单

标签:classname   line   isp   like   cti   eset   das   font   method   

原文地址:https://www.cnblogs.com/curtain473/p/9657929.html

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 mamicode.com 版权所有 京ICP备13008772号-2
迷上了代码!