3 column layouts using flexbox 3rd column by pushing left

I am trying to create a fuild layout using the flexbox CSS property. I am trying to design a three-column layout, but my attempts seem to be out of place. style sheet is as follows.

some background information: I am designing in C # ASP.NET. so my HTML has some code that makes it easier (for me) to have variable content with a layout layout. Basically, only content changes in the menu clicks, and the rest remain the same throughout the website.

.MainContainer{
display: flex;
flex-direction: column;
border-style: solid; /*Debugging purposes*/
}

.ContentContainer{
width: 100%;
fill:aliceblue;
display: flex;
flex-direction: row;
border-style: solid; /*Debugging purposes*/
}

.header{
width: 100%;
height: 15%;
text-align: center;
border-style: solid; /*Debugging purposes*/
}

.footer{
width: 100%;
height: 15%;
text-align: center;
border-style: solid; /*Debugging purposes*/
 }

.navbar{
display: flex;
width: 15%;
align-self: stretch;
align-items: center;
flex-direction: column;
padding:2px;
margin: 10px;

min-width: 15%;

border-style: solid; /*Debugging purposes*/
 }

.content{
display: flex;
align-self: stretch;
width: 95%;
padding:10px;
margin: 10px;
text-align: justify;

min-width: 90%;
overflow:hidden;

border-style: solid; /*Debugging purposes*/
}

.aside{
display: flex;
width: 15%;
align-self: stretch;
align-items: center;
flex-direction: column;
margin: 10px;
padding: 10px;

min-width: 15%;

border-style: solid; /*Debugging purposes*/
}

HTML code:

<div class="header">This is the Header space</div>

<div class="ContentContainer">
    <nav class="navbar">
        <a href="Home.aspx">Home</a>
        <a href="About.aspx">About</a>
        <a href="Contact.aspx">Contact</a>
    </nav>

<%--    start of variable content--%>
    <form id="form1" runat="server">
        <div class="content">
            <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

            </asp:ContentPlaceHolder>
        </div>
    </form>
<%--    end of variable content--%>

    <div class="aside">Content Area for Latest items.</div>
</div>

<div class="footer">Tis is the Footer space</div>

: , , . div , . , , 15% .

?

+4
2

, , , :

.MainContainer{
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ContentContainer{
  display: flex;
  justify-content: space-between;
  flex-direction: row;
}

.header{
  display: flex;
  justify-content: center;
  width: 100%;
  height: 15%;
  text-align: center;
  border-style: solid; /*Debugging purposes*/
}

.footer{
  display: flex;
  justify-content: center;
  width: 100%;
  height: 15%;
  text-align: center;
  border-style: solid; /*Debugging purposes*/
 }

.navbar{
  display: flex;
  width: 15%;
  align-items: center;
  flex-direction: column;
  padding:2px;
  margin: 10px;
  border-style: solid; /*Debugging purposes*/
}

.content{
  display: inline-block;
  flex: 1;
  padding:10px;
  margin: 10px;
  text-align: justify;
  border-style: solid; /*Debugging purposes*/
}

.aside{
  display: flex;
  width: 15%;
  align-items: center;
  flex-direction: column;
  margin: 10px;
  padding: 10px;
  border-style: solid; /*Debugging purposes*/
}
<div class="MainContainer">
  <div class="header">This is the Header space</div>
  <div class="ContentContainer">
	<nav class="navbar">
	  <a href="Home.aspx">Home</a>
	  <a href="About.aspx">About</a>
	  <a href="Contact.aspx">Contact</a>
	</nav>
	<div class="content">
	</div>
	<div class="aside">Content Area for Latest items.</div>
  </div>

  <div class="footer">Tis is the Footer space</div>
</div>
Hide result
0

, CSS, , :

body {
  margin: 0; padding: 0;
}
.MainContainer{
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  min-height: 100vh;
  > * {
    flex-grow: 1 0 auto;
  }
}

.ContentContainer{
  flex-grow: .7;
  width: 100%;
  fill:aliceblue;
  display: flex;
  flex-direction: row;
}

.header, .footer {
  flex-grow: .15;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background-color: rgba(0,0,0,.1);
}


.navbar{
  display: flex;
  width: 15%;
  align-self: stretch;
  align-items: center;
  flex-direction: column;
  padding:2px;
  margin: 10px;

  min-width: 15%;
}

#form1{
  flex-grow: 1;
  border: 2px solid #eee;
  display: flex;
  align-self: stretch;
  padding:10px;
  margin: 10px;
  text-align: justify;
  background-color: white;
}

.aside{
  display: flex;
  width: 15%;
  align-self: stretch;
  align-items: center;
  flex-direction: column;
  margin: 10px;
  padding: 10px;
  min-width: 15%;
}
<div class="MainContainer">
  <div class="header">This is the Header space</div>

  <div class="ContentContainer">
    <nav class="navbar">
      <a href="Home.aspx">Home</a>
      <a href="About.aspx">About</a>
      <a href="Contact.aspx">Contact</a>
    </nav>
    <form id="form1" runat="server">
      <div class="content">
        <div id="ContentPlaceHolder1" runat="server">content
        </div>
      </div>
    </form>
    <div class="aside">Content Area for Latest items.</div>
  </div>
  <div class="footer">Tis is the Footer space</div>
</div>
Hide result

( , , , ):

  • 15% footer header , , (, ), . - , , , . 15% ( ). , 15% , flex-grow: .15 flex: 0 1 15vh; min-height: 15vh;.
  • , ( @media), - , , , ,
  • , , flexbox prefixing, ~80% ~97.3%, .
0

Source: https://habr.com/ru/post/1666313/


All Articles