Prevent Logo On Top of Content in Bootstrap 3.2 - css

I'm not a designer by any means, so that's why I'm here. I placed a logo in a div above the main navigation div on my site. It looks fine, until I scale down to a mobile size, then the logo is somehow on top of all the content in the site when I start scrolling down. I've tried using different classes for the 1st div class="navbar-inner" div, but nothing I do will keep the logo where it should be.
Please note: I do not want the logo to remain on the screen, I'm fine with scrolling to the content and both navigations, including their content, to disappear.
.navbar-fixed-top2 {
padding-left: 0;
padding-right: 0;
max-height: 340px;
margin-top: 60px
}
.navbar {
border-bottom: unset !important;
margin-bottom: unset !important;
border-radius: 0 !important;
border: none !important;
box-shadow: none !important
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner" role="banner">
<div class="container">
<a href="" target="_blank" title="Redirect to main website" class="navbar-brand">
<img src="https://via.placeholder.com/80" alt="logo" />
</a>
</div>
</div>
</div>
<div class="navbar navbar-inverse navbar-fixed-top2" role="navigation">
<div class="navbar-inner">
<div class="container">
<ul class="nav navbar-nav">
<li>Link</li>
<li>Home</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<span>Hello!</span>
</li>
</ul>
</div>
</div>
</div>
Here is the jsfiddle which shows my issue and complete css: https://jsfiddle.net/jamiedewitz/f85qwvms/23/
Can someone help me figure out how to keep the logo in the header, so it can disappear with the navbars like it's supposed to?
UPDATE:
I changed the 2 navbar divs to use navbar-static-top and took out the padding-top from the body and it's working perfectly! Thank you all!
working divs

The position of the navbar is set to fixed because you used .navbar-FIXED-top class (which means it will stay there even when scrolling).
.navbar-fixed-top, .navbar-fixed-bottom {
position: fixed;
}
You need to use the NON-FIXED version of navbar or add css position: static; (or relative if you want to offset it later) to the elements...

Try using another navbar from bootstrap that doesn't include the fixed class, same goes for the navbar with your logo as well as the second navbar.
Maybe you're looking for something like shown in the snippet:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#" target="_blank" title="Redirect to main website">
<img src="https://via.placeholder.com/80" alt="logo" />
</a>
</nav>
<div class="navbar navbar-inverse" role="navigation">
<div class="navbar-inner">
<div class="container">
<ul class="nav navbar-nav">
<li>Link</li>
<li>Home</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<span>Hello!</span>
</li>
</ul>
</div>
</div>
</div>
<div class="container body-content" id="main-content">
<br />
<div class="content" role="main">
<form action="/Home/Save" method="post">
<p><h1>Opt Out Form</h1></p>
<p><h2>Select the term(s) you want to opt out of, then click Save.</h2></p>
<table class="table table-striped table-bordered">
<tr>
<th class="text-center" width="50%">Term</th>
<th class="text-center" width="50%">Status</th>
</tr>
<tr id="2021/08/23">
<td>2021 Fall Term</td>
<td>
<label id="User5StatusInLabel" for="User5StatusInRadioButton">
IN
<input type="radio" checked="checked" disabled="disabled" value="IN" />
</label>
<label id="User5StatusOutLabel" for="User5StatusOutRadioButton">
OUT
<input type="radio" disabled="disabled" value="OUT" />
</label>
</td>
</tr>
</table>
<input type="submit" disabled="disabled" value="Save" class="btn btn-primary" />
</form>
</div>
<hr />
<footer id="footer">
<p>© 2021 - Company Name</p>
</footer>
</div>
</body>
</html>

Related

How to include forms over bg image and beside navbar

First problem; I have very little working knowledge of Bootstrap/CSS and have copied code from various places and adapted it myself to make my solution work.
Second problem; I know I need containers/rows/columns, but I'm unsure of how to nest them appropriately around my navbar (permanently affixed to the left) and on top of the background image.
This is for a mobile web application and I would like to create forms that will sit on top of the background image.
I have spent nearly 2 whole days researching and inserting containers, rows, columns, around my existing code but all it achieves is moving the layout, moving navbar to the centre and text appears above or below the image but not on top of the image. The background image is set in css in the head, code is below.
body,
html {
height: 100%;
margin: 0;
}
.bg {
background: url("Red_polygon.jpg");
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.navbar-custom {
background-color: rgba(22, 22, 22, 1)
}
.thumbnail {
float: left;
margin: 2px 0px 2px 2px;
background: transparent;
border: 0 none;
box-shadow: none;
}
<nav class="navbar navbar-custom navbar-fixed-top">
<div class="thumbnail" border="0">
<img src="ASD_header_logo.png" alt="Active Software Development" width=277 height=76 />
</div>
</nav>
<body>
<nav class="navbar navbar-custom navbar-fixed-top">
<div class="thumbnail" border="0">
<img src="ASD_header_logo.png" alt="Active Software Development" width=277 height=76 />
</div>
</nav>
<div class="bg">
<div class="wrapper">
</div>
<nav id="sidebar">
<ul class="list-unstyled components">
<p>
<center>
<h4>Management Information System</h4>
</center>
</p>
<li>
Project nav
<ul class="collapse list-unstyled" id="pageSubmenu">
<li>
Projects
</li>
<li>
Activities
</li>
<li>
Tasks
</li>
<li>
Staff
</li>
</ul>
</li>
<li>
Help
</li>
<li>
Contact
</li>
</ul>
<ul class="list-unstyled components">
<li>
Home
</li>
<li>
Logout
</li>
</ul>
</nav>
</div>
I am expecting there is something I have done incorrectly to structure the navbar and background image and just wondering if someone can help me understand what I have done wrong, and how to correct it. Apologies for the massive amount of code but I'm unsure what's relevant and what isn't after the amount of things I've tried. Thank you in advance and kindest regards.
I have inserted a very basic structure to incorporate what you have mentioned above. However, not sure if what you are intending with the code you have mentioned above. So let's talk further if you need more help.
body,
html {
height: 100%;
margin: 0;
}
.bg {
background: url("https://www.publicdomainpictures.net/pictures/130000/velka/abstract-magical-background.jpg");
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.navbar-custom {
background-color: rgba(22, 22, 22, 1)
}
.thumbnail {
float: left;
margin: 2px 0px 2px 2px;
background: transparent;
border: 0 none;
box-shadow: none;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<body class="">
<nav class="navbar navbar-custom navbar-fixed-top">
<div class="thumbnail" border="0">
<img src="ASD_header_logo.png" alt="Active Software Development" width=277 height=76 />
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-2">
<nav id="sidebar">
<ul class="list-unstyled components">
<p>
<center>
<h4>Management Information System</h4>
</center>
</p>
<li>
Project nav
<ul class="collapse list-unstyled" id="pageSubmenu">
<li>
Projects
</li>
<li>
Activities
</li>
<li>
Tasks
</li>
<li>
Staff
</li>
</ul>
</li>
<li>
Help
</li>
<li>
Contact
</li>
</ul>
<ul class="list-unstyled components">
<li>
Home
</li>
<li>
Logout
</li>
</ul>
</nav>
</div>
<div class="col-10">
<div class="bg">
<form class="text-white">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me out</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</div>
</body>

"jumping" content in navbar in bootstrap

Edit2:
Okay, the problem was, that I used a <div class="row"> around the <div class="topimage"> tag. Strange. Could someone explain why it is?
I'm pretty new to bootstrap and created a web page for learning purposes.
Everything is working pretty well so far, except the navbar.
This is my nav code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/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 id="headertest ">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="row">
<div class="col-sm-4 col-sm-offset-1">
<form class="navbar-form navbar-left">
<button class="btn btn-default">ENTDECKEN</button>
<button class="btn btn-default">FINDEN</button>
<button class="btn btn-default">PLANEN</button>
<p class="font">
<b> Zurück zur Hafenseite |</b> <a style="text-decoration: none">Salsbury & Mysteriöses Stonehenge</a>
</p>
</form>
</div>
<div class="col-sm-2 ">
<div class="navbar-form">
<img src="../assets/aida.png" class="logo ">
</div>
</div>
<div class="col-sm-4">
<div class="navbar-form navbar-right">
<form action="#" style>
<div class="dropdown">
<img src="../assets/lupe.png" class="icons" />
<img src="../assets/telefon.png" class="icons" />
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li>Erste Aktion</li>
<li>Zweite Aktion</li>
<li>Noch eine Aktion</li>
<li role="separator" class="divider"></li>
<li>Ein Link</li>
</ul>
</div>
</form>
</div>
</div>
</div>
</div>
</nav>
</div>
The problem is, if I use the navbar-fixed-top class, the content inside the navbar is jumping while I scroll.
Like the top margin is vanishing while I'm scrolling down and if I Scroll up, the margin (or whatever the problem is) just magically appears back.
Normal and scrolling up:
Scrolling down:
I hope you can see what I mean.
Does anybody know what I'm doing wrong?
(my css classes shouldn't be the problem. If I delete them, the content still keep "jumping")
Thank you
Edit:
I have an image as the first item (after the navbar) that seems to cause the problems.
If I delete it, the navbar is working as expected.
Css:
.topimage{
height: 600px;
width: 100%;
align-self: center;
background-image: url("./assets/testbild3.jpg");
background-repeat: no-repeat;
background-size: cover;
z-index: -1;
}
and how I implemented it:
<div class="row">
<headertest></headertest><!-- navbar component -->
</div>
<div class="row ">
<div class="topimage">
</div>
</div>
The fiddler link: (where it works without "jumping" navbar content)
https://jsfiddle.net/Biberium/g52cd6v8/

How do I get the form to be on the same line as by navigation buttons?

I've tried playing with putting the indents and placement in different places but it still appear underneath the navigation button. I want it on the same line across the top.
I might of made it a bit messy trying to get it on the same line, if so just take out whenever isn't necessary.
`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap For Beginners</title>
<meta name="description" content="Hello World">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<style>
.nav {
}
.nav container-fluid {
}
.nav li {
display: inline;
padding: 20px;
font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
}
.jumbotron {
}
.jumbotron container-fluid {
}
.jumbotron h1 {
.footer {
}
.footer container-fluid {
}
.footer p {
}
</style>
</head>
<body>
<div class="nav">
<div class="container-fluid">
<ul class="nav nav-pills">
<li class="pull-right">Contact</li>
<li class="pull-right">About</li>
</ul>
<form class="form-horizontal">
<div class="form-group">
<div class="col-md-6">
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="Have Feedback?">
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-default">Submit Feedback</button>
</div>
</div>
</form>
</div>
</div>
<div class="jumbotron">
<div class="container-fluid">
<div class="row">
<h1>Student</h1>
<h1>Business</h1>
</div>
</div>
</div>
<div class="footer">
<div class="container-fluid">
<p>By:</p>
<p>For:</p>
</div>
</div>
<!-- Latest compiled and minified JavaScript -->
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
</body>
</html>
The input bar doesn't seem to be responsive on really really small windows, is that normal?
I also want the footer to be the same size as the nav header and the jumbotron to fill up the rest of the space in between, everything fits in the window with no scrolling.
Thanks in advance.
Your code looks great, all you have to do is wrap the form and nav in a wrapper / container then separate the sections with col-md-6. I built an example for you here http://www.bootply.com/P7VmPZOfXp.
/* CSS used here will be applied after bootstrap.css */
.footer {
height: 58px;
background: #ccc;
}
<div class="wrapper">
<div class="container">
<div class="row">
<div class="container-fluid">
<div class="col-md-6 col-lg-6">
<form class="form-horizontal">
<div class="form-group">
<div class="col-md-6">
<input class="form-control" id="exampleInputEmail2" placeholder="Have Feedback?" type="email">
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-default">Submit Feedback</button>
</div>
</div>
</form><!-- .form-horizontal -->
</div><!-- .col-6 -->
<div class="col-md-6 col-lg-6">
<div class="nav">
<ul class="nav nav-pills">
<li class="pull-right">Contact</li>
<li class="pull-right">About</li>
</ul>
</div><!-- .nav -->
</div><!-- .col-6 -->
</div><!-- .fluid container -->
</div><!-- .row -->
</div><!-- .container-->
</div><!-- .wrapper-->
<div class="jumbotron">
<div class="container-fluid">
<div class="row">
<h1>Student</h1>
<h1>Business</h1>
</div>
</div>
</div><!-- .jumbotron -->
<div class="footer">
<div class="container-fluid">
<p>By:</p>
<p>For:</p>
</div>
</div><!-- .footer -->
To address part of your issue, try putting the sections you would like to be side-by-side in the same div.row, then wrap a div.col-xx-x around each. For example:
<div class="nav">
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="nav nav-pills">
<li class="pull-right">Contact</li>
<li class="pull-right">About</li>
</ul>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<form class="form-horizontal">
<div class="form-group">
<div class="col-md-6">
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="Have Feedback?">
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-default">Submit Feedback</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
I'm really not sure why you're not using the <navbar> class. It's there and ready to accomplish exactly what you're looking for. See this Bootply for example:
Bootply - Navbar
<nav class="navbar navbar-default">
<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="#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="#">Brand</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">
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input class="form-control" placeholder="Have Feedback?" type="text">
</div>
<button type="submit" class="btn btn-default">Submit Feedback</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li>About</li>
<li>Contact</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
There is a way to do it like you have it, but I'm not sure how to get the <form> to align perfectly with the <nav> class, since there's padding on it and moves it down from the top a bit. You may need some custom CSS to handle that.
Bootply - Original
<div class="container-fluid">
<div class="row">
<div class="col-xs-4">
<form class="form-horizontal">
<input class="form-control" id="exampleInputEmail2" placeholder="Have Feedback?" type="email">
</form>
</div>
<div class="col-xs-2">
<button type="submit" class="btn btn-default">Submit Feedback</button>
</div>
<div class="col-xs-6">
<ul class="nav nav-pills">
<li class="pull-right">Contact</li>
<li class="pull-right">About</li>
</ul>
</div>
</div>
</div>
Give them both a look and see if either works for you.
Hope that helps!

Aligning button and text in navbar in twitter bootstrap

I have written the following html with Bootstrap 2.3.2 included and no other css:
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
(...)
<div class="nav-collapse collapse">
<ul class="nav">
(...)
</ul>
<form id="login-form" class="navbar-form pull-right">
<span class="navbar-text">Hello, username!</span>
<button id="logout" class="btn">Log out</button>
</form>
</div>
</div>
</div>
</div>
How can I make it so that the log out button aligns with the text and .navbar correctly? Currently the button sticks to the bottom of the line, which is the bottom of the .navbar because of the .navbar-text.
The problem can be viewed here.
You can reset the button's margin via CSS:
.navbar .btn {
margin-top: 0;
}

Twitter Bootstrap - full width navbar

Following the example of TB, I have a navbar that is marked up as follows:
<div class="container">
<div class="navbar">
<div class="navbar-inner">
<!-- nav bar items here -->
</div>
</div>
</div>
I'd like this to span the full width of the screen and not have any rounded corners -- similar to static top styling of the navbar.
I can't seem to find how to do this in TB. If there isn't a way, what CSS would I need to override TB and not break responsiveness?
Just change the class container to container-fullwidth like this :
<div class="container-fullwidth">
Not sure if the navbar-static-top class was available prior to version 2.2.2 but I think you can accomplish your goal with the following:
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<ul class="nav">
<li class="active">Test1</li>
<li>Test2</li>
<li>Test3</li>
<li>Test4</li>
<li>Test5</li>
</ul>
</div>
</div>
<div class="container">
...
</div>
I put together a jsFiddle as an example.
Put the navbar out of your container:
<div class="navbar">
<div class="navbar-inner">
<!-- nav bar items here -->
</div>
</div>
<div class="container">
</div>
EDIT:
Here is one that I did with responsive navbar. The code fits the document body:
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<!-- Be sure to leave the brand out there if you want it shown -->
<a class="brand" href="#">Project name</a>
<!-- Everything you want hidden at 940px or less, place within here -->
<div class="nav-collapse">
<!-- .nav, .navbar-search, .navbar-form, etc -->
<ul class="nav">
<li class="active">Home</li>
<li class="divider-vertical"></li>
<li>Link</li>
<li class="divider-vertical"></li>
<li>Link</li>
</ul>
<ul class="nav pull-right">
<li>Log out</li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="span12">
</div>
</div>
</div> <!-- end container -->
<script type="text/javascript" src="/assets/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/assets/js/bootstrap.min.js"></script>
I'm very late to the party but this answer pulls up top in Google search results.
Bootstrap 3 has an answer for this built in, set your container div in your navbar to container-fluid and it'll fall to screen width.
Like so:
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>More Stuff</li>
</ul>
</div>
</div>
</div>
Put your <nav>element out from the <div class='container-fluid'>.
Ex :-
<nav>
......nav content goes here
<nav>
<div class="container-fluid">
<div>
........ other content goes here
</div>
</div>
You need to push the container down the navbar.
Please find my working fiddle here http://jsfiddle.net/meetravi/aXCMW/1/
<header>
<h2 class="title">Test</h2>
</header>
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">
<li class="active">Test1</li>
<li>Test2</li>
<li>Test3</li>
<li>Test4</li>
<li>Test5</li>
</ul>
</div>
</div>
<div class="container">
</div>
Just replace <div class="container"> with <div class="container-fluid">, which is the container with no margins on both sides.
I think this is the best solution because it avoids some useless overriding and makes use of built-in classes, it's clean.
You can override some css
body {
padding-left: 0px !important;
padding-right: 0px !important;
}
.navbar-inner {
border-radius: 0px !important;
}
The !important is needed just in case you link the bootstrap.css after your custom css.
And add your nav html out of a .container
To remove the border-radius on the corners add this style to your custom.css file
.navbar-inner{
-webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0;
}
I know I'm a bit late to the party, but I got around the issue by tweaking the CSS to have the width span 100%, and setting l/r margins to 0px;
#div_id
{
margin-left: 0px;
margin-right: 0px;
width: 100%;
}
You have to add col-md-12 to your inner-navbar. md is for desktop .you can choose other options from bootstrap's list of options . 12 in col-md-12 is for full width .If you want half-width you can use 6 instead of 12 .for e.g. col-md-6.
Here is the solution to your question
<div class="container">
<div class="navbar">
<div class="navbar-inner col-md-12">
<!-- nav bar items here -->
</div>
</div>
</div>

Resources