HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> #parent{ display: flex; width: 100%; border: 1px solid #8c8c8c; width:500px; } #parent > div{ border:1px solid #267326; padding:25px 0; text-align:center; flex-basis: 100px; -webkit-flex-basis: 100px; } </style> </head> <body> <h1>CSS flex-basis Property</h1> <div id="parent"> <div>Div 1</div> <div>Div 2</div> <div>Div 3</div> </div> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementById("parent").firstElementChild; function myFunction(){ x.style.flexBasis = "200px"; x.style.WebkitFlexBasis = "200px"; } </script> <p><strong>Note</strong>: Click on the button to set the basic lenght of the 'div1' from 100px to 200px.</p> </body> </html>
OUTPUT
×

Save as Private