Hi guys so i have a problem were i have my logo on the left hand side of my navbar and my navgation on the right hand side. Now as i am shrinking the screen i am trying to get the image to appear smaller so that the nav text and the image dont overlap each other.So basically a responsive design. However for some reason it does not seem to work at all,
I have used the class="img-fluid which boostrap says to use but it dosen't seem to work at all on the logo, so any help on this matter would be great
Fiidle Link : Here
I have used float right on the nav bar and maybe thats what messes it up? but again i am not so sure how to get the image to be resposive and get smaller as the page shrinks
P.S As you can see in the fiddle , the image actually only starts to shrink when the window gets really small, almost less then the mobile version
HTML:
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button aria-controls="navbar" aria-expanded="false" class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse" type="button"><span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span></button>
<div class="logo"><img class="img-responsive" src="https://www.martialartsschoolsdirectory.com/logos/profile/checkmat-logo-burbank-ca-184.png"></div>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>NAVBARA</li>
<li>NAVBARA</li>
<li>NAVBARA</li>
<li>d</li>
<li class="dropdown">
NAVBARA
<ul class="dropdown-menu">
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
</ul>
</li>
<li>9</li>
<li>11</li>
<li>12</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
CSS:
.navbar-nav>li>a {
line-height: 6px;
}
.navbar-nav {
float: right;
margin-top: -15px;
}
.navbar {
padding-top: 53px;
font-size: 13px;
text-transform: uppercase;
}
.navbar-default {
background-color: transparent;
border-top: 0px solid rgba(0, 0, 0, 0.5);
border-bottom: 0px solid rgba(0, 0, 0, 0.5);
border-left: 0px solid rgba(0, 0, 0, 0.5);
border-right: 0px solid rgba(0, 0, 0, 0.5);
-webkit-transition: background-color 200ms linear;
-moz-transition: background-color 200ms linear;
-o-transition: background-color 200ms linear;
-ms-transition: background-color 200ms linear;
transition: background-color 200ms linear;
height: 87px;
}
.navbar-default .navbar-nav>li>a {
color: #ffffff;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
background-color: #F8BD23;
text-decoration: none;
color: #ffffff;
-webkit-transition: background-color 200ms linear;
-moz-transition: background-color 200ms linear;
-o-transition: background-color 200ms linear;
-ms-transition: background-color 200ms linear;
transition: background-color 200ms linear;
}
.navbar-nav > li{
padding-left:30px;
}
body {
background-color: black;
}
.logo img {width:100px;}
otherwise try
add width="100" inside the img tag
To make it shrink you have to make it inline-block and maybe use the following on the img tag:
style="display: inline-block; height: 40px; margin-top: 40px"
You can set whatever height and width you want
Related
.normal {
height: 75px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
.normal .navbar-right {
padding-top: 12px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
#media (max-width: 767px) {
.navbar{height: auto;}
.navbar-brand{
height: auto;}
}
.navbar-collapse{
border: 0px;
}
.navbar-brand {
padding: 0px !important;
}
.navbar-brand img {
max-height: 75px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
.shrink {
height: 50px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
.shrink .navbar-right {
padding-top: 0px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
.shrink .navbar-brand img {
max-height: 50px;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-ms-transition: 0.5s;
transition: 0.5s;
}
body {
min-height: 2000px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default navbar-fixed-top normal" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed button-middle" 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="http://placehold.it/150x70" /></a>
</div>
<div class="navbar-collapse collapse">
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Default</li>
<li>Static top</li>
<li>Fixed top</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
With the .navbar{height: auto;} I fixed the background issue of losing background of navbar-collapsed before scrolling.
The problem is fixing the navbar-collapsed background issue after scrolling when the navbar is shrinked because is interfering with the content after the navbar...
fixed height: 50px; needs to be deleted from the css .shrink class
0Is there anyway of replacing the slide down animation on the mobile navbar-collapse to fade in/out when called upon? I've tried using CSS keyframes and have managed to get the animation working but in reverse - instead of the the menu fading in and out when called upon, the menu is open when the page loads and fades out when the toggle button is pressed.
This is the nav html:
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="center">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar- collapse">
<i class="fa fa-bars fa-2x"></i>
</button>
</div>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Dierentuin</li>
<li>B-Roll</li>
<li>Carousel</li>
<li>Structural Curtains</li>
<li>Proxy</li>
<li>Art in the Underbelly</li>
<li>Suburbanism</li>
<li>Novelty</li>
<li>Album Covers</li>
<li>Fortyounce London</li>
<li>Covmns Clothing</li>
<li>Siobahn Palmer</li>
<li>Django Django</li>
<li>I like Trains</li>
<li>Glass Animals</li>
<li>Spring Offensive</li>
<li>Black Bird</li>
<li>Olympians</li>
<li>The Soft</li>
<li>Wordplay Issue #10</li>
</ul>
</div>
</nav>
The CSS is as follows:
.navbar-nav {
margin: 0;
min-height: auto;
}
.navbar-nav {
float: none!important;
}
.navbar-nav>li {
float: none;
}
.navbar-inverse {
background-color: transparent;
border-color: transparent;
}
.navbar-inverse .navbar-toggle:hover, .navbar-inverse .navbar-toggle:focus {
background-color: transparent;
}
.navbar-inverse .navbar-toggle {
border-color: transparent;
}
.nav>li{
display:inline-block;
}
.collapsing {
opacity: 0;
transition:opacity 0.3s linear;
-webkit-transition:opacity 0.3s linear;
-moz-transition:opacity 0.3s linear;
-o-transition:opacity 0.3s linear;
}
.navbar-collapse.collapse.in{
opacity:0;
transition:opacity 0.3s linear;
-webkit-transition:opacity 0.3s linear;
-moz-transition:opacity 0.3s linear;
-o-transition:opacity 0.3s linear;
}
.navbar-collapse.collapse{
opacity: 1;
transition:opacity 0.3s linear;
-webkit-transition:opacity 0.3s linear;
-moz-transition:opacity 0.3s linear;
-o-transition:opacity 0.3s linear;
}
.navbar-collapse {
width: auto;
border-top: 0;
-webkit-box-shadow: none;
box-shadow: none;
margin-top: 194px;
max-height: none;
font-family:"aktiv-grotesk-std";
font-weight: 400;
line-height: 54px;
font-size: 60px;
display:block !important;
}
I'm still learning how to get to grips with Bootstrap 3, so any help would be gratefully received.
Since the collapse plugin modifies the height of the collapsable container you could override the height property using !important:
.navbar-collapse {
opacity: 0;
width: auto;
height: auto !important;
border-top: 0;
-webkit-box-shadow: none;
box-shadow: none;
margin-top: 194px;
max-height: none;
font-family:"aktiv-grotesk-std";
font-weight: 400;
line-height: 54px;
font-size: 60px;
display:block !important;
}
I also included an example on jsfiddle: http://jsfiddle.net/VVrPd/
You should also be careful when using !important, it's not a good practice: What are the implications of using "!important" in CSS?
This solution works better for me, and gets rid of setting the height auto and the !important rules:
.navbar-collapse {
transition: height 3s , opacity 0.3s ;
opacity: 0;
}
There is still a 'slide' transition, but the workaround is setting enough delay (in this case 3s) so will be invisible to the user
I have been watching tutorials on creating a responsive navbar and one thing I am trying to create is a responsive menu button. I have created the button as you can see here:
http://jsfiddle.net/nickmadd/LvhCh/4/
The HTML
<nav class="navbar navbar-default affix-top nav-links" data-spy="affix" data-offset-top="100" role="navigation">
<div class="container">
<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>
<div class="navbar-header"> <a class="navbar-brand" href="/"><img src="media/img/nav-logo.png" alt="Driven Car Sales Logo" class="img-rounded logo-nav navbar-brand" /></a>
</div>
<div class="nav-collapse navbar-responsive-collapse" data-toggle="collapse" data-target=".navbar-nav">
<ul class="nav navbar-nav">
<li>Used Cars
</li>
<li>Get Finance
</li>
<li class="dropdown">About Driven<strong class="caret"></strong>
<ul class="dropdown-menu">
<li> <a href "#">The Team</a>
</li>
<li> <a href "#">Our Partners</a>
</li>
</ul>
<!--Drop Down End-->
</li>
<li>How To Find Us
</li>
<li>Contact Us
</li>
</ul>
</div>
</div>
</nav>
The CSS
.navbar-toggle {
display: block;
}
.logo-nav {
height: 2.3em;
width: auto;
}
.brand {
font-size: 2em;
margin: 20px 0 25px;
}
.navbar-brand {
opacity: 0;
color: #ff0066;
-webkit-transition:opacity 0.3s ease-in;
-moz-transition:opacity 0.3s ease-in;
-o-transition:opacity 0.3s ease-in;
transition: opacity 0.3s ease-in;
margin-left: 0px;
}
.navbar {
border-radius: 0px;
border-left: none;
border-right: none;
}
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar- default .navbar-nav>.open>a:focus {
color: #fff;
background-color: #DD3B4D;
}
.navbar-default .navbar-nav>li>a:hover, .navbar-default .navbar-nav>li>a:focus {
color: #fff;
}
.dropdown-menu {
color: #fff;
background-color: #DD3B4D;
}
.dropdown-menu>li>a {
color: #fff;
}
nav.affix {
top: 0;
width: 100%;
z-index: 1000;
}
nav.affix .navbar-brand {
opacity: 1;
height: 2.3em;
width: auto;
}
.navbar-header {
width: 0px;
-webkit-transition:width .4s ease-in-out;
-moz-transition:width .4s ease-in-out;
-o-transition:width .4s ease-in-out;
transition:width .4s ease-in-out;
margin: 0 1em 0 1em
}
nav.affix .navbar-header {
width: 8em;
-webkit-transition: width .4s ease-in-out;
-moz-transition: width .4s ease-in-out;
-o-transition: width .4s ease-in-out;
transition: width .4s ease-in-out;
margin: 0 1em 0 0;
}
.nav-links {
font: 600 15px/1.5'Arimo';
}
.navbar-nav > li:last-child {
border-right: 1px solid #475d88;
}
ul.nav a:hover {
color: #fff !important;
background-color: #DD3B4D !important;
-webkit-transition: background-color 0.6s ease;
-moz-transition: background-color 0.6s ease;
-o-transition: background-color 0.6s ease;
transition: background-color 0.6s ease;
}
nav.affix .navbar-brand {
display: inline-block;
}
The issue is that when it opens in the browser it is still there even in a large viewpoint. I need it to appear when it get's towards mobile size. I could go and do this with media queries but I'm sure that bootstrap is meant to do this for you?
Am I missing something?
It's because you are overriding the Bootstrap css with your own css, at the very top of your css you have:
.navbar-toggle {
display: block;
}
which tells ".navbar-toggle" to always show. Remove this and it will show/hide correctly. Also these docs might be useful if you have any more trouble.
Update
Updated fiddle with correct syntax. The main issue was that you had .nav-collapse instead of .navbar-collapse.
You are missing the hidden class which is a large part of bootstrap's responsiveness on different viewport sizes. Check out this bootply
Your button works fine when you make it hidden on large and medium viewports:
<button class="navbar-toggle hidden-md hidden-lg" 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>
Read about the sizes and hiding here. You can add that class to everything in bootstrap, so move it around if you want to hide more or less.
I am trying to use the collapse function in Bootstrap after watching some tutorials I tried it out myself and I am left with no links showing on a large viewport.
Here is my code does anbody notice anything that might be wrong with it?
The HTML:
<nav class="navbar navbar-default affix-top nav-links" data-spy="affix" data-offset-top="100" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/"><img src="media/img/nav-logo.png" alt="Driven Car Sales Logo" class="img-rounded logo-nav navbar-brand"></a>
</div>
<div class="nav-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li>Used Cars
</li>
<li>Get Finance
</li>
<li class="dropdown">About Driven<strong class="caret"></strong>
<ul class="dropdown-menu">
<li>
<a href"#">The Team</a>
</li>
<li>
<a href"#">Our Partners</a>
</li>
</ul> <!--Drop Down End-->
</li>
<li>How To Find Us
</li>
<li>Contact Us
</li>
</ul>
</div>
</div>
</nav>
The custom CSS:
.logo-nav {
height: 2.3em;
width: auto;
}
.brand {
font-size: 2em;
margin: 20px 0 25px;
}
.navbar-brand {
opacity: 0;
color: #ff0066;
-webkit-transition:opacity 0.3s ease-in;
-moz-transition:opacity 0.3s ease-in;
-o-transition:opacity 0.3s ease-in;
transition: opacity 0.3s ease-in;
margin-left: 0px;
}
.navbar {
border-radius: 0px;
border-left: none;
border-right: none;
}
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar- default .navbar-nav>.open>a:focus {
color: #fff;
background-color: #DD3B4D;
}
.navbar-default .navbar-nav>li>a:hover, .navbar-default .navbar-nav>li>a:focus {
color: #fff;
}
.dropdown-menu {
color: #fff;
background-color: #DD3B4D;
}
.dropdown-menu>li>a {
color: #fff;
}
nav.affix {
top: 0;
width: 100%;
z-index: 1000;
}
nav.affix .navbar-brand {
opacity: 1;
height: 2.3em;
width: auto;
}
.navbar-header {
width: 0px;
-webkit-transition:width .4s ease-in-out;
-moz-transition:width .4s ease-in-out;
-o-transition:width .4s ease-in-out;
transition:width .4s ease-in-out;
margin: 0 1em 0 1em
}
nav.affix .navbar-header {
width: 8em;
-webkit-transition: width .4s ease-in-out;
-moz-transition: width .4s ease-in-out;
-o-transition: width .4s ease-in-out;
transition: width .4s ease-in-out;
margin: 0 1em 0 0;
}
.nav-links {
font: 600 15px/1.5 'Arimo';
}
.navbar-nav > li:last-child{
border-right: 1px solid #475d88;
}
ul.nav a:hover {
color: #fff !important;
background-color: #DD3B4D !important;
-webkit-transition: background-color 0.6s ease;
-moz-transition: background-color 0.6s ease;
-o-transition: background-color 0.6s ease;
transition: background-color 0.6s ease;
}
nav.affix .navbar-brand {
display: inline-block;
}
Sorry for the amount of CSS I didn't realise how much there was ha.
I have had a good play about and can't seem to stop this from happening.
Remove the collapse class
Link http://jsfiddle.net/LvhCh/1/
<div class="nav-collapse navbar-responsive-collapse" data-toggle="collapse" data-target=".navbar-nav">
I think I am close, but I don't know what am missing.
I am using the same code as is on this fiddle:
http://jsfiddle.net/2tPGy/3/
HTML:
<ul class="projectGrid align">
<li id="project-1">
<a href="#">
<div class="img-overlay">
<h4>Title</h4>
<p>A description of the image</p>
</div>
</a>
</li>
</ul>
CSS:
.projectGrid li {
display: inline-block;
margin: 0 20px 20px;
box-shadow: 0px 0px 8px rgba(0,0,0,0.2);
opacity:0.7;
border-radius: 11px;
-moz-border-radius: 11px;
-webkit-border-radius: 11px;
text-indent: -9000px;
-webkit-transition: box-shadow .25s ease-in-out, opacity .25s ease-in-out;
-moz-transition: box-shadow .25s ease-in-out, opacity .25s ease-in-out;
-o-transition: box-shadow .25s ease-in-out, opacity .25s ease-in-out;
-ms-transition: box-shadow .25s ease-in-out, opacity .25s ease-in-out;
transition: box-shadow .25s ease-in-out, opacity .25s ease-in-out;
}
.projectGrid li a {
display: block;
width: 280px;
height: 280px;
background-color: grey;
border: solid;
border-radius: 11px;
-moz-border-radius: 11px;
-webkit-border-radius: 11px;
} .projectGrid li:hover {
box-shadow: 0px 0px 8px rgba(0,0,0,0.7);
opacity:1.0;
}
#project-1 {
height:286px;
overflow:hidden;
position:relative;
width:286px;
}
.img-overlay {
background-color:#000;
bottom:0;
color:#fff;
opacity:0;
filter: alpha(opacity=0);
position:absolute;
width:100%;
z-index:1000;
}
#project-1:hover .img-overlay {
opacity:0.75;
filter: alpha(opacity=75);
transition:opacity 0.25s;
-moz-transition:opacity 0.25s;
-webkit-transition:opacity 0.25s;
}
#project-1 a {
background: url('../images/1.png') no-repeat scroll;
background-size: 280px 280px;
}
The code works on the fiddle, but does not work on my website.
The text in the div does not show up on my website.
Can anyone guide me as to why this might be happening?
Not only is the <ul> tag misspelled as <ui> but the <ul> wasn't closed. jsFiddle update here: http://jsfiddle.net/KwyDt/3/
<ul class="blah">
<li id="project-1">
<a href="#">
<div class="img-overlay">
<h4>Title</h4>
<p>A description of the image</p>
</div>
</a>
</li>
</ul>
Also that wrapping around a <div> is completely wrong. Was going to debug the CSS more but you might need to clarify what the final result is. As it stands this is really messy & hard to decipher. I think it works now, but I am still not sure based on the way the code is formatted.
Check out my fork of your jsFiddle. Is this what you're looking for? Basically, instead of making adjustments to the opacity, use display:none on the regular .img-overlay css, then change to display:block on :hover. Does this work on your site? I also made #Giacomo1968's suggested edits regarding your unclosed ui tag, assuming you meant ul.
Also, why is this line in here?
text-indent:-9000px;
I commented that out and everything looks great in the updated jsFiddle. Let me know if that fixes things on your end.