I"m trying to create a layout like the screenshot using Bootstrap 4 but I"m having some problems with making the sidebar fixed & achieving this layout at the same time.
Bạn đang xem: Html, bootstrap sidebar tutorial
Going with a basic example:
It"s possible khổng lồ get this layout but things get tricky once I declare:
.sidebar position: fixed // or absoluteOnce I make the sidebar sticky, the main div starts appearing behind the sidebar instead of next khổng lồ it. Of course it"s possible khổng lồ declare some margin & push it back lớn it"s original position but it makes things complicated for responsiveness.
I feel lượt thích I"m missing something, I read the Bootstrap 4 documentation but I couldn"t find a simple way khổng lồ achieve this layout.
Trending is based off of the highest score sort & falls back khổng lồ it if no posts are trending.
Xem thêm: Top 8 Loại Sữa Rửa Mặt Hazeline Ngọc Trai Có Tốt Không, Review Sữa Rửa Mặt Hazeline
Try it DismissHere"s an updated answer for the latest Bootstrap 4.0.0. This version has classes that will help you create a sticky or fixed sidebar without the extra CSS....
Use sticky-top:
Demo: https://codeply.com/p/0Co95QlZsH
Also see:Fixed & scrollable column in Bootstrap 4 flexboxBootstrap col fixed positionHow lớn use CSS position sticky khổng lồ keep a sidebar visible with Bootstrap 4Create a responsive navbar sidebar "drawer" in Bootstrap 4?
The J.S.:
var lateral = false;function fixar() var element, name, arr; element = document.getElementById("minhasidebar"); if (lateral) element.className = element.className.replace( /position-fixed/g, ""); lateral = false; else name = "position-fixed"; arr = element.className.split(" "); if (arr.indexOf(name) == -1) element.className += " " + name; lateral = true; The HTML:
Sidebar:
div#dashmain margin-left:150px; div#dashside position:fixed; width:150px; height:100%;
Thanks for contributing an answer to Stack Overflow!
But avoid …
Asking for help, clarification, or responding khổng lồ other answers.Making statements based on opinion; back them up with references or personal experience.To learn more, see our tips on writing great answers.
By clicking “Post Your Answer”, you agree khổng lồ our terms of service, privacy policy & cookie policy
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device và disclose information in accordance with our Cookie Policy.