I'm building a site in BootStrap and my scroll disapepeared completely. I now can't scroll up and down. Why is that? I already tried overflow, overflow-y, but I don't understand what I'm doing wrong.
HTML
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<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>
<a class="navbar-brand" href="#">Sugoi!</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="Anime">Anime</li>
<li class="Manga">Manga</li>
<li class="Jogos">Jogos</li>
<li class="Opiniao">Opinião</li>
<li class="Outros">
Outros <b class="caret"></b>
<ul class="dropdown-menu">
<li>AMV</li>
<li>Cosplay</li>
<li>Passatempos</li>
</ul>
</li></ul>
<ul class="pull-right nav navbar-nav">
<li>Sobre</li>
<li>Contacto</li>
</ul>
</div>
</div>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Sugoi!</h1>
<div class="jumbotron">
<div class="container">
<a href="http://google.com"><h1>Persona 4 - The Animation</h1>
<p>Sabe mais!</p></a>
</div>
</div>
</div>
<p class="lead">Pin a fixed-height footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS. A fixed navbar has been added within <code>#wrap</code> with <code>padding-top: 60px;</code> on the <code>.container</code>.</p>
<p>Back to the default sticky footer minus the navbar.</p>
</div>
</div>
<div id="footer">
<div class="container">
<p class="text-muted credit">Example courtesy Martin Bean and Ryan Fait.</p>
</div>
</div>
</div>
CSS
/* Sticky footer styles
-------------------------------------------------- */
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by its height */
margin: 0 auto -60px;
/* Pad bottom by footer height */
padding: 0 0 60px;
}
/* Set the fixed height of the footer here */
#footer {
height: 60px;
background-color: #f5f5f5;
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
#wrap > .container {
padding: 60px 15px 0;
}
.container .credit {
margin: 20px 0;
}
#footer > .container {
padding-left: 15px;
padding-right: 15px;
}
code {
font-size: 80%;
}
.jumbotron {
background-image:url('http://tomodom.com/wp-content/uploads/2013/07/Persona4Golden_Hero.jpg');
height:400px
}
The Div with the fixed position called "" doesn't close until after the page content, which is located just before the div with the id of Footer. Instead it should finish at the end of the nav section.
Copy this.
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<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>
<a class="navbar-brand" href="#">Sugoi!</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="Anime">Anime</li>
<li class="Manga">Manga</li>
<li class="Jogos">Jogos</li>
<li class="Opiniao">Opinião</li>
<li class="Outros">
Outros <b class="caret"></b>
<ul class="dropdown-menu">
<li>AMV</li>
<li>Cosplay</li>
<li>Passatempos</li>
</ul>
</li></ul>
<ul class="pull-right nav navbar-nav">
<li>Sobre</li>
<li>Contacto</li>
</ul>
</div>
</div>
</div>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Sugoi!</h1>
<div class="jumbotron">
<div class="container">
<a href="http://google.com"><h1>Persona 4 - The Animation</h1>
<p>Sabe mais!</p></a>
</div>
</div>
</div>
<p class="lead">Pin a fixed-height footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS. A fixed navbar has been added within <code>#wrap</code> with <code>padding-top: 60px;</code> on the <code>.container</code>.</p>
<p>Back to the default sticky footer minus the navbar.</p>
</div>
</div>
<div id="footer">
<div class="container">
<p class="text-muted credit">Example courtesy Martin Bean and Ryan Fait.</p>
</div>
</div>
Related
I would like to make one page scroll. Nav bar. Then a full width picture. than about me page, porfolio / projects and contact me. But it seems like am doing something wrong with the layout. Please help.
.navbar {
min-height: 80px;
margin-bottom: 0;
}
#btnnavbar {
margin-top: 20px;
}
#btnhome {
margin-top: 16px;
}
#imgbrand {
margin-top: -70px;
margin-left: px;
height: 220px;
width: 280px;
}
#firstpage {
margin-top: 90px;
}
.fixed-bg {
/* The background image */
background-image: url("http://res.cloudinary.com/ekilja01/image/upload/v1478095932/DeathtoStock_Lonely_Commute-05_ricqva.jpg");
/* Scale the background image to be as large as possible */
background-size: cover;
min-height: 100%;
min-width: 1024px;
/* Set up proportionate scaling */
width: 100%;
height: auto;
/* Set up positioning */
position: fixed;
top: 0;
left: 0;
}
<html>
<head>
</head>
<body>
<!-- Navbar style available in Bootstrap framework-->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<!-- /end-->
<!-- Anything that has to be responsive we are going to keep inside the Bootstrap grid -->
<div class="container-fluid">
<!-- /end -->
<div class="navbar-header">
<button type="button" class="navbar-toggle btn-lg" data-toggle="collapse" data-target=".navbar-collapse" id="btnnavbar">
<!-- For screen readers only -->
<span class="sr-only">Toggle navigation</span>
<!-- /end -->
<!-- Hamburger menu button appears when browser window has been shrinked -->
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- /end -->
<!-- Brand and toggle get grouped for better mobile display -->
<a class="navbar-brand " href="http://codepen.io/ekilja01">
<img class="img-responsive" id="imgbrand" src="http://www.kiljakandweb.com/favicon.png" alt="brand logo">
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li id="btnhome">About
</li>
<li id="btnhome">Portfolio
</li>
<li id="btnhome">Contact
</li>
</ul>
</div>
</div>
</div>
</nav>
<div class="fixed-bg">
<div class="row">
<div class="col-lg-10 col-lg-offset-1 text-center">
<h1 class="text-center">1.4.1.3</h1>
<p>fafafa</p>
<div>
</div>
</div>
<div class="row">
<div class="col-lg-10 col-lg-offset-1 text-center">
<h1>Code</h1>
</div>
</div>
</body>
</html>
I am trying to create a full container image that is centered nicely on all screens.
<body>
<!-- Preloader -->
<div class="page-loader">
<div class="loader">Loading...</div>
</div>
<!-- Navigation start -->
<nav class="navbar navbar-custom navbar-transparent navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#custom-collapse">
<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="index.html">
<img src="assets/images/kerriwalshjenningswhite.png" alt="Kerri Walsh">
</a>
</div>
<div class="collapse navbar-collapse" id="custom-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
Home
</li>
<li class="dropdown">
Gallery
</li>
<li class="dropdown">
Sponsors
</li>
<li class="dropdown">
Bio
</li>
<li class="dropdown">
Contact
</li>
</div>
</div>
</nav>
<!-- Navigation end -->
<!-- Home start -->
<section id="home" class="home-section home-parallax home-fade kenburns home-full-height">
<div class="hero-slider">
<ul class="slides">
<li class="bg-light-30">
<div class="img">
<img src="assets/images/kerribig4.jpg" />
</div>
<div class="hs-caption">
<div class="caption-content">
<p class="hs-title-size-1 font-serif mb-30">
Hello & welcome
</p>
<h1 class="hs-title-size-5 font-alt mb-40">
I am Kerri Walsh
</h1>
Learn More
</div>
</div>
</li>
<li class="bg-light">
<div class="img">
<img src="assets/images/kerribig3.jpg" />
</div>
<div class="hs-caption">
<div class="caption-content">
<p class="hs-title-size-1 font-serif mb-30">
I am
</p>
<h1 class="hs-title-size-5 font-alt mb-40">
A Mother
</h1>
Learn More
</div>
</div>
</li>
<li class="bg-light">
<div class="img">
<img src="assets/images/kerribig2.jpg" />
</div>
<div class="hs-caption">
<div class="caption-content">
<p class="hs-title-size-1 font-serif mb-30">
I am
</p>
<h1 class="hs-title-size-5 font-alt mb-40">
An Olympian
</h1>
Learn More
</div>
</div>
</li>
</ul>
</div>
</section >
<!-- Home end -->
And then here is the first part of my style.css. I need to make this image appear a in the center of the screen on mobile so you can actually see Kerri Walsh
html {
overflow-y: scroll;
overflow-x: hidden;
-ms-overflow-style: scrollbar;
}
body {
background: #fff;
font: 400 13px/1.8 "Lato", sans-serif;
color: #666;
-webkit-font-smoothing: antialiased;
}
img {
/*width: 100%; */
height: 100%;
}
If you want this to be a background image, which I think you want.
Then you can use this method:
.home-section {
/* Location of the image */
background-image: url(images/background-photo.jpg);
/* Background image is centered vertically and horizontally at all times */
background-position: center center;
/* Background image doesn't tile */
background-repeat: no-repeat;
/* Background image is fixed in the viewport so that it doesn't move when
the content's height is greater than the image's height */
background-attachment: fixed;
/* This is what makes the background image rescale based
on the container's size */
background-size: cover;
/* Set a background color that will be displayed
while the background image is loading */
background-color: #464646;
}
It's responsive and will look good on all screens. And yes, you can ofcourse change the background images using jQuery or native JavaScript just like you've done with the images.
Best regards,
I would like to fit navbar options in all the container like this:
Tried using this website methods, but couldn't get it working, it broke my responsive.
Can anyone please explain me best way using bootstrap?
Thank you
i created a fiddle for you take a look, it may help you.
use margin for doing this
.navbar.navbar-default.navbar-fixed-top {
margin: 6px 10px 0px 5px;
}
#blue{background-color:blue !important; height: 57px;}
.navbar-collapse.in,
.navbar-collapse.collapsing {
clear: left;
}
.navbar.navbar-default.navbar-fixed-top {
margin: 6px 10px 0px 5px;
}
#blue{background-color:blue !important; height: 57px;}
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div id="blue">
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header pull-left">
<a class="navbar-brand" href="index.php">xxx</a>
</div>
<div class="navbar-header pull-right">
<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>
<p class="navbar-text">
<b> '.$username.' </b>
Logout
</p>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
<!-- Post Info -->
<div style='position:fixed;bottom:0;left:0;
background:lightgray;width:100%;'>
About this SO Question: <a href='http://stackoverflow.com/q/18900593/1366033'>navbar float right moves div to new line</a><br/>
Find documentation: <a href='http://getbootstrap.com/css/'>Get Bootstrap 3.0</a><br/>
Fork This Skeleton Here <a href='http://jsfiddle.net/KyleMit/kcpma/'>Bootrsap 3.0 Skeleton</a><br/>
External JS File: <a href='http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js'>bootstrap.min.js</a><br/>
External Style Sheet: <a href='http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js'>bootstrap.min.css</a><br/>
External Fonts / Icons: <a href='http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css'>font-awesome.min.css</a>
<div>
</div>
fiddle here
I am trying to create a layout where I have a header (nav) of fixed height in px, a footer of fixed px as well and a div in between them that occupies the remaining space.
Broken Demo: http://jsfiddle.net/murid/0vcyqm3y/
What I'm trying to achieve is for that blue div to go all the way down to the footer. Keeping in mind that I'm using a "push" div to get the footer to sit at the bottom of the page in case the content of the page is short and that said content can be very long as well therefore pushing the footer down.
I've checked out similar questions on Stackoverflow but answers involve position absolute, JavaScript, or background color on the body, I'm trying to avoid all of these and have a simple CSS only solution with background color on the content div.
I'm using Bootstrap btw.
CSS and HTML:
html,
body {
height: 100%;
}
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
margin-bottom: -50px;
}
nav.navbar {
margin-bottom: 0;
}
section {
padding: 10px 0;
margin-left: -15px;
margin-right: -15px;
}
.section-primary {
background: #337ab7;
}
section > .row {
margin-left: 0;
margin-right: 0;
}
footer,
.push {
height: 50px;
}
<div id="wrap">
<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="">Logo</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
Logout
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<section class="section-md section-primary">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-body">
Panel Body
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<div class="push"></div>
</div>
<footer>
<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Copyright</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
Logout
</li>
</ul>
</div>
</div>
</nav>
</footer>
I have to say I'm not a fan of this.. but this is the only CSS solution I know..
http://codepen.io/pacMakaveli/pen/EjWXNw?editors=110
Otherwise, for a cleaner way, use flexbox.
html,
body {
height: 100%;
}
#wrap {
height: 100%;
display: table;
width: 100%;
border: 2px solid green;
}
#wrap > nav,
footer {
display: table-row;
}
nav.navbar {
margin-bottom: 0;
}
section {
padding: 10px 0;
margin-left: -15px;
margin-right: -15px;
}
.section-primary {
background: #337ab7;
}
.content {
border: 3px solid red;
display: table-cell;
height: 100%;
}
section > .row {
margin-left: 0;
margin-right: 0;
}
<div id="wrap">
<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="">Logo</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
Logout
</li>
</ul>
</div>
</div>
</nav>
<div class="content">
<div class="container-fluid">
<section class="section-md section-primary">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-body">
Panel Body
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
<footer>
<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Copyright</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
Logout
</li>
</ul>
</div>
</div>
</nav>
</footer>
</div>
I am getting an unwanted space like this between red color div and header
my html is i've give 0 value for margin and padding for html and body.But still there's a problem please help
<header>
<nav role="navigation" class="navbar navbar-fixed navbar-inverse">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle nav-button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
Example
</div>
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav nav-ul">
<li id="tech" class="nav-list"> home</li>
<li id="politics" class="nav-list"> careers</li>
<li id="crime" class="nav-list"> about</li>
<li id="business" class="nav-list"> contact</li>
</ul>
</div>
</nav>
</header>
<section class="frontpage">
<div class="container">
<div class="row">
<div class="col-md-5">
</div>
</div>
</div>
</section>
<section class="ghi">
<div class="container">
<div class="row">
<div class="col-md-5">
</div>
</div>
</div>
</section>
and css is i've also tried giving 0 padding and margins for div and header
body,html {
margin:0;
padding:0;
}
header{
margin:0;
padding:0;
}
.frontpage{
background:red;
height:200px;
margin:0;
padding:0;
}
.ghi{
background:blue;
height:220px;
}
use it
.navbar{
margin-bottom: 0!important;
}
body,html {}
header{}
.frontpage{
background:red;
height:200px;
}
.ghi{
background:blue;
height:220px;
}
.navbar{
margin-bottom: 0!important;
}
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<header>
<nav role="navigation" class="navbar navbar-fixed navbar-inverse">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle nav-button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
Example
</div>
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav nav-ul">
<li id="tech" class="nav-list"> home</li>
<li id="politics" class="nav-list"> careers</li>
<li id="crime" class="nav-list"> about</li>
<li id="business" class="nav-list"> contact</li>
</ul>
</div>
</nav>
</header>
<section class="frontpage">
<div class="container">
<div class="row">
<div class="col-md-5">
</div>
</div>
</div>
</section>
<section class="ghi">
<div class="container">
<div class="row">
<div class="col-md-5">
</div>
</div>
</div>
</section>
It is because the Browser is adding default margins to the ul Elements. Add this style to your css and it should fix the issue:
ul.nav { margin-bottom: 0 !important; }
Just in case someone else have same problem. I fixed it based on reading https://css-tricks.com/fighting-the-space-between-inline-block-elements/ in my case just added this line margin-bottom: -10px;