admin管理员组文章数量:1321443
I'm using the drawer from Material UI and I'm trying to round the corners using CSS like so:
style={{
borderRadius: "25px",
backgroundColor: "red",
overflow: "hidden",
padding: "300px"
}}
It works kinda, but the actual corners remain white instead of transparent.
How can I fix it such that the corners are properly rounded off? I've put my code in the following codesandbox:
I'm using the drawer from Material UI and I'm trying to round the corners using CSS like so:
style={{
borderRadius: "25px",
backgroundColor: "red",
overflow: "hidden",
padding: "300px"
}}
It works kinda, but the actual corners remain white instead of transparent.
How can I fix it such that the corners are properly rounded off? I've put my code in the following codesandbox:
https://codesandbox.io/s/material-demo-q3n14
Share Improve this question asked Mar 17, 2020 at 12:56 SJ19SJ19 2,12310 gold badges39 silver badges80 bronze badges1 Answer
Reset to default 9Reason
Your SwipeableDrawer
wraps your content inside a <Paper />
ponent. A Materiaul-UI paper ponent has shadows and a non-transparent background.
Solution
You do not use classnames, you use style, so the right way would be to set the SwipeableDrawer paperProps to:
PaperProps={{ elevation: 0, style: { backgroundColor: "transparent" } }}
- Elevation: 0, so that there are no shadows anymore
- backgroundColor: 'transparent', so that there is no background except yours
PS: Instead of having your borderRadius on your div, you may set it on the paper itself using the same prop
PaperProps={{ square: false }}
And remove your borderRadius from your div
Using classNames
If you used classNames (doc), you could have set the paper className to one of yours, using the classes
prop:
classes={{ paper: classes.someClassName }}
本文标签: javascriptMaterialUI Drawer rounding off corners leaves whitespaceStack Overflow
版权声明:本文标题:javascript - Material-UI Drawer rounding off corners leaves whitespace - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742101306a2420812.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论