html - Nested flexbox groups -


i 2 groups of 3 inputs. on wider screens, 2 groups should side-by-side, , on narrower screens, 2 groups should stacked. 3 input items inside groups should side-by-side.

in cases, input items should evenly sized across width of window. in other words, on larger screens, should see 6 inputs equally sized side-by-side, taking width of window. on smaller screens, should see 3 inputs equally sized taking width of window, stacked on top of 3 similar inputs.

as grow or shrink window, inputs should change size proportionally. when window small 6 inputs fit side-by-side, should go 2 groups of 3, 3 inputs in each group expanding group takes width of window.

i want flexbox. realize media queries can this, embedding in growable div, media queries not work.

this code sample comes close, in wrapping, not grow inputs (or div wrappers around inputs matter) take width of window.

<!doctype html> <html lang="en"> <head>     <meta charset="utf-8">     <title>flex test</title>     <style>         .row {             flex-wrap: wrap;             flex-grow: 1;         }         .group {             display: inline-flex;             flex-wrap: nowrap;             flex: 1 0 100%;         }         .item {             flex: 1;         }     </style> </head> <body> <div id="wrapper" style="display:flex">     <div class="row">         <div class="group">             <div class = "item">                 <input text="test">             </div>             <div class = "item">                 <input text="test2">             </div>             <div class = "item">                 <input text="test3">             </div>         </div>         <div class="group">             <div class = "item">                 <input text="test">             </div>             <div class = "item">                 <input text="test2">             </div>             <div class = "item">                 <input text="test3">             </div>         </div>     </div> </div> </body> </html> 

i'm not sure if desired layout possible without media queries. since want inputs flexible , occupy full width of container, need way know when wrap. media queries , fixed widths triggers.

in answer i'll highlight problems code, may better grasp of situation.

this original css, comments:

#wrapper {     display: flex; /* valid */ }  .row {     flex-wrap: wrap; /* invalid #1 */     flex-grow: 1; /* valid */ }  .group {     display: inline-flex; /* valid */     flex-wrap: nowrap; /* valid */     flex: 1 0 100%; /* invalid #2 */ }  .item {     flex: 1; /* valid */ } 

invalid #1:

this code invalid because flex-wrap property applies flex containers. haven't applied display: flex or display: inline-flex .row, element not flex container , flex-wrap ignored.

invalid #2:

this code invalid because flex property applies flex items. parent element – .row – not flex container, .group not flex item , flex property ignored.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -