Brand logo on navbar - what am I doing wrong? - html

Is there a way to dynamically resize the nav-bar brand logo image to go over the nav-bar itself without it losing it's size?
I want it to be fixed on the top of the nav-bar and be over it. I don't want the nav-bar to adjust to the image.
.navbar {
margin-bottom: 0;
border-radius: 0;
border: 0;
background-color: #97CACA;
color: #fff;
padding: 1% 0;
font-size: 1.2em;
}
.navbar-brand>img {
max-height: 100%;
height: 100%;
width: auto;
margin: 0px;
}
.navbar-brand {
float: left;
min-height: 100px;
padding: 0 0px;
}
.navbar-inverse .navbar-nav .active a,
.navbar-inverse .navbar-nav .active a:focus,
.navbar-inverse .navbar-nav .active a:hover {
color: #fff;
background-color: #97CACA;
}
.navbar-inverse .navbar-nav li a {
color: #E2F2E8;
}
<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="https://preview.ibb.co/cuc7sb/logo_sitters.png"></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>A Nossa Missão</li>
<li>Os Nossos Serviços</li>
<li>Contactos</li>
</ul>
</div>
</div>
</nav>

You can give a position: absolute to your .navbar-brand and remove float: left
Added top: 0 and left: 0 to put it in place. You can change them accordingly.
.navbar-brand {
min-height: 100px;
padding: 0 0px;
position: absolute;
top: 0;
left: 0;
}
Additionally, you need to style your ul after that, because it will be behind your logo
(this is a rough solution)
.navbar-inverse .navbar-collapse ul {
float: right;
}
Example: https://jsfiddle.net/d67y3Ltn/1/

Related

How do I keep the logo from resizing when on mobile?

I believe what is happening is the image is getting shrinked until it disappears, and I want to keep it the same size even on mobile, and also leveled to the rest of the nav li/hamburger
<!DOCTYPE html>
<head>
</head>
<body>
<style>
/* --- header -- */
.navbar-header div.logo {
margin-top: -1%;
padding-bottom: 0;
}
.navbar-header div.logo a.navbar-brand {
padding: 0;
}
.navbar-header div.logo a.navbar-brand img {
width: 6%;
padding: 15px;
}
navbar-nav .navbar-brand {
display: flex;
align-items: center;
}
.navbar-nav .navbar-brand>img {
padding: 7px 14px;
}
/****override navbar height********/
.navbar-nav > li > a {
padding-top: 4px !important;
padding-bottom: 2px !important;
}
.navbar {
min-height: 5px !important
}
/*********************************/
header .navbar {
margin-bottom: 0;
}
.navbar-default {
border: none;
}
header .navbar-collapse ul.navbar-nav {
float: right;
margin-right: 0;
}
header .navbar-default {
background-color: transparent;
}
header .navbar {
min-height: 32px;
}
header .navbar-nav > li {
padding-bottom: 5px;
padding-top: 5px;
}
header .navbar-nav > li > a {
padding-bottom: 5px;
padding-top: 5px;
margin-left: 2px;
line-height: 30px;
font-weight: 700;
}
</style>
<header>
<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>
<div class="logo">
<a class="navbar-brand" href="index.php"><img src="./img/logo.png"></a>
</div>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>about us</li>
<li>Contacts</li>
</ul>
</div>
</div>
</div>
</header>
<div>content</div>
</body>
Does anyone know how to keep the logo from disappearing, moving or resizing, while keeping the rest of the website elements responsive?
It's because you have set your image to a size in %, you will have to change it to a set size. This:
.navbar-header div.logo a.navbar-brand img {
width: 6%;
padding: 15px;
}
should be something like this:
.navbar-header div.logo a.navbar-brand img {
width: 200px;
padding: 15px;
}

CSS : button overlapped by a div,z-index not working

I have a top bar with a button and a navbar, for z-index reason I can only get the button working but the menu hided under the top bar or I get both but the button not clickable:
PS: I get this problem only on small display with the burger menu,
For the small device, Bootstrap uses this:
.navbar-fixed-top, .navbar-fixed-bottom {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
}
If I override Z-index:1030; the bergur menu is hided under my headercss bar.
Here is my almost whole CSS, maybe some parts are not important for my problem:
HTML:
<div class="headercss navbar-fixed-top">
<div class="element"> <a class="btn btn-warning" href="www.test.com">Internet ></a></div>
</div>
<div class="sidebar-nav">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse sidebar-navbar-collapse" data-toggle="collapse" data-target=".navbar-collapse">
<ul class="nav navbar-nav">
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
CSS:
.headercss {
width: 100%;
height: 62px;
display:block;
overflow:auto;
background-color: #CAD722;
top: -1px;
left: 0px;
position: fixed;
z-index: 100;
}
}
.btn {
font-size: 18px;
font-weight: bold;
}
/* make sidebar nav vertical */
.navbar-default .navbar-nav>li>a {
font-weight: bold;
}
#media (min-width: 768px) {
.navbar-default{
width: 200px;;
height: 100%;
background-color: #e6dfd7;
z-index: 0;
}
.sidebar-nav .navbar .navbar-collapse {
margin-top: 65px;
padding: 0;
max-height: none;
}
.sidebar-nav .navbar ul {
float: none;
display: block;
}
.sidebar-nav .navbar li {
float: none;
display: block;
}
.sidebar-nav .navbar li a {
padding-top: 12px;
padding-bottom: 12px;
font-size: 16px;
}
.sidebar-nav .navbar li a:hover {
background-color: #CAD722;
}
}
/*fixing bootstrap*/
.col-sm-10 {
width: 100%;
float: right;
}
#media (min-width: 768px){
.col-sm-10 {
width: 85%;
}
}
.navbar-default .navbar-collapse,.navbar-default .navbar-form {
border-color:#CAD722;
}
.content{
position: relative;
}
.navbar-toggle {
margin-top: 11px;
margin-bottom: 1px;
margin-left: 5px;
float: left;
}
/*For small display*/
#media (max-width: 768px) {
.navbar-default {
background-color: transparent;
border-color: transparent;
}
.sidebar-nav .navbar li{
background-color: #CAD722;
}
}
The issue is that you essentially have two full-width navbars sitting on top of each other, with one button in each. Clearly, you'll only be able to click on the top one. One solution is to add width: 50%; to .navbar-default and width: 200%; to .navbar-collapse in the small display; This causes the navbar with the menu button to only cover half of the screen, allowing you to click on the Internet button, while the collapsible menu remains full-width.

Set background-color with opacity of collapse navbar

How to set the collapse background-color of the NavBar.
Currently it looks like this.
If I add:
.collapse {
background: rgba(70,130,180 ,0.4);}
it looks like this. Because I have a transparent background-color.
I don't know how to fix it.
I want to have the same color in both ways.
.navbar-nav > li > a {
height: 30px;
padding-top:8px !important;
}
li a {
margin-right: 15px;
color: gray;
text-transform: uppercase;
font-family: "Arial Black", Gadget, sans-serif;
font-size: 16px;
}
.navbar-toggle {
margin-top: 3px;
background-color: #5F9EA0;
height: 28px;
}
.icon-bar {
margin-top: -2px;
background-color: white;
}
ul.nav a:hover {
color: #5F9EA0;
background-color: transparent;
}
.navbar {
background: rgba(70,130,180 ,0.4);
height: 35px;
min-height: 35px;
position: fixed;
width: 100%;
z-index: 1;
}
.navbar-header img {
height: 32px;
padding-top: 3px;
padding-left: 20px;
}
<body>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<nav role="navigation" 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" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="pull-left" href="#">
<img src="imgs/Logo.png"/>
</a>
</div>
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>Profile</li>
<li>Messages</li>
</ul>
</div>
</div>
</nav>
</body>
I'm sure there will be a better way to structure you html, but here is the solution for your case:
Simply add this media queries to the bottom of your css file, and make sure it's rewriting the boostrap one you are using.
#media (max-width:768px) {
.collapse {
margin-top:6px;
background: rgba(70, 130, 180, 0.4);
}
}
And here is the working demo

Fixing ul to right of bootstrap navbar

Disclaimer: Pardon my stupidity when it comes to coding. I started learning last week.
I have been tinkering around with a Bootstrap 3 template from a Youtube tutorial I found to assist me in learning HTML, CSS, and eventually Java. In this example I'm working on, I am trying to get the inline unordered list to float to the right of the page. I tried adding float:right to most of the navbar elements in the CSS, but it's not doing anything for me. Any help would be greatly appreciated.
HTML:
<div class="navbar navbar-fixed-top">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button class="navbar-toggle" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><img src="images/logo.png" alt="Your Logo"></a>
<div class="nav-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li class="active">
Home
</li>
<li class="inactive">
Photos
</li>
<li class="inactive">
Videos
</li>
<li class="inactive">
Contact Us
</li>
</ul>
</div><!-- end nav-collapse -->
</div><!-- end container -->
</div><!-- end navbar -->
CSS:
.navbar {
position: relative;
min-height: 50px;
padding-right: 15px;
padding-left: 15px;
margin-bottom: 20px;
background-color: #eeeeee;
border-radius: 4px;
}
.navbar:before,
.navbar:after {
display: table;
content: " ";
}
.navbar:after {
clear: both;
}
.navbar:before,
.navbar:after {
display: table;
content: " ";
}
.navbar:after {
clear: both;
}
.navbar-nav {
margin-top: 10px;
margin-bottom: 15px;
}
.navbar-nav > li > a {
padding-top: 15px;
padding-bottom: 15px;
line-height: 20px;
color: #777777;
border-radius: 4px;
}
.navbar-nav > li > a:hover,
.navbar-nav > li > a:focus {
color: #333333;
background-color: transparent;
}
.navbar-nav > .active > a,
.navbar-nav > .active > a:hover,
.navbar-nav > .active > a:focus {
color: #555555;
background-color: #d5d5d5;
}
.navbar-nav > .disabled > a,
.navbar-nav > .disabled > a:hover,
.navbar-nav > .disabled > a:focus {
color: #cccccc;
background-color: transparent;
}
.navbar-nav.pull-right {
width: 100%;
}
.navbar-static-top {
border-radius: 0;
}
.navbar-fixed-top,
.navbar-fixed-bottom {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
border-radius: 0;
}
.navbar-fixed-top {
top: 0;
}
.navbar-fixed-bottom {
bottom: 0;
margin-bottom: 0;
}
.navbar-brand {
display: block;
max-width: 200px;
padding: 15px 15px;
margin-right: auto;
margin-left: auto;
font-size: 18px;
font-weight: 500;
line-height: 20px;
color: #777777;
text-align: center;
}
.navbar-brand:hover,
.navbar-brand:focus {
color: #5e5e5e;
text-decoration: none;
background-color: transparent;
}
.navbar-toggle {
position: absolute;
top: 9px;
right: 10px;
width: 48px;
height: 32px;
padding: 8px 12px;
background-color: transparent;
border: 1px solid #dddddd;
border-radius: 4px;
}
.navbar-toggle:hover,
.navbar-toggle:focus {
background-color: #dddddd;
}
.navbar-toggle .icon-bar {
display: block;
width: 22px;
height: 2px;
background-color: #cccccc;
border-radius: 1px;
}
.navbar-toggle .icon-bar + .icon-bar {
margin-top: 4px;
}
As you are using Bootstrap, to so you may use class .pull-right to align it to right.
For more info click here.
In Bootstrap v 3.** it is better practice to use "navbar-right" so the proper context should read:
ul class = "nav navbar-nav navbar-right"
If you are using bootstrap 3 the use navbar-right to pull right h
jsfiddle.net/makk/9yxeg7r5/2 - this is a similar example
<div id="top"></div>
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="row">
<div class="navbar-header">
<a class="navbar-brand" href="#top"><span class="fa fa-book fa-3x">MATH</span></a>
</div>
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li>Features</li>
<li>Courses</li>
<li>Pricing</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>

Bottom to top navigation in Bootstrap 3 - Affix?

This is my first question so please excuse me if it is ridiculous/rather vague.
I have been trying for days to get a navigation that starts at the bottom and then when scrolled it sticks to the to, something that is similar to this website.
All I've managed to do so far is this:
<div id="nav" data-spy="affix" data-offset-top="443" data-offset-bottom="200">
<nav class="navbar navbar-affix-top navbar" role="navigation">
<div class="navbar-header">
<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>
<a class="brand1" href="#why"><img src="http://dummyimage.com/228x63"></a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse navbar-right">
<ul class="nav navbar-nav">
<li>Why why why ?</li>
<li>How How How</li>
<li>Action call</li>
<li>Who who who</li>
</ul>
</div>
</nav>
</div>
And the CSS is:
.navbar-nav {
font-size: 1.4em;
font-family: "adelle";
color: #fff;
}
#nav.affix {
position: fixed;
top: 0;
width: 100%;
z-index:11; }
.navbar-nav > li > a {
color: #fff;
text-align:center;
}
.navbar-nav > li > a:hover{
color: #59aa80;
background-color: transparent;
transition: 1s;
-webkit-transition: 1s;
-moz-transition: 1s;
-o-transition:1s;
}
.navbar-nav li.active:after {
content: " .";
display: block;
text-indent: -99em;
color: #fff;
height: 0px;
margin-left: -.8em;
margin-right: auto;
margin-top: 3px;
position: absolute;
left: 50%;
width: 1px;
text-align:center;}
.navbar .nav .active > a {
background-color: none;
background: 0 !important;
color: #FFF !important;
box-shadow: none !important;
-webkit-box-shadow: none !important;
text-align:center;}
.navbar {
background-color: rgba(0,0,0,.7);
box-shadow: 1px 5px 10px rgba(0,0,0,.3);
text-align:center;}
.navbar-header {
padding-left: 40px; }
I have searched stackoverflow.com as well as JSFiddle, Bootply, Bootsnip etc without any luck so it would be much appreciated if I could get some help.
You can use the Bootstrap affix component to position it to the top once scrolling reaches a specific point.
Here's a working example..
http://www.bootply.com/121595