Bootstrap Navbar CSS Issue - html

I have been working in bootstrap for awhile now, and really love the features of it all. But I am having trouble with the navigation header on mobile view. I have an image that displays during the desktop version of the website, and I am trying to change to a smaller icon logo in mobile display.
I have the site bringing up the icon bar and collapsing everything for the login screen on mobile properly. I think it might be as simple as the fact that I don't fully understand the CSS of bootstrap but could anyone tell me how to change the image when the screen collapses into mobile mode.
This is what the website looks like in desktop view:
This is what it looks like when I go mobile now:
This is what the desired look is (made in photoshop):
When the bar goes mobile, I'd like to swap the two images.
Here is my bootstrap code -
<div class="navbar navbar-inverse navbar-fixed-top dropShadow" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-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="#"><img src="images/logoWhite.png" width="400px"></a>
</div>
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="form">
<div class="form-group">
<input type="text" placeholder="Email" class="form-control">
</div>
<div class="form-group">
<input type="password" placeholder="Password" class="form-control">
</div>
<button type="submit" class="btn btn-primary">Sign In</button><span style="color:white;"> or</span>
<button type="submit" class="btn btn-success">Sign Up</button>
</form>
</div><!--/.navbar-collapse -->
</div>
</div>

you can use a media query for this.
but first use that logo image in background.
assuming that you use .logo for the logo classmate university
HTML:
<a class="navbar-brand" href="#"><span class="logo"></span></a>
CSS:
#media(max-width:767px){
.logo{
background:url(images/hat.png) no-repeat;
width : 400px;
display:block;
}
}
/* this logo will be used for everything outside of the above breakpoint */
.logo{background:url(images/logoWhite.png)

You can put both images there inline, and using classes .visible-xs on small logo, for mobile mode, and .hidden-xs class on other (university name) image tag.
.visible-xs - displays ur image on mobile mode and hides on rest of the modes, while .hidden-xs hides the image on mobile mode and displays on rest of modes.

Related

Bootstrap navbar appearing on 2 lines in Safari on first load

This is the code I have for my navbar:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<button type="button" class="navbar-nav btn btn-default navbar-btn navbar-left previous_page" style="display:inline-block">
<span class="glyphicon glyphicon-menu-left"></span>
back
</button>
<div class="text-center" id="progress-bar" style="display:inline-block">
<div data-page="0" class="counter active"></div>
<div data-page="1" class="counter "></div>
<div data-page="2" class="counter "></div>
<div data-page="3" class="counter "></div>
<div data-page="4" class="counter "></div>
</div>
<button type="button" class="navbar-nav btn btn-default navbar-btn navbar-right next_page disabled" style="margin-right:0px;display:inline-block">
next
<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
</nav>
On Safari on iPhone 7, 8, X devices, when you FIRST load the page, the navbar appears on 2 different lines like so:
Then, when you refresh or reload it, it appears normal like so:
I'm having a really hard time figuring out how to get it to always appear normal, and am even more boggled by why a secondary page load corrects the issue.
Note, I added display:inline-block to all 3 navbar elements to try to correct this problem. It's done something... BEFORE I added it, when it was just Bootstrap native styling, on the Safari and iPhone 7, 8, X devices, even refreshing wouldn't help, and the navbar would stay split on 2 rows.
I am using Bootstrap 3.3.4
I go through this i found this solution rather than giving it inline you can use bootstrap class checkbox-inline which will make the center div inline and give navbar text-center class. Use pull-left and pull-right instead navbar-left and navbar-right. Hope it will help you :)
<nav class="navbar navbar-default navbar-fixed-top text-center" style="background: red;">
<div class="container-fluid">
<button type="button" class="navbar-nav btn btn-default navbar-btn pull-left previous_page">
<span class="glyphicon glyphicon-menu-left"></span>
back
</button>
<div class="text-center checkbox-inline" id="progress-bar">
<div data-page="0" class="counter active"></div>
<div data-page="1" class="counter "></div>
<div data-page="2" class="counter "></div>
<div data-page="3" class="counter "></div>
<div data-page="4" class="counter "></div>
</div>
<button type="button" class="navbar-nav btn btn-default navbar-btn pull-right next_page disabled">
next
<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
</nav>
I had the same problem. I solved it by fixing the height of the navbar. Try giving the navbar a fixed height: i.e
.container_navbar{ height: 60px; ... }
The fixed height works across all devices.
Hope this works for you
Best regards

Footer overlaps login form in mobile landscape mode

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;
}
}

How to include existing div from header to be part of Menu in mobile using bootstrap?

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>

Bootstrap certain buttons are not working

When hovering my social buttons the hyperlink appears and the link can be launched by right clicking and choosing an option, but not on a single click. They were built differently in html to help my troubleshooting but I can't get either of them to send me to the respective social pages. They are located in the 4 wide column in the social row. I went a little crazy nesting columns to keep everything centered. Any help is appreciated.
test site can be found here: http://www.tedrmoke.com/cjs
<div class="jumbotron">
<div class="container">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" 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="index.html"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Home <span class="sr-only">(current)</span></li>
<li>Sawmill</li>
<li>Purchase</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<!-- Jumbotron -->
<div class="row text-center jumbo">
<h1>Hello! We are <br/><span>CJ Sawmill & Lumber</span></h1>
<h3>We specialize in coming to you and cutting your lumber in the central NJ area. We also have a selection of quality cured cuts available for purchase.</h3>
<div class="row">
<div class="col-xs-2"></div>
<div class="col-xs-8 social">
<div class="col-sm-8">
<div class="collapse-group"> Contact Us.
<form class="collapse" name="contactform" method="post" action="http://www.cjsawmill-lumber.com/send_form_email.php">
<table class"col-lg-12 text-left" >
...
</table>
</form>
</div>
</div> <!-- row -->
<div class="col-sm-4">
<div class="btn btn-default twi_btn"></div>
<a class="btn btn-default fb_btn" href="http://www.facebook.com/cjsawmill"></a>
</div>
</div> <!-- col-6 button row -->
<div class="col-xs-2"></div>
</div> <!-- button row -->
</div>
</div> <!-- container -->
</div> <!-- end jumbotron -->
That's because in your javascript :
// JavaScript Document
$('.row .btn').on('click', function(e) {
e.preventDefault();
var $this = $(this);
var $collapse = $this.closest('.collapse-group').find('.collapse');
$collapse.collapse('toggle');
});
, you are preventing the default event whenever an element with class btn is clicked inside an element of class row.
Notice in your HTML, that both your hyperlinks and divs for facebook and twitter respectively are of the class btn due to which, whenever they are clicked, the default event (that is redirecting to their href) is prevented which is why the links dont work on a single click, but they do work on right click, since the right click only uses the href attribute to redirect you to the new link.
Try removing the e.preventDefault(); from being applied to your hyperlinks or divs inside hyperlinks and then the social buttons should work just fine on a single left click as well.
Your Javascript says
$('.row .btn').on('click', function(e) {
e.preventDefault();
# . . .
});
So I would target that to just the specific 'Contact Us' button, not all butons.
Bootstrap can be restrictive in a way that won't let you wrap your button in an a tag. Like you could in regular html. Here is a solution that I used to a similar issue I had, structure you a tag like this and you should still get a button that functions.Place in your class names of course.
<a class="btn btn-default glyphicon glyphicon-hand-up"></a>

How to force text wrapping with floated elements

Here is an image of my problem.
See how the hamburger/menu icon is pushed down to the next line? I want the text to go to the next line instead, keeping the menu button and header text next to eachother. The title text and menu are floated left and right respectively.
This doesn't seem to be a clear problem (since I'm trying to do the opposite), and I can't think how the white space property could be used in this case.
The only thing that works is setting a max width on the title, but that messes up the layout at some screen sizes.
I have no custom css on these elements, just what comes with Bootstrap 3
Markup (basically lifted straight from the new Bootstrap 3 docs):
<div class="navbar navbar-default">
<div class = "navbar-header">
<a class = "navbar-brand" href="<%= request.protocol + request.host_with_port%>/weather"> Weather </a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<form id="search" class="navbar-form navbar-right form-inline" method="get" action="/weather">
<div class="form-group">
<input type="text" placeholder="Search for your city or zip" class="form-control" id = "searchbox" name="search">
</div>
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"/></button>
</form>
</div>
`
Stephen,
Two changes are required to get your desired result.
First, set .navbar-brand padding right to 70px or what you needed.
.navbar-brand {
padding-right:70px;
}
And second, make .navbar-toggle position:absolute, right:0;
.navbar-toggle {
position:absolute;
right:0;
top:0;
}
And you are done! :).
Here is demo: http://jsfiddle.net/sARaY/