My bootstrap navbar-bottom covers content when I need to scroll the page. I've already tried to set the padding-bottom to 65px of the body but that didn't help.
My HTML
<!-- FOOTER -->
<nav class="navbar navbar-inverse navbar-fixed-bottom">
<div class="container">
<ul class="nav navbar-nav">
<li><i class="fa fa-facebook-official" aria-hidden="true" id="socialMedia"></i></li>
<li><i class="fa fa-twitter-square" aria-hidden="true" id="socialMedia"></i></li>
<li><i class="fa fa-youtube-square" aria-hidden="true" id="socialMedia"></i></li>
</ul>
</div> <!-- End container -->
</nav>
My CSS
body {
padding-bottom: 65px;
padding-top: 65px;
}
Could anyone help me out please :D Thanks in advance.
The existing answer doesn't work, but it is close. Instead of adding the margin to the html element or the body element (which include the footer and the overlapped content), it's necessary to add the margin to the element that contains the content, at the same level as the footer; the .main-content div.
.main-content {margin-bottom: 65px}
p {padding:2em; border: 1px dashed #CCC}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="cotainer-fluid main-content">
<div class="container">
<h1>Lorem ipsum dolor sit.</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptas beatae dolor consectetur ipsum minus impedit eaque reiciendis, quos vel ea eos? Inventore obcaecati laudantium incidunt quos ipsam. Optio, ipsa, tempora.</p>
<p>Maiores sed ab excepturi nobis exercitationem repudiandae dolores doloremque omnis. Reprehenderit placeat consequatur perferendis, aspernatur impedit eveniet odio ipsum, dignissimos libero qui omnis cum nihil non suscipit debitis repellendus autem.</p>
<p>Ipsum excepturi possimus pariatur enim mollitia repellat assumenda consequuntur. Maxime, amet, perspiciatis! Omnis praesentium sequi illum quisquam, perferendis doloremque possimus nihil facilis ipsum nam amet eos neque voluptates, dignissimos corrupti.</p>
<p>Reprehenderit possimus autem itaque eligendi inventore modi, temporibus consequatur tempore a magni! Sed soluta, minima quidem molestias animi accusamus voluptas nobis vel libero, natus voluptatum tempora magnam, labore, repellendus iste!</p>
<p>Eaque rem earum tenetur debitis consequuntur voluptate nobis numquam possimus temporibus, voluptas unde adipisci quisquam delectus corporis aliquam ut itaque! Rem minus accusamus ex, est sed molestias ipsa quae aspernatur.</p>
</div>
</div>
<!-- FOOTER -->
<nav class="navbar navbar-inverse navbar-fixed-bottom">
<div class="container">
<ul class="nav navbar-nav">
<li><i class="fa fa-facebook-official" aria-hidden="true" id="socialMedia"></i></li>
<li><i class="fa fa-twitter-square" aria-hidden="true" id="socialMedia"></i></li>
<li><i class="fa fa-youtube-square" aria-hidden="true" id="socialMedia"></i></li>
</ul>
</div> <!-- End container -->
</nav>
Add bottom margin to HTML instead of padding to body. This will prevent the footer from covering the content when scrolling to end of page. If you don't want the footer to cover at all then you'll have to use another approach instead of a fixed position.
html { margin-bottom: 65px }
jsFiddle: https://jsfiddle.net/azizn/b7Lq56kt/
html {margin-bottom: 65px}
p {padding:2em; border: 1px dashed #CCC}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="cotainer-fluid">
<div class="container">
<h1>Lorem ipsum dolor sit.</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptas beatae dolor consectetur ipsum minus impedit eaque reiciendis, quos vel ea eos? Inventore obcaecati laudantium incidunt quos ipsam. Optio, ipsa, tempora.</p>
<p>Maiores sed ab excepturi nobis exercitationem repudiandae dolores doloremque omnis. Reprehenderit placeat consequatur perferendis, aspernatur impedit eveniet odio ipsum, dignissimos libero qui omnis cum nihil non suscipit debitis repellendus autem.</p>
<p>Ipsum excepturi possimus pariatur enim mollitia repellat assumenda consequuntur. Maxime, amet, perspiciatis! Omnis praesentium sequi illum quisquam, perferendis doloremque possimus nihil facilis ipsum nam amet eos neque voluptates, dignissimos corrupti.</p>
<p>Reprehenderit possimus autem itaque eligendi inventore modi, temporibus consequatur tempore a magni! Sed soluta, minima quidem molestias animi accusamus voluptas nobis vel libero, natus voluptatum tempora magnam, labore, repellendus iste!</p>
<p>Eaque rem earum tenetur debitis consequuntur voluptate nobis numquam possimus temporibus, voluptas unde adipisci quisquam delectus corporis aliquam ut itaque! Rem minus accusamus ex, est sed molestias ipsa quae aspernatur.</p>
</div>
</div>
<!-- FOOTER -->
<nav class="navbar navbar-inverse navbar-fixed-bottom">
<div class="container">
<ul class="nav navbar-nav">
<li><i class="fa fa-facebook-official" aria-hidden="true" id="socialMedia"></i></li>
<li><i class="fa fa-twitter-square" aria-hidden="true" id="socialMedia"></i></li>
<li><i class="fa fa-youtube-square" aria-hidden="true" id="socialMedia"></i></li>
</ul>
</div> <!-- End container -->
</nav>
<div class="container">
<nav class="navbar navbar-inverse navbar-fixed-bottom">
...
</nav>
</div>
.container {
padding-top: 65px;
}
Wrap the nav with class .fixed-bottom with a .container <div> and give the parent <div> .padding-top.
Related
I have this page : and the problem there is that there's a vacant space below the white part. what I want is to extend the upper contents the (sidebar-nav and the main- content) to be full page.
<section id="left-sidebar-panel">
<div id="left-panel-content">
<img id="pictureShadow" src="/assets/images/main-photo.jpg">
<nav id="menu-links" >
<ul class="inline-block">
<li class="mb-4 mt-4 text-white">
<a href="/" class="text-3xl font-light flex" id="homePage">
#include("svgs.home")
Home
</a>
</li>
<li class="text-white mb-4">
<a href="/blogs" class="text-3xl hover:text-3xl flex" id="blogsPage">
#include("svgs.post")
Blogs
</a>
</li>
<li class="text-white mb-4">
<a class="text-3xl mt-2 flex" href="/podcasts" id="podcastsPage">
#include("svgs.microphone")
Podcasts
</a>
</li>
<li class="text-white mb-4">
<a class="text-3xl flex" href="/work">
#include("svgs.laptop")
Work
</a>
</li>
<li class="text-white mb-4">
<a class="text-3xl flex" href="/side-projects">
#include("svgs.projects")
Side Projects
</a>
</li>
</ul>
</nav>
</div>
</section>
<p class="text-xl text-normal">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed consequatur praesentium aliquid unde, debitis sit vel velit distinctio eligendi, nesciunt illum totam ad repudiandae. Pariatur dolor totam omnis eos eius ab debitis reprehenderit dicta, quidem, deleniti? Natus consequatur eum vel voluptatem illum doloremque dolores, id voluptatibus quas nam officia cumque dolor in, nobis maiores alias. Repellendus molestias quia nisi voluptas est voluptate ab quam voluptatum! Atque sequi magnam et iure sunt molestias ipsum odit ad repellendus reprehenderit hic temporibus possimus, totam eligendi quas amet accusantium dolores quibusdam dolorem, corrupti placeat perspiciatis animi velit. Odit quisquam ipsum voluptate quibusdam, et, placeat iure dolorum, expedita quia soluta cupiditate. Dicta cupiditate neque minus excepturi consectetur et, exercitationem fugit at enim ex libero. Debitis, omnis modi harum quisquam. Dicta, est esse fuga dolor doloremque architecto velit magnam eos nesciunt et natus ullam quasi error, eligendi. Autem dolorum debitis reiciendis alias atque fugiat aperiam soluta?</p>
Tried to use some different methods but nothing really happened. This is my code, how can I make it sticky to the top of the page when scrolling down?
When I tried it the nav was behind the photo's and the text on the page. Anyone who could help me out?
<!-- Header start -->
<header>
<div class="menu-area" id="">
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="logo">
<!--== change the logo name ==-->
<a href="index.html">
<h3><span>CHRISTIAAN</span>DESMET</h3>
</a>
</div>
<!-- Responsive Menu Start -->
<div class="responsive-menu"></div>
<!-- Responsive Menu End -->
</div>
<div class="col-md-9 col-sm-12">
<div class="mainmenu">
<nav>
<ul id="navigation">
<li class="current-page-item">home
</li>
<li>
<a href="#overmij">
over mij
</a>
</li>
<li>
producten
</li>
<li>contact</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
</header>
<!-- Header End -->
HTML:
<div id="navbar">
<!-- navbar content Here -->
</div>
CSS:
#navbar {
overflow: hidden;
background-color: #333;
}
/* when navbar reaches top this should be added using JS*/
.sticky {
position: fixed;
top: 0;
width: 100%;
}
/* Add some top padding to the page content to prevent sudden quick movement (as the navigation bar gets a new position at the top of the page (position:fixed and top:0) */
.sticky + .content {
padding-top: 60px;
}
JS:
// When the user scrolls the page, execute myFunction
window.onscroll = function() {myFunction()};
// Get the navbar
var navbar = document.getElementById("navbar");
// Get the offset position of the navbar
var sticky = navbar.offsetTop;
// Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky")
} else {
navbar.classList.remove("sticky");
}
}
Just add class name and change as per your requirement
.sticky {
position: -webkit-sticky;
position: sticky;
top: 0;
}
It seems you are also using Bootstrap, if so; what you want is really simple; you just have to add the sticky-top class to the navbar and you're good to go, see here:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Unde illum voluptatibus, laborum porro quibusdam officiis cum repudiandae iusto neque, consequatur consectetur error beatae maiores eaque ratione qui temporibus iste quisquam modi minima doloremque
iure. Cumque et labore incidunt alias enim magnam cum nam id ullam, modi nisi eos illo eaque amet hic eum ea natus consequatur necessitatibus! Asperiores, quaerat perspiciatis quibusdam laudantium sunt illo libero ex aspernatur dolores explicabo rem
architecto eos ipsa temporibus repudiandae itaque fugiat tempore ducimus ad eligendi reiciendis commodi. Molestiae ea necessitatibus in dolorum inventore vero et rerum dolore similique, dolores porro adipisci facilis, blanditiis obcaecati cumque, quisquam
voluptatibus nisi magni doloribus rem voluptatem explicabo quis accusantium quibusdam! At quo laudantium ad id eaque ex voluptas illum? Id, beatae. Ducimus, quam assumenda? Dignissimos ad iusto accusamus obcaecati, laudantium blanditiis nam non in repellat
iste repellendus suscipit magni est sapiente vero dolorem deserunt velit veritatis eius inventore?
</p>
<nav class="navbar navbar-expand sticky-top navbar-dark bg-primary">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Unde illum voluptatibus, laborum porro quibusdam officiis cum repudiandae iusto neque, consequatur consectetur error beatae maiores eaque ratione qui temporibus iste quisquam modi minima doloremque
iure. Cumque et labore incidunt alias enim magnam cum nam id ullam, modi nisi eos illo eaque amet hic eum ea natus consequatur necessitatibus! Asperiores, quaerat perspiciatis quibusdam laudantium sunt illo libero ex aspernatur dolores explicabo rem
architecto eos ipsa temporibus repudiandae itaque fugiat tempore ducimus ad eligendi reiciendis commodi. Molestiae ea necessitatibus in dolorum inventore vero et rerum dolore similique, dolores porro adipisci facilis, blanditiis obcaecati cumque, quisquam
voluptatibus nisi magni doloribus rem voluptatem explicabo quis accusantium quibusdam! At quo laudantium ad id eaque ex voluptas illum? Id, beatae. Ducimus, quam assumenda? Dignissimos ad iusto accusamus obcaecati, laudantium blanditiis nam non in repellat
iste repellendus suscipit magni est sapiente vero dolorem deserunt velit veritatis eius inventore?
</p>
<p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Unde illum voluptatibus, laborum porro quibusdam officiis cum repudiandae iusto neque, consequatur consectetur error beatae maiores eaque ratione qui temporibus iste quisquam modi minima doloremque
iure. Cumque et labore incidunt alias enim magnam cum nam id ullam, modi nisi eos illo eaque amet hic eum ea natus consequatur necessitatibus! Asperiores, quaerat perspiciatis quibusdam laudantium sunt illo libero ex aspernatur dolores explicabo rem
architecto eos ipsa temporibus repudiandae itaque fugiat tempore ducimus ad eligendi reiciendis commodi. Molestiae ea necessitatibus in dolorum inventore vero et rerum dolore similique, dolores porro adipisci facilis, blanditiis obcaecati cumque, quisquam
voluptatibus nisi magni doloribus rem voluptatem explicabo quis accusantium quibusdam! At quo laudantium ad id eaque ex voluptas illum? Id, beatae. Ducimus, quam assumenda? Dignissimos ad iusto accusamus obcaecati, laudantium blanditiis nam non in repellat
iste repellendus suscipit magni est sapiente vero dolorem deserunt velit veritatis eius inventore?
</p>
I have to design a "Rent A Flat" website as a school assignment using Dreamweaver and am having trouble finding my error. I added in a hover dropdown menu to a parallax design but it left all this white space next to the menu and put the image underneath the menu. Below is the code for my website. I don't know what to do anymore. I tried everything I could think of.
body, html{
height:100%;
margin:0;
font-size:16px;
font-family:"Lato", sans-serif;
font-weight:400;
line-height:1.8em;
color:#666;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: #06106E;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 80px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #ddd}
.dropdown:hover .dropdown-content {
display: inline-block;
}
.dropdown:hover .dropbtn {
background-color: #06106E;
}
.pimg1, .pimg2, .pimg3, .pimg4, .pimg5, .pimg6{
position:relative;
opacity:0.70;
background-position:center;
background-size:cover;
background-repeat:no-repeat;
/*
fixed = parallax
scroll = normal
*/
background-attachment:fixed;
}
.pimg1{
background-image:url('../Renting A House/Homepage/Image/pexels-photo-932095.jpeg');
min-height:100%;
}
.pimg2{
background-image:url('../Renting A House/Homepage/Image/agenda-appointment-business-1020323.jpg');
min-height:400px;
}
.pimg3{
background-image:url('../Renting A House/Homepage/Image/pexels-photo-1061576.jpeg');
min-height:400px;
}
.pimg4{
background-image:url('../Renting A House/Homepage/Image/Use instead of checkout.jpeg');
min-height:400px;
}
.pimg5{
background-image:url('../Renting A House/Homepage/Image/pexels-photo-276641.jpeg');
min-height:400px;
}
.pimg6{
background-image:url('../Renting A House/Homepage/Image/stairs-home-loft-lifestyle.jpg');
min-height:100%;
}
.section{
text-align:center;
padding:50px 80px;
}
.section-light{
background-color:#000040;
color:#ddd;
}
.section-dark{
background-color:#282e34;
color:#ddd;
}
.ptext{
position:absolute;
top:50%;
width:100%;
text-align:center;
color:#000;
font-size:27px;
letter-spacing:8px;
text-transform:uppercase;
}
.ptext .border{
background-color:#778899;
color:#000;
padding:20px;
}
.ptext .border.trans{
background-color:#C0C0C0;
}
#media(max-width:568px){
.pimg1, .pimg2, .pimg3, .pimg4, .pimg5, .pimg6{
background-attachment:scroll;
}
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Renting Your First Flat</title>
<link href="../Website Style.css" rel="stylesheet" type="text/css">
<link rel="icon" href="../house-key.png">
<div>Icons made by Roundicons from www.flaticon.com is licensed by CC 3.0 BY</div>
</head>
<body>
<div class="dropdown">
<button class="dropbtn"><input type="image" width="30px" height="30px" src="../Burger Dropdown Icon Menu.png" class="burger-menu"/></button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
<div class="pimg1">
<div class="ptext">
<span class="border">
Renting A Flat
</span>
</div>
</div>
<section class="section section-light">
<h2>Introduction?</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nesciunt eveniet dicta saepe mollitia nobis. Deleniti ratione dolor quas tempora quasi necessitatibus ipsa iusto voluptatibus sed veniam cum labore, excepturi reprehenderit odit accusamus dignissimos in modi culpa delectus, velit saepe repellat distinctio atque magnam quis. Accusantium enim voluptate quo delectus eveniet alias tempore temporibus maiores. Numquam, nostrum omnis vero dicta laboriosam ratione nisi pariatur veniam officiis quaerat dignissimos, sint cum obcaecati, sunt accusantium. Alias suscipit repellat mollitia, laboriosam, doloribus totam numquam sapiente quidem itaque eveniet iure sunt earum obcaecati vel! Vero quod unde officiis sit in facilis sed praesentium rem molestias.
</p>
<p>
About Us
</p>
</section>
<div class="pimg2">
<div class="ptext">
<span class="border trans">
Money
</span>
</div>
</div>
<section class="section section-dark">
<h2>Rent, Afford to Leave, Buy Furniture, Insurance, Flatmate to Share Costs</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima explicabo perferendis, quo eaque facilis architecto aut qui esse, eveniet, magnam ratione voluptatum aspernatur. Facere nemo ut aut alias commodi consequuntur ipsa sed eveniet. Accusamus animi tempore obcaecati blanditiis veniam, quaerat perferendis inventore exercitationem expedita, dolorem dolores quod cupiditate laborum incidunt autem distinctio, quisquam labore explicabo delectus molestiae? Delectus aperiam quis quae at consequatur iusto corrupti! Voluptatibus, fuga. Fugiat, numquam, rerum! Porro aliquam temporibus adipisci facere harum labore.
</p>
</section>
<div class="pimg3">
<div class="ptext">
<span class="border trans">
The Ins And Outs
</span>
</div>
</div>
<section class="section section-dark">
<h2>What Do You Need To Know?</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam ab maiores, dicta porro, omnis commodi corrupti quisquam nobis odit amet provident in quos libero deserunt non aut nesciunt ducimus laboriosam architecto ipsam quod repellat, incidunt animi sapiente cumque. Cumque, tempora expedita ab laborum. Possimus voluptatem dolorum ea magni facere, quod, atque vitae! Nemo consequuntur laboriosam maiores soluta consequatur culpa nulla maxime impedit inventore laborum voluptatibus eveniet molestiae quaerat suscipit adipisci repudiandae voluptatem iusto deserunt error architecto, ipsam nihil accusantium, cumque est vero. Impedit facilis aperiam hic eius voluptate rem atque numquam consequuntur, earum suscipit vero asperiores voluptates doloremque, laudantium temporibus.
</p>
</section>
<div class="pimg4">
<div class="ptext">
<span class="border trans">
Availability
</span>
</div>
</div>
<section class="section section-dark">
<h2>What To Look For/Available Flats?</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam quidem laudantium animi aut dolor distinctio cumque voluptate placeat iste esse eligendi, tempora accusantium repellat provident, mollitia cupiditate incidunt quasi perferendis alias laborum suscipit facere adipisci et facilis fugit. Quo sunt eos nam nulla nihil voluptates eius blanditiis consequuntur fuga, officia quaerat repellat, qui non repudiandae alias quod quis nostrum porro quia suscipit mollitia. Natus repudiandae fugiat sed enim vel repellat eligendi aperiam dolores necessitatibus suscipit iste dicta iusto dolorum quia, rerum, impedit, eum facilis? Quos vel consequuntur consectetur debitis, sed corporis quibusdam molestiae id quas. Dolore corporis aliquam a optio!
</p>
</section>
<div class="pimg5">
<div class="ptext">
<span class="border trans">
The Makings of a Flat
</span>
</div>
</div>
<section class="section section-dark">
<h2>Furnishing Your Flat?</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis beatae reprehenderit, voluptatibus molestias odio doloribus minima vitae amet temporibus ab voluptatum adipisci ut nemo at possimus voluptates quae sit ea accusantium quidem quibusdam velit error asperiores ipsam, quam. Quia, iure at, sequi sit earum vero cupiditate est hic laboriosam atque voluptatem tempora modi enim fugiat, esse dolorem incidunt deserunt quidem eveniet, odio omnis. Officia iusto quod, enim soluta eos optio commodi ab. Quasi accusamus porro explicabo, a ducimus, amet labore alias atque consequatur molestiae, eius temporibus adipisci assumenda voluptas minus perspiciatis? Id rem quisquam explicabo fuga esse ipsum provident quo!
</p>
</section>
<div class="pimg6">
<div class="ptext">
<span class="border">
Real Estate
</span>
</div>
</div>
<div>Icons made by Cole Bemis from www.flaticon.com is licensed by CC 3.0 BY</div>
</body>
</html>
here is my try I am not sure is that what you want. Any more changes let me know. I have moved menubox on top of the background image.
I wrapped the .dropdown and .pimg1 with a div
<div class="header-wrapper">
<div class="dropdown">
<button class="dropbtn"><input type="image" width="30px" height="30px" src="http://placeholder.pics/svg/30" class="burger-menu"/></button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
<div class="pimg1">
<div class="ptext">
<span class="border">
Renting A Flat
</span>
</div>
</div>
</div>
css
.header-wrapper{
clear: both;
position: relative;
}
.dropdown {
position: absolute;
display: inline-block;
z-index: 2;
}
live link: https://codepen.io/anon/pen/QxLReY?editors=1100
I have a section of a site that uses an h2, followed by an accordion. I am trying to have the accordion and h2 pull-left, however the accordion is the wrong size, unless it is expanded in which it enlarges itself. I have a sidebar column set up as so: <div class="col-md-3">
thus I want the h2, and accordion to be to the right of that but take up the full screen on the right of that. My accordion and h2 is set up as follows:
<div class="col-md-9 pull-right">
<div class="panel-body">
<h2 class="page-header col-md-9 pull-left">Action Strategies: What We Can Do Now</h2>
<div class="panel-group col-md-9 pull-left" id="accordion">
with each panel like so:
<!-- /.panel -->
<div class="panel panel-default">
<div class="panel-heading teachers">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">Teachers and Support Staff</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
<!-- content -->
</div>
</div>
</div>
As I understood your problem, pull-right is causing it. Please see the attached snippets if this is was you need.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="col-md-3">
<h3>Sidebar</h3>
<div>Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro esse officiis ipsa, placeat praesentium laborum rerum iste aspernatur omnis ratione exercitationem eligendi. Soluta id ipsa nisi ex! Cumque, voluptatum laudantium hic, ea cum, vitae aperiam expedita delectus autem iusto nam voluptatem dolorum fugiat? Laudantium minima, eos eius harum voluptatem error!</div>
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-12">
<h2 class="page-header col-md-9 pull-left">Action Strategies: What We Can Do Now</h2>
</div>
</div>
<div class="panel-group " id="accordion">
<div class="panel panel-default">
<div class="panel-heading teachers">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse1">Teachers and Support Staff 1</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quos architecto atque nemo nisi explicabo dolor. Magni perferendis modi vero pariatur officia consectetur, vitae id. Aspernatur officia nam ipsum ea dolorum laborum error maxime quidem provident rerum facere eum, unde? Ducimus quos provident adipisci, odit porro itaque eligendi beatae obcaecati tenetur minima officiis libero, nesciunt quidem autem ex cupiditate ratione veniam repellat est consequuntur quibusdam aut suscipit at. Provident quod, dolor quae incidunt vitae non neque, molestiae minus veritatis deleniti eligendi laboriosam blanditiis nostrum eum quia qui voluptas nemo expedita aliquam dolorum nihil. Quas dolor neque voluptatibus quos optio reprehenderit, impedit?
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading teachers">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse2">Teachers and Support Staff 2</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui ex laboriosam libero suscipit natus, voluptatibus, perferendis eos omnis impedit minima fugit a ipsum ipsa rem numquam placeat provident magnam asperiores mollitia vero magni laudantium pariatur. Obcaecati error rem dolor itaque quidem eligendi, voluptas vero voluptatem, labore adipisci perferendis quia velit reiciendis illo libero optio. Aliquam autem labore voluptas veritatis praesentium, in a tempore accusamus error ad laboriosam omnis consequuntur, pariatur dolor voluptates dolores vel. Repellat animi tenetur expedita nobis est a natus hic adipisci eligendi aliquam quo minus, dolorum nihil provident odit delectus suscipit omnis nostrum quod magni, voluptatum. Laboriosam!
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading teachers">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse3">Teachers and Support Staff 3</a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Obcaecati, voluptatem, itaque cumque dolorem dicta eveniet porro voluptatibus unde ad nostrum est accusantium veniam, iste natus incidunt quis consectetur quod placeat deserunt corporis veritatis quidem! Eaque facilis quasi, rem reiciendis! Voluptatibus quasi, necessitatibus repellendus impedit, fugit minima vero eius, perferendis dignissimos vel nulla velit! Error commodi veniam maxime reprehenderit aut sint voluptatem id culpa autem corrupti optio expedita blanditiis odit dolorem obcaecati vitae delectus ea necessitatibus beatae laboriosam aliquid, eos eveniet nobis quos quidem? Quia itaque dicta quasi perferendis earum, fuga illo aperiam architecto nisi iure suscipit omnis esse facilis, saepe.
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I would like to know how I can avoid the big whitespace using float: left, all the block does not have the same height
here's a demo
<div class="container">
<div class="block">
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laudantium, molestias vel quia ratione a nostrum quae provident facere perspiciatis commodi!</div>
</div>
<div class="block">
<div class="content">Est, eaque, enim? Illo, incidunt, molestias aut expedita aspernatur consectetur quos sit accusantium hic mollitia beatae numquam itaque excepturi eaque.</div>
</div>
<div class="block">
<div class="content">Nihil, quibusdam animi voluptatum modi pariatur aliquam adipisci nostrum placeat eos atque maxime odit optio molestias nisi dignissimos. Cum, vel?</div>
</div>
<div class="block">
<div class="content">Tempore, adipisci voluptatibus iure temporibus aut hic deleniti inventore accusantium excepturi vel et omnis veritatis itaque nesciunt odit ut nemo?</div>
</div>
<div class="block">
<div class="content">Voluptas, dignissimos, reiciendis, rem quasi neque quia molestiae in consequatur animi at et qui sint nihil ipsum corrupti totam repudiandae?</div>
</div>
<div class="block">
<div class="content">Tempora, velit, incidunt a est sed nostrum optio suscipit in sint eveniet architecto pariatur culpa asperiores minus praesentium perspiciatis dignissimos.</div>
</div>
<div class="block" style="height:200px"><!-- this height is for example, the height can be higher or lower -->
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam, enim, quidem laudantium quo iusto deleniti sed assumenda placeat dolorem est?</div>
</div>
<div class="block">
<div class="content">Earum, ut, laudantium, eaque, quaerat architecto officiis magni iusto eum nesciunt asperiores illum sit. Et officiis modi tempore mollitia sunt.</div>
</div>
<div class="block">
<div class="content">Nobis, placeat, tenetur tempore facere reiciendis illo reprehenderit sunt a ratione hic deleniti quaerat fuga ex minus eum culpa laborum.</div>
</div>
<div class="block">
<div class="content">Qui, nostrum, ab, totam, molestias quaerat expedita saepe odit accusamus reiciendis rerum officia provident iusto voluptate quis quos sit nisi.</div>
</div>
<div class="block">
<div class="content">Eum, dolorem, qui, autem dolorum et molestiae asperiores rerum eius minus iste quaerat labore distinctio vel cum quis atque consequatur.</div>
</div>
<div class="block">
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iure est magni necessitatibus consequatur deleniti aut veniam repellat quis similique ab.</div>
</div>
<div class="clear"></div>
</div>
Style.css
body {color:white;}
.clear{clear: both;}
.block {float:left;width: 50%;height:100px;}
.content {margin: 10px; padding: 10px; background-color: #000;}
Using regular css you can't really avoid the whitespace underneath each of your elements.
The only way to do it with css would be to have all of your content arranged in columns, not all actually floated left.
Most people get around this problem by using a plugin such as http://masonry.desandro.com/ which uses jQuery/JavaScript to make it work.
Hope that helps.