---恢复内容开始---

<!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>

---恢复内容结束---

<!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>