问题
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