Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

Full height siderbar and content area breaks on smaller device screen

$
0
0

Is it possible to fix the following issue with 100% height of both sidebar and content area on a smaller device screen? Given the code, it's hard for me to fix the issue.

My goal is to create a sidebar and a content area. The sidebar should be of a fixed width, that takes up full width on a smaller device. The sidebar is sticky when scrolling the content.

I am using Bootstrap 4.

Thanks

The code:

<!doctype html><html lang="en" class="h-100"><head><!-- Required meta tags --><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><!-- Bootstrap CSS --><link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"><title>Hello, world!</title><link href="../Assets/CSS/Master3-style.css" rel="stylesheet" /><style>
    html,
    body {
      color: white;
    }
    .sidebar {
      background-color: aliceblue;
      padding-right: 20px;
      padding-left: 20px;
      padding-top: 40px;
    }
    .logo {
      margin-bottom: 40px;
      max-width: 215px;
    }
    .logo-wrapper {
      text-align: center;
    }
    .main {
      background-color: antiquewhite;
      color: black;
    }
    .sidebar-nav {
      background-color: cadetblue;
      max-width: 200px;
      margin: 0 auto;
    }
    .left {
      float: left;
      width: 300px;
      height: 100%;
      background-image: linear-gradient(180deg, #00607a 0%, #006e73 100%);
      padding-bottom: 40px;
    }
    .right {
      float: right;
      width: calc(100% - 300px);
      background: yellow;
      height: 100%;
    }
    @media only screen and (max-width: 768px) {
      .left {
        float: none;
        height: auto;
        width: 100%;
      }
      .right {
        float: none;
        width: 100%;
        height: auto;
      }
    }</style></head><body class="h-100"><div class="h-100"><div class="h-100"><div class="sidebar left"><div class="sticky-top"><div class="logo-wrapper"><img class="logo" src="http://logosvg.com/wp-content/uploads/2016/08/logosvgcom.png" /></div><ul class="sidebar-nav"><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li><li><a>Link</a></li></ul></div></div><div class="main right"><div class="container"><div class="row"><div class="col-12"><p>
                What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type
                specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
                and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking
                at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web
                page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose
                (injected humour and the like). Where does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock,
                a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable
                source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance.
                The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de
                Finibus Bonorum et Malorum" by Cicero a</p></div></div></div></div></div></div><!-- Optional JavaScript --><!-- jQuery first, then Popper.js, then Bootstrap JS --><script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script><script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script></body></html>

enter image description here

Running @MinIsNghia code i get two issues i would like to get figured out: enter image description here


Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>