ant design (antd) Modal 自定義樣式,去除白色背景,邊框,關閉按鈕
阿新 • • 發佈:2018-12-31
想實現功能如下:
這個Modal沒有頭,沒有確定什麼的。
因為Modal元件不能自定義外邊框,所以把所有的屬性全都刪掉之後:
<Modal title={null}
visible={this.state.visible}
onCancel={this.handleCancel}
footer={null}
closable={false}
wrapClassName={'web'}//對話方塊外部的類名,主要是用來修改這個modal的樣式的
>
<div className ="outer-iframe">
<div className="d-iframe">
<iframe id="previewIframe" src="" frameBorder="0"
className="iframe-style"></iframe>
</div>
</div>
</Modal>
還會剩餘一個頭部的關閉,所以用到了上面程式碼塊的: wrapClassName=>對話方塊外層容器的類名
來重寫外邊框的類,此時less改成:
.web {
.ant-modal-content {
position: relative;
background-color: #00000000 !important;
border: 0;
border-radius: 4px;
background-clip: padding-box;
box-shadow: 0 0 0 rgba(0, 0, 0, 0) !important;
}
.ant-modal-body {
padding: 0 !important ;
font-size: 0 !important;
line-height: 1 !important;
}
}
背景改為透明,沒有陰影效果即可,此時已經可以完全定義自己的樣式。
2018/1/9更新
上面的 :
background-color: #00000000 !important;
的前兩個 0 代表的是 安卓上面的 透明度,無意中看到,可能在前端識別不了,請替換成 rgba(0, 0, 0, 0) ,這邊不測試了,親自己試試。