Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

what is the difference between max-width and flex-basis

Here are some of the most important things I have learned about flex-basis during my use of Flexbox’s flex-basis.

Flex-basis controls either “width” or “height” based on the flex-direction
Flex-basis will override any other width: or height: properties if specifically declared anything other than flex-basis: auto (auto by default)
The shorthand for flex basis is (flex: $grow, $shrink, $size) and is set to (flex: 0 1 auto) by default.
When flex basis is set to auto, it first checks for a width or height property (based on direction) if none, it uses the elements content sizing
Flex-basis will still obey any min / max-width: or height settings. Again, it is based on the flex-direction:
Flex-basis in a column overrides height:, this is important because although width: will obey flex-shrink, height: will not. (This can cause confusing and unexpected results in your design.)
Important to note
Notice how auto is bold. By default, if you have a width set and did not declare a flex basis value, width will function normally on that element. There is no difference between how flex-basis: will function on your element and how width: will function on your element. Width will even obey flex-shrink when using Flexbox.

The divergent factor between width and flex-basis is the dynamic ability of flex-basis to change its effective direction based on the flex-direction.

The caveat
height: on the other hand acts a bit differently. The height property does not obey flex-shrink in the same way that width does. When using flex-direction column you should always use flex-basis to dynamically control your Flexbox’s sizing so that you have consistent and expected results.

Also take special note of bullet point number 4:

When flex basis is set to auto, it first checks for a width or height property (based on direction) if none, it uses the elements content sizing
Comment

PREVIOUS NEXT
Code Example
Python :: restart device micropython 
Python :: pandas dro pow 
Python :: pygame download for python 3.10 
Python :: Command "python setup.py egg_info" failed setuptools/ gunicorn 
Python :: installing python3.8 in rpi 
Python :: showing typle results with for loop in py in one line 
Python :: python pytest use same tests for multiple modules 
Python :: numpy array filter and count 
Python :: python with statement variables 
Python :: full_pickle 
Python :: is 2 an even number 
Python :: ploting bargraph with value_counts(with title x and y label and name angle) 
Python :: fungsi untuk mengecek apakah ada data yang kosong 
Python :: python type checking dictionary mypy 
Python :: select randomly from list in loop 
Python :: train object detection model 
Python :: dbscan clustering of latitudes and longitudes 
Python :: yticks in plotly expres 
Python :: python project pick text color according to background 
Python :: how to use wbtools in python 
Python :: django create view filter options 
Python :: pythongalaxy.com 
Python :: pyqt create a qmenu on a button click 
Python :: Percentage change between the current and the prior element. 
Python :: how to copy items in list n times in list python 
Python :: how to create fibonacci sequence in python 
Python :: python iterate through list by chunks 
Python :: python tuple range 
Python :: pytorch rolling window 
Python :: module level import not at top of file 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =