Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 655
void42 Avatar asked Jul 21 '16 11:07

void42


People also ask

What's the difference between box sizing content box and border box?

In the content box model, the content inside of element will have the same dimension as the element. In the border box model, the content's dimension has to subtract the border and padding from the element's dimension. Specifically, the content's width is 200 - 5 * 2 - 10 * 2 = 170px .

Does box sizing border box include border?

The box-sizing property allows us to include the padding and border in an element's total width and height. If you set box-sizing: border-box; on an element, padding and border are included in the width and height: Both divs are the same size now!

Is box sizing border box default?

box-sizing: border-box is the default styling that browsers use for the <table> , <select> , and <button> elements, and for <input> elements whose type is radio , checkbox , reset , button , submit , color , or search .


1 Answers

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

like image 81
Rashi Abramson Avatar answered Oct 02 '22 16:10

Rashi Abramson