自定义弹框

自定义弹框实现

import styles from './index.scss'
const customModal = (props) => {
  const { showModal, setShowModal } = props
  return (
   <>
    {
     showModal && (
       <div className={styles['custom-modal']}>
          {/* 遮罩层 */}
         <div className={styles['modal-overlay']} onClick={() => { setShowModal (false)}}></div>
          {/* 内容 */}
          <div className={styles['modal-content']}>
            <div className={styles['content']}>
            </div>
              {/* 底部按钮 */}
              <div className={styles['modal-btn']}>
                  <Button
                    style={{ width: '40%'}}
                    size="small"
                    onClick={handleClear}
                  >
                    重写
                  </Button>
                )}
                <Button
                  style={{ width:'40%'}}
                  size="small"
                  type="primary"
                  onClick={handleSave}
                >
                  确认
                </Button>
              </div>
          </div>
       </div>
      )
    }
   </>
  )
}
/* 弹框动画 */
@keyframes fadeIn {
  from {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }

  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.custom-modal {
  .modal-overlay {
	  position: fixed;
	  top:0;
	  left: 0;
	  width: 100%;
	  height: 100%;
	  background: rgba(0, 0, 0, 0.5);
	}
  .modal-content {
    position: fixed;
    z-index: 99;
    top: 50%;
    left: 50%;
    width: 90%;
    height: 80%;
    padding: 12px 8px;
    transform: translate(-50%, -50%) scale(0);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
    animation: fadeIn 0.5s forwards;
    display: flex;
    flex-direction: column;
    .content {
      flex: 1;
      ovverflow: auto;
     }
    .modal-btn {
      display: flex;
      justify-content: space-between;
      gap: 16px;
      align-items: center;
    }
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值