0

You can see my codes output in this image. I want the Header and Content to be placed under each other and stick together. This should be executed while the 'Menu' tag is in the middle them (#header, #content), but next to it in appearance.

#app {
    position: relative;
    display: flex;
    width: 100%;
    background-color: #eee;
    border-radius: 10px;
    height: 100%;
    padding: 2%;
    gap: 2%;
    flex-wrap: wrap;
}

#header, #menu, #content {
    position: relative;
    width: 40%;
    min-width: 300px;
    height: 300px;
    background-color: #333;
    border-radius: 10px;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
}

#menu {
    height: 100%;
}
<div id="app">
        <div id="header">HEADER</div>
        <div id="menu">MENU</div>
        <div id="content">CONTENT</div>
 </div>
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
nego
  • 23
  • 4

1 Answers1

1

I think grid would be a better choice for this.

#app {
  /*position: relative;*/
  /*display: flex;*/
  background-color: #eee;
  border-radius: 10px;
  /*height: 100%;
    width: 100%;*/
  padding: 1rem;
  grid-gap: 1rem;
  /*flex-wrap: wrap;*/
  
  display: grid;
  grid-template: 
  "header menu" 1fr /* [grid area] [grid area] [row height] */
  "content menu" 1fr /* [grid area] [grid area] [row height] */
  / 3fr 1fr;  /* [left column width] [right column width] */
 
}

#header,
#menu,
#content {
  /*position: relative;*/
  /*width: 40%;*/
  /*min-width: 300px;*/
  /*height: 300px;*/
  background-color: #333;
  border-radius: 10px;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  
  flex-direction: column;
}

#header {
  grid-area: header;
  max-height: 300px;
}

#menu {
  grid-area: menu;
}

#content {
  grid-area: content;
}
<div id="app">
  <div id="header">
    <h1>HEADER</h1>
  </div>
  <div id="menu">
    <h1>MENU</h1>
  </div>
  <div id="content">
    <h1>CONTENT</h1>
  </div>
</div>
cp1
  • 163
  • 6