input样式美化

1.checkbox样式优化
效果图如下:
在这里插入图片描述

代码如下:

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>checkbox美化</title>
</head>
<style type="text/css">
    /*input框中颜色更改*/
    .divBox{
        display: flex;
    }
    .iconColor{
        width: 80px;
        height: 80px;
        position: relative;
    }
    #color-input-red+label {
        display: block;
        width: 20px;
        height: 20px;
        cursor: pointer;
        position: absolute;
        border-radius: 4px;
        border:1px solid rgba(240, 84, 77, 1);
        top: 0;
        left: 0;
        background: white;
    }

    #color-input-red:checked+label::before {
        display: block;
        content: "\2714";
        text-align: center;
        font-size: 16px;
        color: rgba(240, 84, 77, 1);
    }

    input[type=checkbox] {
        visibility: hidden;
    }

    #color-input-orange+label {
        display: block;
        width: 20px;
        height: 20px;
        border-radius: 4px;
        cursor: pointer;
        position: absolute;
        top: 0;
        left: 0;
        background: rgba(234, 152, 54, 1);
    }

    #color-input-orange:checked+label::before {
        display: block;
        content: "\2714";
        text-align: center;
        font-size: 16px;
        color: white;
    }

    #color-input-yellow+label {
        display: block;
        width: 20px;
        height: 20px;
        cursor: pointer;
        position: absolute;
        top: 0;
        left: 0;
        background: rgba(230, 192, 58, 1);
    }

    #color-input-yellow:checked+label::before {
        display: block;
        content: "\2714";
        text-align: center;
        font-size: 16px;
        color: white;
    }

    #color-input-green+label {
        display: block;
        width: 20px;
        height: 20px;
        cursor: pointer;
        position: absolute;
        top: 0;
        left: 0;
        background: rgba(95, 189, 65, 1);
    }

    #color-input-green:checked+label::before {
        display: block;
        content: "\2714";
        text-align: center;
        font-size: 16px;
        color: white;
    }

    #color-input-blue+label {
        display: block;
        width: 20px;
        height: 20px;
        cursor: pointer;
        position: absolute;
        top: 0;
        left: 0;
        background: rgba(61, 170, 230, 1);
    }

    #color-input-blue:checked+label::before {
        display: block;
        content: "\2714";
        text-align: center;
        font-size: 16px;
        color: white;
    }

    #color-input-purple+label {
        display: block;
        width: 20px;
        height: 20px;
        cursor: pointer;
        position: absolute;
        top: 0;
        left: 0;
        background: rgba(195, 122, 211, 1);
    }

    #color-input-purple:checked+label::before {
        display: block;
        content: "\2714";
        text-align: center;
        font-size: 16px;
        color: white;
    }
</style>

<body>
    <div class="chat-windows-color-div">
        <div class="divBox">
            <div class="iconColor">
                <input id="color-input-red" class="chat-button-location-radio-input" type="checkbox" name="color-input-red"
                    value="#f0544d" />
                <label for="color-input-red"></label>
            </div>
            <div class="iconColor">
                <input id="color-input-orange" class="chat-button-location-radio-input" type="checkbox" name="color-input-orange"
                    value="#ea9836" />
                <label for="color-input-orange"></label>
            </div>

            <div class="iconColor">
                <input id="color-input-yellow" class="chat-button-location-radio-input" type="checkbox" name="color-input-yellow"
                    value="#e6c03a" />
                <label for="color-input-yellow"></label>
            </div>
            <div class="iconColor">
                <input id="color-input-green" class="chat-button-location-radio-input" type="checkbox" name="color-input-green"
                    value="#5fbd41" />
                <label for="color-input-green"></label>
            </div>
            <div class="iconColor">
                <input id="color-input-blue" class="chat-button-location-radio-input" type="checkbox" name="color-input-blue"
                    value="#3daae6" />
                <label for="color-input-blue"></label>
            </div>
            <div class="iconColor">
                <input id="color-input-purple" class="chat-button-location-radio-input" type="checkbox" name="color-input-purple"
                    value="#c37ad3" />
                <label for="color-input-purple"></label>
            </div>
        </div>
    </div>
</body>

</html>

2.input[type=file] 样式美化
效果图如下:
在这里插入图片描述

代码如下:

<style>
   .a-upload {
    padding: 4px 10px;
    height: 20px;
    line-height: 20px;
    position: relative;
    cursor: pointer;
    color: #888;
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    *display: inline;
    *zoom: 1
}

.a-upload  input {
    position: absolute;
    font-size: 100px;
    right: 0;
    top: 0;
    opacity: 0;
    filter: alpha(opacity=0);
    cursor: pointer
}

.a-upload:hover {
    color: #444;
    background: #eee;
    border-color: #ccc;
    text-decoration: none
}
.file {
    position: relative;
    display: inline-block;
    background: #D0EEFF;
    border: 1px solid #99D3F5;
    border-radius: 4px;
    padding: 4px 12px;
    overflow: hidden;
    color: #1E88C7;
    text-decoration: none;
    text-indent: 0;
    line-height: 20px;
}
.file input {
    position: absolute;
    font-size: 100px;
    right: 0;
    top: 0;
    opacity: 0;
}
.file:hover {
    background: #AADFFD;
    border-color: #78C3F3;
    color: #004974;
    text-decoration: none;
}
</style>
 <a href="javascript:;" class="a-upload">
       <input type="file" name="" id="">点击这里上传文件
  </a>
            
 <a href="javascript:;" class="file">选择文件
    <input type="file" name="" id="">
 </a>

3.input[type=radio]的样式美化
效果图如下:
在这里插入图片描述
代码如下

<div>
        <p style="font-size:18px;margin-top:30px;color:rgba(0,0,0,0.44)">对吗?</p>
        <label class="demo--label">
            <input class="demo--radio" type="radio" name="demo-radio">
            <span class="demo--radioInput"></span>对
        </label>
        <label class="demo--label">
            <input class="demo--radio" type="radio" name="demo-radio">
            <span class="demo--radioInput"></span>不对
        </label>
    </div>
    <div>
        <p style="font-size:18px;margin-top:30px;color:rgba(0,0,0,0.44)">你喜欢的是?</p>
        <label class="demo--label"><input class="demo--radio" type="checkbox" name="demo-checkbox1">
            <span class="demo--checkbox demo--radioInput"></span>A
        </label>
        <label class="demo--label">
            <input class="demo--radio" type="checkbox" name="demo-checkbox2">
            <span class="demo--checkbox demo--radioInput"></span>B
        </label>
        <label class="demo--label">
            <input class="demo--radio" type="checkbox" name="demo-checkbox3">
            <span class="demo--checkbox demo--radioInput"></span>C
        </label>
    </div>
 <style>
.demo--label{margin:20px 20px 0 0;display:inline-block}
.demo--radio{display:none}
.demo--radioInput{background-color:#fff;border:1px solid rgba(0,0,0,0.15);border-radius:100%;display:inline-block;height:16px;margin-right:10px;margin-top:-1px;vertical-align:middle;width:16px;line-height:1}
.demo--radio:checked + .demo--radioInput:after{background-color:#57ad68;border-radius:100%;content:"";display:inline-block;height:12px;margin:2px;width:12px}
.demo--checkbox.demo--radioInput,.demo--radio:checked + .demo--checkbox.demo--radioInput:after{border-radius:0}
</style>

4.input[type=text]的样式美化
效果图如下:
在这里插入图片描述

代码如下:

<input type="text" class="form_input" placeholder="请输入姓名" />
<style>
        input{

            font-size:12px;
             /* 设置输入框中字体的大小 */

            height:30px; 
            /* 设置输入框的高度 */

            border-radius:4px; 
            /* 设置输入框的圆角的大小 */

            border:1px solid #c8cccf;
            /* 设置输入框边框的粗细和颜色 */

            color:#986655; 
            /* 设置输入框中文字的颜色 */

            outline:0; 
            /* 将输入框点击的时候出现的边框去掉 */

            text-align:left; 
            /* 设置输入框中文字的位置 */

            padding-left: 10px;

            display:block; 
            /* 将输入框设置为块级元素 */

            cursor: pointer;

             box-shadow: 2px 2px 5px 1px #ccc;  

            }

         input::-webkit-input-placeholder{
             color: #986655;
             font-size: 12px;
         }


  </style>
  • 13
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值