Material Design Lite and Bootstrap Sticky Footer - css

I am building a site where I use the Bootstrap Sticky Footer and Navbar. However, with Google's recent release of the Material Design Lite library, I want to use the cards for a portion of my site. However, as soon as I include the MDL library (just the CSS, no other changes), my sticky footer does something odd. The footer is set to the bottom of the viewport (no matter the height of that window) but then it just sticks there. If I scroll up, it scrolls up as well.
When I actually inspect the footer, body, etc., I see nothing that is affecting the layout from the material design CSS. Something obviously is, but I'm fairly stuck on what it might be. (To see it work, remove the reference to the material-lite.css. Currently it is broken within the snippet.)
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
padding-bottom: 20px;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
color: white;
background-color: black;
}
#footer-content {
margin: 20px 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.0/material.min.css" />
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a asp-controller="Home" asp-action="Index" class="navbar-brand">
<i class="fa fa-globe fa-lg visible-sm visible-xs"></i>
<i class="fa fa-globe fa-3x hidden-sm hidden-xs"></i>
</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav main-links">
<li><a asp-controller="Home" asp-action="Index">Home</a>
</li>
<li><a asp-controller="Home" asp-action="About">About</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<img src="http://placekitten.com/300/450" />
<br/>
<img src="http://placekitten.com/300/450" />
<br/>
</div>
<footer>
<div class="container">
<div id="footer-content" class="pull-right">
My Footer
</div>
</div>
</footer>

I found the correct solution to keeping footer stuck to bottom even if the content of a new tab is a different height.
https://github.com/google/material-design-lite/issues/913
This js fiddle specifically had useful html and css.
http://jsfiddle.net/eggbox/gk7u32b6/
In short add this to your html above the footer
<style>
.mdl-layout__content {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: column nowrap;
-ms-flex-flow: column nowrap;
flex-flow: column nowrap;
}
.mdl-layout__content > *:not(.mdl-layout-spacer) {
-webkit-flex: none;
-ms-flex: none;
flex: none;
}
</style>
<div class="mdl-layout-spacer"></div>
<footer class="mdl-mini-footer">
<div class="mdl-mini-footer--middle-section">
<div class="mdl-logo">Title</div>
<ul class="mdl-mini-footer--link-list">
<li>Help</li>
<li>Privacy & Terms</li>
</ul>
</div>
</footer>

This should fix your problem. See plunker
html {
height: auto;
}

Related

Making a responsive navbar layout with two logos and centered text

I need to do a responsive navbar with:
LOGO1(left side) text(centered) LOGO2(right side)
I am trying the next but It doesnt work when when resized to small screens.
Here is my problem: when in "lg" size the screen is correct. But when in "md" size or smaller the LOGO2 goes to left side.
And, in 'xs' size the 'text' continues showing with the LOGO2 below it.
In my markup code I have some angular staff, but it is not important to answer the question.
What am I doing wrong?
//markup
div class="container-fluid example2">
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" ng-click="isMyNavCollapsed = !isMyNavCollapsed" ng-init="isMyNavCollapsed=false">
<span class="sr-only">Navegação</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand"><img src="img/SoundCloud64.png" alt="Cloud Clínica">
</a>
</div>
<p class='navbar-text navbar-center font35'><strong>Retire seu ticket aqui</strong></p>
<div class="collapse navbar-collapse" id="navbar_right" uib-collapse="isMyNavCollapsed">
<ul class="nav navbar-nav navbar-right">
<li><img class="img-responsive" height="150" width="200" src="img/red-ticket-md.png" /></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container-fluid -->
</nav>
</div>
//css
<style type="text/css">
.example2 .navbar-brand>img {
padding: 7px 15px;
}
.navbar-right img{
padding: 7px 15px;
}
.navbar-center
{
display:inline-block;
position: absolute;
width: 100%;
left: 0;
top: 0;
text-align: center;
overflow: visible;
height: 0;
padding:15px 10px 10px 10px;
z-index: 10099;
}
.navbar-nav,
.navbar-right {
display:inline-block;
position: relative;
z-index: 100100;
}
</style>

How do i remove this unwanted gap between my navabar and featured image? [duplicate]

This question already has answers here:
Mysterious whitespace in between Bootstrap2 Navbar and row underneath
(2 answers)
Closed 5 years ago.
I am creating a website with bootstrap, and I encountered a problem when I created a featured image with a parallax effect. It seems that something is creating a space between the navigation bar (Bootstrap) and the featured image.
.parallax {
background-image: url("../images/aboutHeader.jpg");
height: 100%;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.parallax h2 {
color: white;
font-size: 4em;
text-align: center;
padding-top: 100px;
}
<!-- NAVBAR
================================================== -->
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img src="images/headerWhite.png" alt="Bird's Aerial Imaging LC" style="height:100%">
</a>
</div>
<div class="collapse navbar-collapse navbar-right" id="myNavbar">
<ul class="nav navbar-nav">
<li>Home</li>
<li class="active">About</li>
<li>Gallery</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
<!-- FEATURED IMAGE =============================================================== -->
<section style="height:250px;">
<div class="parallax">
<h2>About Us</h2>
</div>
</section>
What I understood from you that you mean the white vertical space between the parallax div and the navbar and my answer will depend on that, if your problem is different please let me know.
Your solution is all about removing:
1) The margin property from the "h2":
.parallax h2 {
margin-top: 0;
}
2) The padding property from the "navbar":
.navbar {
padding-bottom: 0;
}
Hope it works with you!
You can add position:absolute; top:0; to your section tag. That will definitely remove the space...
It could also be because of default margin or padding around the section. Try to add margin:0; padding:0; to that

.nav-tabs behaving inappropriate when .navbar-brand is assigned to its sibling element

I have commented out the bug(with #characters) in the navigation part of the code where I am getting the issue. Try removing the .navbar-brand as mentioned in the comment and you will get to see.
I'm curious to know that what's happening under the hood when navbar-brand is assigned to its(element with .nav-tabs) adjacent element which conflicting with it
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="author" content="NeelDUnstoppable" />
<meta name="description" content="A rough template for html page created just for enhancing and getting a precise grip over the rules" />
<title>html template</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="css/main.css" rel="stylesheet" />
</head>
<body>
<div class="nav" role="navigation">
<!-- ######## Remove the .navbar-brand class from the below <a> element and the .nav-tabs class in <ul> element works completely fine ######### -->
Blasting off with bootstrap
<ul class="nav nav-tabs">
<li role="presentation" class="active">Tickets</li>
<li role="presentation">Stations</li>
<li role="presentation">About</li>
</ul>
</div>
<div class="container">
<div class="row well well-lg">
<div class="col-md-6">
<h2>The Fastest way to space</h2>
<p class="lead">Make your way to space in the comfort of your own rocket, elevator or transporter.</p>
<button type="button" class="btn btn-lg btn-default">Take the Tour</button>
<button type="button" class="btn btn-lg btn-primary">Book Tickets Now</button>
</div>
<div class="col-md-6 hidden-sm hidden-xs">
<img src="images/img-header.jpg" alt="Blasting off" title="Blasting off image"/>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row text-center features">
<div class="col-sm-4 col-xs-10 col-xs-offset-1 col-sm-offset-0">
<i class="glyphicon glyphicon-briefcase"></i>
<h3>Book Today</h3>
<p>Even if you're traveling tomorrow, you can still get tickets today. We have a number of conveniently located ports around teh globe to service everyone</p>
</div>
<div class="col-sm-4 col-xs-6">
<i class="glyphicon glyphicon-random"></i>
<h3>Go Anywhere</h3>
<p>If you need to get to space today, why not try out a transporter? Despite the claims, there are have been no deaths in the last 6weeks!</p>
</div>
<div class="col-sm-4 col-xs-6">
<i class="glyphicon glyphicon-send"></i>
<h3>RocketBus®</h3>
<p>For cheapest fares, catch the next RocketBus® to the stars. Cheaper on you wallet, and easiest way to make friends</p>
</div>
</div>
</div>
<div class='footer'>
<div class='container'>
<div class='row'>
<div class='col-sm-4 col-md-3 col-xs-6'>
<h4>Who We Are</h4>
<p><i>Blasting Off With Bootstrap</i> is the fastest way to space. <a href='#'>Book your ticket today</a>!</p>
<p><a href='#'>More About Us <i class='glyphicon glyphicon-arrow-right'></i></a></p>
</div>
<div class='col-sm-2 col-xs-6 col-md-offset-1'>
<h4>Links</h4>
<ul class='list-unstyled'>
<li><a href='#'>Home</a></li>
<li><a href='#'>Tickets</a></li>
<li><a href='#'>Stations</a></li>
</ul>
</div>
<div class='clearfix visible-xs'></div>
<div class='col-sm-2 col-xs-6'>
<h4>Stay in Touch</h4>
<ul class='list-unstyled'>
<li><a href='#'>About</a></li>
<li><a href='#'>Contact Us</a></li>
<li><a href='#'>Blog</a></li>
<li><a href='#'>Twitter</a></li>
<li><a href='#'>Facebook</a></li>
</ul>
</div>
<div class='col-sm-4 col-md-3 col-md-offset-1 col-xs-6'>
<h4>Contact Us</h4>
<ul class='list-unstyled'>
<li><i class='glyphicon glyphicon-globe'></i> Orlando, FL<li>
<li><i class='glyphicon glyphicon-phone'></i> 1-555-blast-off<li>
<li><i class='glyphicon glyphicon-envelope'></i> <a href='mailto:#'>blastingoff#codeschool.com</a><li>
</ul>
<p>Blasting Off With Bootstrap ©2214.</p>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script>
</body>
</html>
The related .css file:
.features .glyphicon {
font-size: 32px;
}
.row {
margin-bottom: 20px;
}
.quote {
background-color: #444;
color: #e1e1e1;
}
.quote blockquote {
border: none;
margin: 0;
}
.quote footer {
color: #c1c1c1;
}
section, header {
background-color: #fff;
}
body {
}
.footer {
padding: 20px 0;
}
/*
#demo-nav {
display: none;
}
.show-nav #demo-nav {
display: block;
}
*/
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 200px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 200px;
}
.footer {
color: #efefef;
background-color: #333;
}
.footer a {
color: #9af7fe;
}
#media only screen and (max-width: 768px) {
body { margin-bottom: 400px; }
.footer { height: 400px; }
}

Center first and last menu item with items above menu

Using bootstrap 3, I have:
<div class="container"> </div> {with specific width}
<div class="container-fluid">
<nav> <nav>
</div> {need container-fluid to make mnu background full width}
I would like to center first menu item with left edge of picture above and also last menu item to center with right edge of text above.
Here is a link to the JSFiddle demo.
Do maximize JS fiddle result window to see menu in full width
The idea is that space between all menu items is same. I try to get result with some padding of <a> tag and <li> tag, but for bigger screen I must then write queries. Hence, how do I have an "universal" solution?
How about using flexbox to add the property value space-between and justify your unordered list items, combined with a media query to prevent affecting your hamburger menu.
#media (min-width: 768px) {
.navbar-nav {
display: flex;
width: 100%;
justify-content: space-between;
align-items: center;
}
.navbar-nav > li {
display: flex;
}
.navbar-nav > li > a {
justify-content: center;
align-items: center;
}
}
jsfiddle
CODE SNIPPET:
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
.container {
width: 1100px;
padding: 0px;
}
.navbar-nav {
padding: 0;
margin: 0;
}
.menuCon {
background: grey;
}
#mainMenu > ul > li > a {
color: #000;
}
#media (min-width: 768px) {
.navbar-nav {
display: flex;
width: 100%;
justify-content: space-between;
align-items: center;
}
.navbar-nav > li {
display: flex;
}
.navbar-nav > li > a {
justify-content: center;
align-items: center;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container ">
<div class="row headRow">
<div class="col-xs-12 col-sm-12 col-md-4 borderRight width80">
<img src="https://placeholdit.imgix.net/~text?txtsize=20&txt=230%C3%9781&w=230&h=81" class="img-responsive logo" id="logo" alt="logo" />
</div>
<div class="hidden-xs col-sm-6 col-md-4 mobileMarginText ">
<div class="headerTextOne">
<div>top textttttt</div>text text</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 text-left ">
<p class=" headerPhone">12345678999 710</p>
<p class=" headerMail">hi#hello.com</p>
</div>
</div>
<!-- /row menu-->
</div>
<div class="container-fluid menuCont ">
<div class="row">
<div class="col-xs-12 col-md-12">
<nav class="navbar navbar-default noBorder height40 menuBox">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed " data-toggle="collapse" data-target="#mainMenu" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="mainMenu">
<ul class="nav navbar-nav">
<li>First
</li>
<li>Home1
</li>
<li>Home2
</li>
<li>Home3
</li>
<li>Home4
</li>
<li>Last
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</div>
</div>
</div>

specifying div height (bootstrap)

so I am trying to make a cool portfolio landing page with Bootstrap.
The template includes a fixed navbar and a sticky footer. The rest of the page is whtespace that I want to fill with basically a giant background so I put a test paragraph element to try and see how to size it. I figured I could just add CSS rules that made body's height 100% but when I do that I get an overflow and my footer isn't at the bottom of the page anymore. Instead I have a small overflow of the background at the bottom.
How can I fix this? I made the background color bright yellow to try and show what I mean. Any help is appreciated!
Here's the HTML
<!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">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Work in Progress</title>
</head>
<body>
<!--navbar-->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed"
data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Portfolio</a>
</div>
<div id="navbar" class="navbar-collapse collapse"
aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
<li>About</li>
<li>Contact</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
role="button" aria-haspopup="true"
aria-expanded="false">Projects
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Rails Projects</li>
<li>LAMP Projects</li>
</ul>
</ul>
</div>
</div>
</nav>
<div class="main">
<div class="container">
<p>Test text</p>
</div>
</div>
<!--footer-->
<footer class="footer">
<div class="container">
<div class="row">
<div class="col-md-4">
<p>Contact info or whatever goes here.</p>
</div>
<div class="col-md-4 col-md-offset-4">
<p>More info or whatever goes here.</p>
</div>
</div>
</div>
</footer>
</body>
</html>
And here's the CSS
html, body{
height: 100%
}
.main{
height: 100%;
background-color: #FFFF00;
margin-top: 50px;
}
.footer{
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #000;
color: #9d9d9d;
}
You can use this CSS (position: relative on body and .main height as calc function (100% minus height of the footer):
html,
body {
height: 100%;
position: relative;
}
.main {
height: calc(100% - 60px);
background-color: #FFFF00;
padding-top: 50px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #000;
color: #9d9d9d;
}
Demo: https://fiddle.jshell.net/uvaef49h/1/
You want to use the following CSS:
html, body{
height: 100%;
padding: 0;
margin: 0;
}
.main{
height: calc(100% - 110px);
background-color: #FFFF00;
margin-top: 50px;
}
.footer{
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #000;
color: #9d9d9d;
overflow: hidden;
}
Why did it not work before?
The body had a height of X, main occupied 100% of that. However main was pushed down by the 50px margin. After the .main part, you had your footer which was completely pushed out from the view-port so I had to remove another 60px from .mains height. The footer still had an overflow issue so I hid that.
Lastly, the browser wanted to add some random margin/padding so I Removed that as well.

Resources