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>
### 回答1: CSS可以用来美化input file样式,具体方法如下: 1. 隐藏默认的input file样式 ```css input[type="file"] { display: none; } ``` 2. 创建一个自定义的按钮样式 ```css .custom-file-upload { border: 1px solid #ccc; display: inline-block; padding: 6px 12px; cursor: pointer; } ``` 3. 将自定义按钮和input file关联起来 ```html <label for="file-upload" class="custom-file-upload"> 选择文件 </label> <input id="file-upload" type="file"/> ``` 这样就可以实现一个简单的input file样式美化了。当然,还可以根据需求进行更加复杂的样式设计。 ### 回答2: 在Web开发中,我们经常使用input file标签来让用户上传文件。然而,由于input file的样式比较简单单调,我们往往需要用CSS来美化样式,使其更加符合网站的视觉风格,以增强用户的体验。在以下的回答中,我将介绍几种常见的CSS input file样式美化方法。 1. 纯CSS样式美化 在这种方法中,我们通过CSS样式input file标签进行美化。一般来说,我们需要通过input[type=file]这个CSS选择器来选中input file标签。然后,我们可以通过设置样式来改变这个标签的外观,例如修改背景颜色,设置文字样式,以及添加边框、阴影等效果。 2. 借助JavaScript库实现 除了纯CSS样式美化,我们还可以借钩JavaScript库来实现input file样式美化。比如,利用jQuery的filestyle插件,我们可以在input file标签的旁边添加一个按钮,使得用户点击按钮后弹出文件选择框。这样在视觉效果上会更加美观,用户操作也更加方便。 3. 页面元素替换 在这种方法中,我们可以将input file标签替换成其他更符合页面风格的元素,并设置对应的事件处理函数。例如,我们可以通过一个div元素来替代input file标签,当用户点击这个div时,触发input file的点击事件,从而弹出文件选择框。接着,我们可以通过CSS样式来让div元素看起来像自己设计的按钮或图标,从而实现input file样式美化。 总之,通过CSS input file样式美化,我们可以提高用户的使用体验和页面的视觉效果。无论是使用纯CSS的方式、借助JavaScript库实现,还是进行页面元素替换,我们都需要尽量保证美化后的样式与页面整体视觉风格相符,使得整个网站看起来更加统一、美观。 ### 回答3: CSS Input File样式美化是一种通过CSS来美化HTML的文件输入元素的方法。通常,HTML文件输入元素的默认样式是单调和无聊的。美化它们的样式既能够增强页面的可视性,也能够提高用户体验。在这里,我们将介绍几种常见的CSS Input File样式美化的方法。 1. 使用伪类选择器:可以通过给文件输入元素添加伪类选择器来美化它们的样式。例如,通过添加 ::before 和 ::after 伪类选择器,我们可以为文件输入元素添加图标和文本来让它看起来更加有吸引力和易于使用。 2. 改变字体颜色和背景颜色:可以通过改变文件输入元素的字体和背景颜色来使其看起来更加有吸引力。这样可以使其更加显眼和易于使用。 3. 使用CSS框架:也可以使用CSS框架来美化文件输入元素,框架通常包含现成的文件输入样式。Bootstrap和Foundation等CSS框架目前是最受欢迎的。 4. 自定义CSS样式表:可以自定义CSS样式表来美化文件输入元素。通过调整文件输入元素的边框,背景颜色,颜色,字体等属性,可以轻松地制作美观且实用的样式。 在进行CSS Input File样式美化时,要注意遵循通用CSS最佳实践,避免过度使用样式。同时要确保文件输入元素的有效性,并遵循HTML标准。切勿使用外部插件进行文件输入元素的美化,这会增加额外的代码和安全漏洞。总之,好的文件输入文件样式应该是简单,易于使用和眼睛友好的。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值