Home > Enterprise >  How to use bootstrap4 to implement fixed navigation and modules?
How to use bootstrap4 to implement fixed navigation and modules?

Time:12-23

How to implement the new version of twitter home page s css html layout. I want to left menu and Navbar and right col is fixed, only body can scroll, like twitter home page the same.

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
  <title>Document</title>
</head>
<body>
  <div >
    <div >
      <div > left menu</div>
      <div >
        <nav >
          <a  href="#">Navbar</a>
          <button  type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span ></span>
          </button>
        </nav>
        <div > <div >body</div> 
        <div >right col</div></div>
      </div>
    </div>
  </div>
</body>
</html>

`

CodePudding user response:

Bootstrap 4 has a class sticky-top can fixed div top.

<nav id="main-left-nav"
  ></nav>

You can see this demo.

  • Related