react&antd(6)js原生input文件上传框样式美化

在上个需求中虽然功能完成了,但是原生input框的样式太简陋了,不符合页面的整体风格,而且上面三个输入框也没有对齐,所以需要美化样式
思路:input框可以先把之前的按钮透明度opacity设置为0,然后外层用div包裹。通过冒号对齐antd提供了相应方法,可以去antd搜索form表单
修改前:
在这里插入图片描述
修改后(这样模态框就好看多了)
在这里插入图片描述

js代码

<div className={styles.fileBox}>
              <Input type="file" onChange={e => this.Upload(e)} accept='text/plain' className={styles.fileBtn}></Input>
              <CloudUploadOutlined />上传txt文件
              </div>

css

/* 原生的上传文件input样式修改 */
.fileBox{
    margin-left: 99px;
    /*  */
    display: inline-block; 
    position: relative;
    padding: 3px 5px;
    overflow: hidden;
    color: #fff;
    background-color: rgb(49, 150, 233);
    height: 32px;
    border-radius: 3px;
    vertical-align: bottom;
}
  
.fileBtn{
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    outline: none;
    background-color: transparent;
    filter: alpha(opacity=0);
    -moz-opacity:0;
    opacity: 0;
    cursor: pointer;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值