How can I add two more column beside the sidebar?

Viewed 100

I can't create another two column beside the sidebar.

Please see the image for understanding

Can somebody assist me?

<!-- -------------Navigation Bar------------- -->

<div class="sidebar">
  <a class="active" href="#home">Home</a>
  <a href="#services">Example 1</a>
  <a href="#portfolio">Example 2</a>
  <a href="#about">Example 3</a>
  <a href="#contact">Example 4</a>
</div>
<div class="col">
  <div class="content">
    <h2>Responsive Sidebar Example</h2>
    <p>This example use media queries to transform the sidebar to a top navigation bar when the screen size is 700px or less.
    </p>
    <p>We have also added a media query for screens that are 400px or less, which will vertically stack and center the navigation links.</p>
    <h3>Resize the browser window to see the effect.</h3>
  </div>

</div>

4 Answers

Refer this you can adjust width according to requirement

create 2 div and style it as you want here i provided just an example

.section1{
    background-color:#00ffff;
    width:70%;
    float:left;
    height:100vh;
    border-right: 1vw solid #F5E5D6; 
    box-sizing: border-box;
    margin:0;
    padding:0;  
}
.section2{
    background-color:#f1c40f;
    width:30%;
    float:left;
    height:100vh;
    margin:0;
    padding:0;
  box-sizing: border-box;
}
<div class="sidebar">
  <a class="active" href="#home">Home</a>
  <a href="#services">Example 1</a>
  <a href="#portfolio">Example 2</a>
  <a href="#about">Example 3</a>
  <a href="#contact">Example 4</a>
</div>
<div class="col">
  <div class="content">
  <div class="section1">
    <h2>Responsive Sidebar Example</h2>
    <p>This example use media queries to transform the sidebar to a top navigation bar when the screen size is 700px or less.
    </p>
    <p>We have also added a media query for screens that are 400px or less, which will vertically stack and center the navigation links.</p>

    </div>
    <div class="section2">
    2nd screen
</div>
  </div>

</div>

You can achieve this by wrapping your content in a container that would behave like a row and its children will be aligned as columns. You can do this with display: flex or display: grid, your choice.

.row {
  display: flex;
  /* display: grid;
  grid-template-columns: 20% 60% 20%; */
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 20%
}

.content {
  width: 60%
}
<div class="row">
  <div class="sidebar">
    <a class="active" href="#home">Home</a>
    <a href="#services">Example 1</a>
    <a href="#portfolio">Example 2</a>
    <a href="#about">Example 3</a>
    <a href="#contact">Example 4</a>
  </div>
  <div class="content">
    <h2>Responsive Sidebar Example</h2>
    <p>
      This example use media queries to transform the sidebar to a top navigation bar when the screen size is 700px or less.
    </p>
    <p>
      We have also added a media query for screens that are 400px or less, which will vertically stack and center the navigation links
    </p>
    <h3>Resize the browser window to see the effect.</h3>
  </div>
  <div class="sidebar-2">
    Another container
  </div>
</div>

Something like this

.container {
    display: flex;
    flex-direction: row;
}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link rel="stylesheet" href="main.css" />
        <title>Document</title>
    </head>
    <body>
        <div class="container">
            <div class="sidebar">
                <a class="active" href="#home">Home</a>
                <a href="#services">Example 1</a>
                <a href="#portfolio">Example 2</a>
                <a href="#about">Example 3</a>
                <a href="#contact">Example 4</a>
            </div>
            <div class="section1">
                <h2>Responsive Sidebar Example</h2>
                <p>This example use media queries to transform the sidebar to a top navigation bar when the screen size is 700px or less.</p>
                <p>We have also added a media query for screens that are 400px or less, which will vertically stack and center the navigation links.</p>
            </div>
            <div class="section2">2nd screen</div>
        </div>
    </body>
</html>

I have added new DIV element please check that and get some idea. I have edited this related to your code.

 @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@500&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Lato&display=swap');

*{
    margin: 0px;
    padding: 0px;
    box-sizing: border-box;
}

.container{
    max-width: 1400px;
    margin: auto;
}
.header{                /* Header */
    padding: 10px 20px;
    background-image: linear-gradient(rgba(0,0,0,0.75), rgba(0,0,0,0.75)),url(/assets/top.jpg);
    background-size: cover;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    
}
   
.fa{                     /* icon color */
    color: white;
}
.comLink:hover{          /* icon hover */
    color: #ccc;
}

input{                  /* Search input*/
    margin-top: 8px;
    padding:6px ;
    border: 1px solid #ccc;
    width: 70%;
    border-radius: 4px;
}
.btn{                   /* Search Button */
    padding: 7.5px;
    background:#f44336 ;
    border: none;
    cursor: pointer;
    border-radius: 4px;
}
.btn:hover{                /* Button hover */
    background: #FF7F50;
}
.links a{
    padding-left: 19px;
}

.logo{                      /* Logo */
    font-family: 'Roboto', sans-serif;
   padding: 40px 0px;
   font-size: 30px;
   text-decoration: none;
   color: white;
   letter-spacing: 8px;
}
span{
    color: #f44336;
}

a{
    text-decoration: none;
}

.myDIV{         /* here is my changes */
  display:flex;
}

li{
    list-style: none;
}
   
.sidebar {
  display:flex; /* here is the changes */
  flex-direction:column; /* here is the changes */
  margin: 0;
  padding: 0;
  width: 200px;
  background-color: #f1f1f1;
  height: 100%;
  overflow: auto;
  position: relative;
}

.sidebar a {
    font-family: 'Lato', sans-serif;
  display: block;
  color: black;
  padding: 16px;
  text-decoration: none;
}
 
.sidebar a.active {
  background-color: #f44336;
  color: white;
}

.sidebar a:hover:not(.active) {
  background-color: #555;
  color: white;
}

/* Content */


@media screen and (max-width: 768px) {
  
.myDIV{      /* here is my changes */
  display:flex;
  flex-direction:column;
}

.sidebar{   /* here is my changes */
    display: flex;
    flex-direction: row;
    width: -webkit-fill-available;
}
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .sidebar a {
      float: left;
    }
  div.content {
      margin-left: 0;
    }

  .logo{
      font-size: 25px;
  }
}

@media screen and (max-width: 500px) {
  .sidebar a {
    text-align: center;
    float: none;
  }
  .logo{
      font-size: 25px;
      letter-spacing: normal;
  }
}

.section1{
    background-color:#00ffff;
    width:70%;
    float:left;
    height:100vh;
    border-right: 1vw solid #F5E5D6; 
    box-sizing: border-box;
    margin:0;
    padding:0;  
}
.section2{
    background-color:#f1c40f;
    width:28%;
    float:left;
    height:100vh;
    margin:0;
    padding:0;
  box-sizing: border-box;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <title>Hi There! Aziz</title>


    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div class="container">

        <!-- -------------Header/Banner------------- -->

        <div class="header">
            <a href="#" class="logo">ABDUL <span>AZIZ</span></a>
            <div class="links">
                <a href="#"><i class="comLink fa fa-facebook-square fa-2x"></i></a>
                <a href="#"><i class="comLink fa fa-github-square fa-2x"></i></a>
                <a href="#"><i class="comLink fa fa-linkedin-square fa-2x"></i></a>
                <a href="#"><i class="comLink fa fa-behance-square fa-2x"></i></a>
                <form action="#">
                    <input type="text" placeholder="Search...">
                    <button class="btn" type="submit"><i class="fa fa-search"></i></button>
                </form>
            </div>

        </div>


        <!-- -------------Navigation Bar------------- -->
    <div class ="myDIV">              <!-- here is the DIV I added-->
        <div class="sidebar">
            <a class="active" href="#home">Home</a>
            <a href="#services">Example 1</a>
            <a href="#portfolio">Example 2</a>
            <a href="#about">Example 3</a>
            <a href="#contact">Example 4</a>
        </div>
        
        <div class="col">
            <div class="content">
                <div class="section1">
                    <h2>Responsive Sidebar Example</h2>
                    <p>This example use media queries to transform the sidebar to a top navigation bar when the screen
                        size
                        is
                        700px or less.
                    </p>
                    <p>We have also added a media query for screens that are 400px or less, which will vertically stack
                        and
                        center the navigation links.</p>

                </div>
                
                <div class="section2">
                    2nd screen
                </div>
                
            </div>
        </div>                
     </div>
   </div>
</body>

</html>

I have commented "here is my changes" like that to find my changes

Updated the answer please check this

Related