-
-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Modal width out of screen #25765
Merged
afc163
merged 8 commits into
ant-design:master
from
tanmoyopenroot:25554-fix-modal-width
Sep 3, 2020
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ba4efe0
style(modal): add max-width
tanmoyopenroot 45233b9
chore(modal): add custom width demo
tanmoyopenroot 6400c9e
test(modal): add custom width snapshot
tanmoyopenroot 032c6a8
Merge branch 'master' into 25554-fix-modal-width
afc163 5a8a81e
Update modal.less
afc163 73dda3b
Update modal.less
afc163 e33a7eb
Update width.md
afc163 28ec6e3
Update demo.test.js.snap
afc163 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
order: 13 | ||
title: | ||
zh-CN: 自定义模态的宽度 | ||
en-US: To customize the width of modal | ||
--- | ||
|
||
## zh-CN | ||
|
||
使用 `width` 来设置模态对话框的宽度。 | ||
|
||
## en-US | ||
|
||
Use `width` to set the width of the modal dialog. | ||
|
||
```jsx | ||
import { Modal, Button } from 'antd'; | ||
|
||
class App extends React.Component { | ||
state = { | ||
modalVisible: false, | ||
}; | ||
|
||
setmodalVisible(modalVisible) { | ||
this.setState({ modalVisible }); | ||
} | ||
|
||
render() { | ||
return ( | ||
<> | ||
<Button type="primary" onClick={() => this.setmodalVisible(true)}> | ||
Vertically centered modal dialog | ||
</Button> | ||
<Modal | ||
title="Vertically centered modal dialog" | ||
centered | ||
visible={this.state.modalVisible} | ||
onOk={() => this.setmodalVisible(false)} | ||
onCancel={() => this.setmodalVisible(false)} | ||
width={1000} | ||
> | ||
<p>some contents...</p> | ||
<p>some contents...</p> | ||
<p>some contents...</p> | ||
</Modal> | ||
</> | ||
); | ||
} | ||
} | ||
|
||
ReactDOM.render(<App />, mountNode); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
margin: 0 auto; | ||
padding-bottom: 24px; | ||
pointer-events: none; | ||
max-width: calc(100vw - 16px); | ||
|
||
&-wrap { | ||
position: fixed; | ||
|
@@ -81,7 +82,8 @@ | |
padding: @modal-header-padding; | ||
color: @text-color; | ||
background: @modal-header-bg; | ||
border-bottom: @modal-header-border-width @modal-header-border-style @modal-header-border-color-split; | ||
border-bottom: @modal-header-border-width @modal-header-border-style | ||
@modal-header-border-color-split; | ||
border-radius: @border-radius-base @border-radius-base 0 0; | ||
} | ||
|
||
|
@@ -96,7 +98,8 @@ | |
padding: @modal-footer-padding-vertical @modal-footer-padding-horizontal; | ||
text-align: right; | ||
background: @modal-footer-bg; | ||
border-top: @modal-footer-border-width @modal-footer-border-style @modal-footer-border-color-split; | ||
border-top: @modal-footer-border-width @modal-footer-border-style | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep original style There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be formatted by prettier. |
||
@modal-footer-border-color-split; | ||
border-radius: 0 0 @border-radius-base @border-radius-base; | ||
|
||
button + button { | ||
|
@@ -153,7 +156,6 @@ | |
|
||
@media (max-width: @screen-sm-max) { | ||
.@{dialog-prefix-cls} { | ||
max-width: calc(100vw - 16px); | ||
margin: 8px auto; | ||
} | ||
.@{dialog-prefix-cls}-centered { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep original style