0

I have a challenge that seems simple, but is causing me lack of sleep. Here's what I want to achieve:

  1. .toc makes the parent go fullwidth, works as intended
  2. .menu has a narrow parent, works as intended
  3. .searchbar needs full width parent, does't work

How do I fix my searchbar issue?

My fiddle is here: https://jsfiddle.net/afz7qth3/1/

<button data-target="search">search</button>
<button data-target="toc">toc</button>
<button data-target="menu">menu</button>

<div class="site-header">
  <nav class="container">
      <div class="content search">
        <div class="searchbar">
          search
        </div>
      </div>

      <div class="content toc">
        Lot of Lorem ipsum [...] elit.
      </div>

      <div class="content menu">
        <ul>
          <li>I am</li>
          <li>a narrow</li>
          <li>width menu</li>
        </ul>
      </div> 
   </nav>
 </div>

.site-header {
  width: 100%;
}

.container {
  border: 2px dotted black;
  display: table;
}

.content { display: none; }
.content.search { display: table-cell; }

.searchbar {
  width: 100%;
}

the .content divs are toggled with JS.

I have checked here How to make a div fill a remaining horizontal space? and here CSS fill remaining width and here Two divs side by side - Fluid display which did not help me.

Thank you,

Marc Smits
  • 53
  • 6
  • Why is this not simply using `block` in all the places where you are currently using `table`? – CBroe Nov 20 '20 at 12:05
  • Is reverses the problem, but does not solve it. It works for ```.search```, but then the menu wil be full width as well. – Marc Smits Nov 21 '20 at 11:24

0 Answers0