css - Flexbox children don't always expand as wide as they could/should -


two of link buttons in nav have long-ish names, , they're text-wrapping , becoming 2 lines tall though (as far can tell) there's nothing stopping them or nav growing wider. have missed something?

the code quite long, you'll happier viewing codepen reading here. it's long because i'm afraid i've overlooked in global styling or media query changes blame bug.

edit: 1 easy answer. misunderstood selector precedence. thought media queries took precedence on (except inline). didn't realize nav a rule in media query not overwriting nav > section > a in base css. lesson respecting css selector precedence.

html

<section>     <nav>         <a id="nsfw_deactivatefilter" onclick="worksafeoff()" href="#">worksafe mode: on</a>         <h2 onclick="showmenu()">category filters</h2>         <div></div>         <section id="nav_orientation">               <a id="horizontals" href="#">horizontals</a>               <a id="verticals" href="#">verticals</a>         </section>         <div></div>         <section id="nav_category">               <a id="biltmore" href="#">biltmore</a>               <a id="commercial" href="#">commercial / product</a>               <a id="fashion" href="#">fashion &amp; glamour</a>               <a id="invocation" href="#">invocation</a>               <a id="neworleans" href="#">new orleans</a>         </section>     </nav> </section> 

css

/** global **/ * {     box-sizing: border-box;     -moz-box-sizing: border-box;     -webkit-box-sizing: border-box;     color: inherit;     font-size: 16px;     font-style: inherit;     font-weight: 400;     line-height: 1em;     margin: 0 auto;     padding: 0;     position: relative;     text-align: center;     text-decoration: none;     z-index: 1; } {     text-decoration: underline; } body {     background-color: #444;     color: #ccc;     font-family: cambria, "hoefler text", "liberation serif", times, "times new roman", serif;     font-style: normal; } body > section {     background-color: #333;     width: 100%;     max-width: 1440px; }  /** nav **/ nav {     align-items: center;     background-color: #222;     display: flex;     flex-flow: column nowrap;     margin-bottom: 10px;     width: 95%;     max-width: 480px; } nav a, nav > h2 {     border: 1px solid #666;     margin: 0 0 5px 0;     padding: 5px; } nav {     text-decoration: none; } nav > a, nav > h2 {     width: 100%; } nav > {     background-color: #666; } nav > div {     display: none; } nav > section {      align-items: center;     display: none;     flex-flow: row wrap;     justify-content: space-between;     margin: 0;     width: 95%; } nav > section.nav {     display: flex; } nav > section > {     display: inline-block;     width: 48%; }   /** media queries **/ @media (min-width: 1000px) {     nav {         display: inline-flex;         flex-flow: row nowrap;         width: auto;         max-width: none;     }     nav {         margin: 0 5px;         width: auto;     }     nav > h2 {         display: none;     }     nav > div {         background-color: #666;         display: block;         height: 20px;         margin: 0 5px;         width:1px;     }     nav > section {          display: flex;         flex-flow: row nowrap;         width: auto;     } } 

remove width: 48%; rule nav > section > a.

see codepen.


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? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -