Does it exist an equivalent of box-sizing: border-box in flexbox for React Native?

核能气质少年 提交于 2019-12-08 14:32:15

问题


I would like the size of my boxes not to be changed by margin and padding.


回答1:


React Native styles all views as if box-sizing: border-box is set. See this code: https://github.com/facebook/react-native/blob/5aa1fb3ff326a429e33a443576da866f2a63c20c/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java#L632




回答2:


Let O (for outer) = (top, left, bottom, right) be the rectangle that represents the size * and position of a view V. Since the box-sizing of all React Native views is border-box, any * border of V will render inside O.




回答3:


you can use resizeMode: 'cover' or 'stretch' or 'contain'



来源:https://stackoverflow.com/questions/38503451/does-it-exist-an-equivalent-of-box-sizing-border-box-in-flexbox-for-react-nativ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!