好看的 input 编辑框

2021-11-24 11:16:29 浏览数 (1)

开始

效果图

代码 html部分

代码语言:javascript复制
<div class="inputDiv">
    <input type="text" name="id" required>
    <span class="inputText">账号</span>
</div>
<div class="inputDiv">
    <input type="password" name="password" required>
    <span class="inputText">密码</span>
    <input type="submit" value="登录" name="inputSubmit" class="inputSubmit">
</div>

css部分

代码语言:javascript复制
div.inputDiv {
    width: 80%;
    margin: 0 auto;
    position: relative;
    padding: 20px 0 0 0;
}

div.inputDiv input {
    border: none;
    background-color: transparent;
    border-bottom: 2px solid #dddddd;
    -webkit-tap-highlight-color: transparent;
    padding: 10px;
    outline: none;
    width: 100%;
} div.inputDiv input:focus ~ span.inputText, div.inputDiv input:valid ~ span.inputText {
    top: 0;
    transition: all 100ms linear;
    color: #4444ff;
} div.inputDiv input:focus, div.inputDiv input:valid {
    border-bottom: 2px solid #4444ff;
}

div.inputDiv span.inputText {
    position: absolute;
    font-weight: 200;
    top: 20px;
    left: 10px;
    transition: all 100ms linear;
}

div.inputDiv input.inputSubmit {
    width: 100%;
    display: inline-block;
    margin-top: 10px;
    padding: 10px 10px;
    font-weight: 200;
    /* background-color: #5050ff; */
    color: #000000;
    text-align: center;
    cursor: pointer;
    /* position: absolute; */
    /* right: 0; */
    -webkit-tap-highlight-color: transparent;
    border-bottom: none;
    font-size: 18px;
}

0 人点赞