I am facing an error while scrolling page, body contents overlaps the navbar.
I have content over navbar that should disappear when scrolling, it is working fine.
While scrolling navbar should be fixed, this is working fine.
Problem is while scrolling, body contents are sliding over navbar. It should go from behind the navbar.
I have an image slider below navbar
Here is the code of HTML file:
<div class="container-fluid" style="background-color:#F44336;color:#fff;height:200px;">
<div class="row">
<div class="col-sm-4" style="background-color:yellow; width:200px">
<img class="img-responsive img-rounded pull-left" src="img/logo 1.png" alt="Chania" width="200" height="200">
</div>
<div class="col-sm-4" style="background-color:pink;">
<h3>Fixed (sticky) navbar on scroll</h3>
<p>Scroll this page to see how the navbar behaves with data-spy="affix".</p>
<p>The navbar is attached to the top of the page after you have scrolled a specified amount of pixels.</p>
</div>
<div class="col-sm-4 text-right" style="background-color:yellow;width:200px;">
<img class="img-responsive img-rounded pull-right" src="img/logo 2.png" alt="Chania" width="200" height="200">
</div>
</div>
</div>
<nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="197">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="container-fluid">
<div class="navbar-header">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Menu</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
menu name..
</ul>
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
</form>
</div>
</div>
</nav>
CSS code of navbar:
.affix {
top: 0;
width: 100%; }
.affix + .container-fluid {
padding-top: 70px; }
CSS code for Slider
html, body {
height: 100%;}
.carousel, .item {
height: 70%; }
.carousel-inner {
height: 143%; }
.fill {
width: 100%;
height: 100%;
background-position: center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover; }
I am beginner in bootstrap.
Thanks.
You should put this in a fiddle but off the bat I would guess that your navbar should contain position:absolute; and z-index:1;
On seeing this query i have made jsfiddle for you just check it.. You are using affix for fixing navbar.
so in css just add the followings:
.affix{
width:100%;
top:0px;
}
And check with the z-index of your navbar keep high value for nabvar like z-index:9999;
JSfiddle link
All the coding looks good no issue with that. Just check my fiddle
Adding margin-top:30px; in the main Container would do what you are asking.
Related
I'm trying to create a login page for my application .It includes a header ,login form which is horizontally and vertically centered and a footer .Everything works fine in the normal mode but when i load it in mobile landscape mode footer overlaps the login form .Can anyone help me how to figure it out .I know the issue is due to fixed footer a the bottom but when i try to give position:absolute or position:relative the footer jumps near the header
.full-width{width:100%;}
.login-container{position: absolute;transform: translate(-50%, -50%);width: 330px;margin:auto;padding-bottom:100px;}
.parent {position:fixed;top: 50%;left: 50%;transform: translateY(-50%);margin-top:60px}
<nav class="navbar navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed bottom-line" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"
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>
<a class="navbar-brand logoLinkStyle" href="#">
<img [src]="'application/images/logo.png'" alt="Brand logo">
</a>
</div>
</div>
<!-- /.container-fluid -->
</nav>
<div class="parent">
<div class="row login-container">
<div class="col-lg-12">
<form name="form" #loginForm="ngForm" novalidate>
<h1 class="welcomeheading">WELCOME</h1>
<div class="form-group">
<input class="form-control user" name="username" placeholder="Username" aria-label="Username" required autofocus>
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" type="password" name="password" aria-label="Password" required>
</div>
<button class="btn full-width" [disabled]="loading">Login</button>
<div class="login-forgot">
Forgot your password?
</div>
</form>
</div>
</div>
</div>
<div class="container-fluid" style="position: fixed;bottom: 0;width: 100%;">
<div class="row">
<div class="col-lg-10 col-sm-12">
<h6>Copyright (c) 2017 this is the copyright of application developed
</h6>
</div>
<div class="col-lg-2 col-sm-12">
<img [src]="FooterLogo" alt="Footer logo" />
</div>
</div>
</div>
You could add a media query and remove the absolute positioning on mobile.
You'd have to calculate your height breakpoint, but it would look something like this:
#media screen and (max-height: 400px) {
.parent, .login-container {
position: static;
transform: none;
}
.footer {
position: relative;
}
}
I am developing a site, where I have Login div as part of header in Desktop view. Where as the same div has to be appear in Mobile menu along with existing menu items as shown below:
So, how to implement this as part of mobile menu item (Without using 2 Divs for hide/show) using Bootstrap?
You could use the navbar class for your header. And then bootstrap will automatically behave that way. Otherwise you should use the media query.
Or you could use the visible-xs, visible-sm, etc. bootstrap classes (with mulitple div's), to handle what is viewed on which device.
first of all this is no javascript / jquery question.
What you wannt to do is explained here
See how aspects of the Bootstrap grid system work across multiple devices with a handy table.
bootstrap itself does the job just read that doc
I Think You Have Too Use .col-md class from bootstrap.
Give Class OF menu div as col-md-4 and in login and content div has col-md-8.
For Example,
<div class="row">
<div class="menu col-md-4"></div>
<div class="login col-md-8"></div>
</div>
Just Like This...
If You Are Don't familiar with Bootstrap. Then First Read Out The Documentation That Will Suggested By Burak Topal . So You are understand that what this class will actually do.
Might This Will Helpful.
I found the solution for this without using media queries. We need to place both top and left navbars inside ".navbar-collapse" class.
I have used a custom class "navbar-fixed-left" to make the left navbar.
.navbar-fixed-left {
margin-top: 47px;
left: 0px;
width: 140px;
position: fixed;
border-radius: 0;
height: 100%;
}
.navbar-fixed-left .navbar-nav > li {
float: none; /* Cancel default li float: left */
width: 139px;
}
.navbar-fixed-left + .container {
padding-left: 160px;
}
<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="#">WebSiteName</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<form class="navbar-form navbar-left">
<div class="form-group">
<input type="text" class="form-control" placeholder="User Name">
<input type="text" class="form-control" placeholder="Password">
</div>
<button type="submit" class="btn btn-default">Login</button>
</form>
<div class="navbar-inverse navbar-fixed-left">
<ul class="nav navbar-nav">
<li>Menu 1</li>
<li>Menu 2</li>
</ul>
</div>
</div>
</div>
</nav>
<div class="container">
<h3>Content goes here...</h3>
</div>
I'm trying to create a responsive website. Everything looks great except for the footer when in mobile view the content dont seem to align perfectly.
Here are screenshots.
This is the desktop view
This is the mobile view
As you can see everything is messed up. Here's my code
<div id="footer" class="navbar navbar-default navbar-fixed-bottom">
<div class="container-fluid">
<div class="navbar-text pull-left">
<p id="color"> Supported By </p>
</div>
<div class="navbar-text pull-left">
<img class="img-responsive" src="Images/King-Abdullah-Fund-Development-Jordan-360-Panorma-Video.png" id="imageclass1">
</div>
<div class="navbar-text pull-left">
<img class="img-responsive" src="Images/Jordan-Tourism-Board-Visit-Jordan-Lolo.png" id="imageclass1">
</div>
<div class="navbar-text" id="centered">
<img class="img-responsive" src="Images/Request-a-Recording-Jordan-360-Panorama.png" id="imagecenter">
</div>
<div class="navbar-text pull-right">
<img class="img-responsive" src="Images/Oasis-500-logo-360.png" id="imageclass">
</div>
<div class="navbar-text pull-right">
<img class="img-responsive" src="Images/Ayla-Logo.png" id="imageclass1">
</div>
<div class="navbar-text pull-right">
<img class="img-responsive" src="Images/Manaser.png" id="imageclass2">
</div>
<div class="navbar-text pull-right">
<p id="color">Partners</p>
</div>
</div>
</div>
And for the CSS
#centered {
position: absolute;
overflow: visible;
left: 40%;
}
#imagecenter{
max-width: 200px;
max-height: 200px;
}
#imageclass1{
max-width: 90px;
max-height: 90px;
}
#imageclass2{
max-width: 70px;
max-height: 60px;
}
And here's my attempt on mobile view
#media screen and (min-width: 400px) {
body {
overflow: auto;
}
.img-responsive {
position:relative;
max-width: 20%;
}
#color{
font-size: 5px;
}
#footer{
max-height: 200px;
}
}
If there's an easier approach than the way I did it, I would be very thankful.
Thank you!
Forget the pull-left pull-right on each element and use col's layout (col offset will be helpfull for the centered one).
Bootstrap provides easy ways for designing responsive sites. You just add classes to your divs and bootstrap's css will do the job! You can find it here:
http://getbootstrap.com/
I have the following HTML:
<nav class="navbar pr-navbar navbar-fixed-top" role="navigation">
<div class="navbar-header">
<div class="row">
<div class="navbar-left">
<a plat-tap='goBack()'><span class="fui-arrow-left pr-back"></span></a>
</div>
<div class="navbar-right">
<a plat-tap='goHome()'><span class="glyphicon glyphicon-home pr-home"></span></a>
</div>
<p class="pr-navbar-text">Manage/Add Users</p>
<div class="navbar-right">
<div class="pr-add-item">
<a plat-tap='addUser()'><span class="fui-plus"></span></a>
</div>
</div>
</div>
</div>
</nav>
Coupled with the following LESS:
#primaryColor: red;
#secondaryColor: blue;
#borderColor: white;
#textColor: white;
.pr-back{
color: #textColor;
}
.pr-home{
color: #textColor;
}
.pr-navbar-text{
color: #textColor;
text-align: center;
}
.pr-navbar {
background-color: #secondaryColor;
background-image: none;
background-repeat: no-repeat;
filter: none;
}
body { padding-top: 75px; }
#media screen and (max-width: 768px) {
body { padding-top: 53px; }
}
.pr-add-item {
padding-right: 75px
}
For some reason, the row element in my HTML does nothing. The plus icon is always put on a row beneath all the other buttons. How can I fix this so I have one row with a left aligned button, a center text, and two right aligned buttons?
Here, I started a fiddle for this.
JSFiddle here
<nav class="navbar pr-navbar navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="nav navbar-nav navbar-left">
<a plat-tap='goBack()'><span class="fui-arrow-left pr-back"></span></a>
</div>
<div class="nav navbar-nav navbar-right">
<a plat-tap='goHome()'><span class="glyphicon glyphicon-home pr-home"></span></a>
</div>
<p class="nav navbar-nav pr-navbar-text">Manage/Add Users</p>
<div class="nav navbar-nav navbar-right">
<div class="pr-add-item">
<a plat-tap='addUser()'><span class="glyphicon glyphicon-plus"></span></a>
</div>
</div>
</div>
</nav>
This HTML is closer to what you want. There were some unnecessary tags included in your original HTML, and also some important tags (like nav and navbar-nav) that were excluded. I suggest you read over this section of the bootstrap components page to understand how to get NavBars to work more cooperatively.
(I changed the glyph for your plus button and back arrow button so something would show up without including flat ui).
Edit: Altered the JSFiddle so that the text could be centered in the navbar.
I am using Bootstrap 3 to create a header and footer for my website. Both the header and footer are static so they can move accordingly if the user is on mobile to ensure the best visibility of the middle content. My question becomes how do I set the middle content to always take up 100% of the remaining space? The header and footer aren't always the same height because Bootstrap navbars are responsive. So the footer might be 50 pixels high on the desktop but in mobile it will be something like 62 pixels high because it stacked the footer content (text). Here's the code that I have:
<body>
<!-- Header -->
<div class="navbar navbar-default navbar-static-top">
<div class="navbar-inner">
<div class="container">
<div class="navbar-header">
<div class="navbar-brand">
Brand
</div>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-left tabs">
<li>
<a href="#"><div>
<label class="IconText">Home</label>
</div></a>
<a href="#"><div>
<label class="IconText">Settings</label>
</div></a>
<a href="#"><div>
<label class="IconText">About</label>
</div></a>
<a href="#"><div>
<label class="IconText">Contact</label>
</div></a>
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Header End -->
<!-- Middle Content -->
<div id="background" style="margin-top: -20px;">
<div class="mainContent">
</div>
</div>
<!-- Middle Content End -->
<!-- Footer -->
<div class="navbar navbar-default navbar-static-bottom">
<div class="container">
<p><label id="Label" class="navbar-text"></label></p>
</div>
</div>
<!-- Footer End -->
</body>
And here's my attempt at the CSS. I've been browsing this website and others for a while trying everything that I found but nothing seems to work.
.mainContent {
height: calc(100% - 120px); /* IE9+ and future browsers */
height: -moz-calc(100% - 120px); /* Firefox */
height: -webkit-calc(100% - 120px); /* Chrome, Safari */
}
#background {
background : #000000 url("./Images/black_background.jpg") no-repeat bottom left;
overflow:hidden;
height: 100%;
}
In desktop mode the Header takes up 70px and the Footer takes up 50px so that's where the 120px in the mainContent style section comes from but again the Header and Footer sizes are responsive.
An age old question, with a good answer/starting point here: http://css-tricks.com/snippets/css/sticky-footer/.
It's not bootstrap specific, so you may have to hammer some stuff into place, but the gist of it is there.