Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> .box { height: 70px; display: flex; } .box div { flex-grow: 0; flex-shrink: 0; flex-basis: 60px; padding: 15px; /* For Safari 6.1 and above browsers */ -webkit-flex-grow: 0; -webkit-flex-shrink: 0; -webkit-flex-basis: 60px; } .box div:first-child { background-color: #40c3da; } .box div:nth-of-type(2) { flex-basis: 40%; -webkit-flex-basis: 40%; background-color: lightgreen; } .box div:nth-of-type(3) { flex-basis: auto; -webkit-flex-basis: auto; background-color: yellow; } .box div:nth-of-type(4) { flex-basis: initial; -webkit-flex-basis: initial; background-color: orange; } .box div:nth-of-type(5) { flex-basis: inherit; -webkit-flex-basis: inherit; background-color: pink; } </style> </head> <body> <h2>Flex-basis property example</h2> <div class="box"> <div> number 60px </div> <div> percentage 40% </div> <div> auto </div> <div> initial </div> <div> inherit </div> </div> </body> </html>