你如何设置上传按钮的样式?

时间:2013-07-01 02:40:24

标签: html css html5 css3 upload

我试图给我的上传按钮添加一些风格,但它给你带来了一些麻烦。当我应用一些样式时,它会影响背景而不是按钮。与so一样。

3 个答案:

答案 0 :(得分:1)

遗憾的是,仅仅应用几种风格要困难一些。 Bool先生提供了一个很好的教程,使用HTML,CSS和JavaScript来完成工作:

http://mrbool.com/how-to-style-a-file-upload-button-in-css/26599

希望这有帮助~~

答案 1 :(得分:0)

CSS

    <style type="text/css">
        div.fileinputs {
            position: relative;
        }

        div.fakeinput{
            position: absolute;
            top: 0px;
            left: 0px;
            z-index: 1;
        }

        div.fakeinput input[type=button] {
            /* enough width to completely overlap the real hidden file control */
            cursor: pointer;
            width: 148px;
        }

        div.fileinputs input.file {
            position: relative;
            text-align: right;
            -moz-opacity:0 ;
            filter:alpha(opacity: 0);
            opacity: 0;
            z-index: 2;
        }
    </style>

HTML

    <div class="fileinputs">
        <input type="file" class="file" />

        <div class="fakeinput">
            <input type="button" value="Select file" />
        </div>
    </div>
</html>

答案 2 :(得分:0)

以下是CSS脚本示例。 同样,您可以根据您的要求添加。

.homebutton {
    border: none;
    background-color: #ededed;
    color: #999999;
    font-size: 15px;
    font-weight: bold;
    height: 40px;
    width: 110px;
    border-radius: 5px 0px 0px 5px;
}

`

相关问题