I'm working on building a website with bootstrap, and I have a navbar fixed to the top of the window. I'm trying to make the abbreviated logo (BLM) on the left of the bar transparent through the letters and the navbar (so that whatever is on the page can be seen through the letters).
Anyone know what css (or html) needs to be added to do this?
Below is my navbar code:
<!-- Fixed navbar -->
<div class="navbar navbar-inverse navbar-fixed-top" 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="#">BLM</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>About</li>
<li class="dropdown">
The Team <span class="caret"></span></li>
<ul class="dropdown-menu" role="menu">
<li>PersonA</li>
<li>PersonB</li>
<li>PersonC</li>
<li>PersonD</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
The part I'm talking about making transparent through to the page is
<a class="navbar-brand" href="#">BLM</a>
I can use CSS to make the navbar-brand transparent, but then it's just black because the navbar is black (and I don't want the navbar to be transparent).
In this example, I want to be able to see the red wall through the BLM letters
Thanks for any help/thoughts!!
Unfortunately, there is no CSS feature (yet) that does what you want it to do while being cross-browser compatible. However, the solution to your problem is easy.
Replace your logo with a .png with transparent letters and a semi-transparent background that matches the rest of the navbar. Shuffle around your divs so that your logo and the rest of the navbar are separate elements, and you're done!
Try opacity and a value of a decimal.
.navbar-brand {
opacity: 0.5;
}
Related
I'm trying to make dropdown navbar box black, I've been looking for solution for 2 days, but still even templates from bootstrap docs doesn't work properly, I mean that dropdown box.
Here is my html code for navbar:
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navcol-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 navbar-link"><img src="/images /logo.png"></a>
</div>
<div class="collapse navbar-collapse" id="navcol-1">
<ul class="nav navbar-nav navbar-right">
<li role="presentation">Main </li>
<li role="presentation">Main </li>
<li role="presentation">Main </li>
<li role="presentation">Courses </li>
<li role="presentation">Help
<a class="visible-sm-block" href="#"> </a>
</li>
</ul>
</div>
</div>
</nav>
Here is Page hierarchy:
You're correctly using .navbar-inverse, which should already be making your navbar black, as can be seen here.
There are a couple of reasons why this may not be working for you.
You've not referenced Bootstrap correctly.In this case, check for errors in your F12 Developer Tools' console.
You're using CSS for a different version of Bootstrap than the one you've loaded.
You have code that is overriding the defaults with higher specificity.
You have cached outdated CSS. Refresh your stylesheet refrence with CTRL + F5, and hold SHIFT while clicking on the refresh icon to ensure you clear your CSS cache as well.
Hope this helps! :)
I have a list item that has a stuck background-color. The list item is "Contact" and the background-color is black. When the page loads, this list item's background-color starts off as black which I don't understand why. I don't want it to start off with any background-color. I noticed the .navbar-inverse class causes this to happen, but then when I take it out, and shorten my browser to the size of a mobile viewport, my icon-bar button which is supposed to collapse/extend the navbar disappears. So it causes that problem when I take out .navbar-inverse.
Here is the codepen: http://codepen.io/capozzic1/full/JKmZzZ/
Here is the code:
<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="#">DreamerCC</a>
</div>
<div class="collapse navbar-collapse" id="myNavBar">
<ul class="nav navbar-nav">
<li>About</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</div>
The class that gives it the black background is .navbar-nav>.active>a.
Add background-color: transparent to that element in your stylesheet.
.navbar-nav>.active>a {
background-color: transparent;
}
Use a custom style and set it's background color with !important so that it will override the navbar-inverse default black color.
let me know if you understand that!
I'm creating template using Bootstrap v3.3.6.
Here's the part of my template:
As you can see I have navbar fixed at the top and I also have menu items that are icons or simply images embedded between <li></li> tags, user info icon and gear icon.
What I don't know for sure is if I'm doing it correctly, I mean is there a special class in bootstrap that is specifically for menu items where you want to insert image. Maybe those images are not supposed to be there.
Another question would be if I should place my logo image inside <a class="navbar-brand"></a>? If I try to insert bigger logo image in height than navbar height then logo image isn't properly centered. What is the easiest way to properly change navbar height and how to center images vertically in navbar?
(Maybe that's too much code, but I wanna make sure that my question isn't lacking anything) only part where two images are inserted as navigation items are relevant
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" 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="#">Workout.lt</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 navbar-right">
<li>
Vardenis Pavardenis
</li>
<li>
<img src="images/user-info.png">
</li>
<li>
<img src="images/user-gear.png">
</li>
<li>
Services
</li>
<li>
Atsijungti
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
To answer the second question, I put the image in the navbar-brand anchor and then use the inspector to adjust how the navbar looks. I copy that CSS into a separate document that overrides the default Bootstrap CSS.
<div class="navbar-header">
<button type="button" class="navbar-toggle" 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="#"><img src="../path/picture.jpg" alt="picture" height="90" width="180" /></a>
</div>
Your CSS would look something like this:
.nav-bar-brand {
height:90px;
width:100%; /*or whatever width you wanted*/
}
Again, using the inspector is always quicker than experimenting and then uploading the CSS document.
Okay, so I'm making a website using Bootstrap 3 framework, and I have an issue.
When I put an image (regular one, with an img tag) it has white space (left and right) across the screen. http://prntscr.com/9wuek5 - you can see that here, it even goes under my navbar. What I want to do is somehow get rid of that white space, and move picture to the center (horizontally and vertically). Here is my code so far:
<nav id="mainNavbar" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#colaps">
<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="#">ivke11080</a>
</div>
<div class="collapse navbar-collapse" id="colaps">
<ul class="nav navbar-nav navbar-right">
<li><a class="page-scroll" href="#">Home</a></li>
<li><a class="page-scroll" href="#">Projects</a></li>
<li><a class="page-scroll" href="#portfolio">About</a></li>
</ul>
</div>
</div>
</nav>
<img src="img/chase.jpg"/>
I tried to put border around image so i can see if it applies to the white space, but it's not, it's just around image as it should be.
You can absolutely position your image by using the following styles:
img{
position:absolute;
top:50%;
left:50%;
transform:translate(-50%, 50%);
}
See this fiddle
Having CSS/HTML issues with Bootstrap. For some reason it seems the navigation is not pushing down the aspects of the HTML that follows. See https://jsfiddle.net/xaazf6u2/
<div id="topNavigation">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="#">BCF</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li class="dropdown">History <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>FGT</li>
<li>BB</li>
</ul>
</li>
</ul>
<ul id="login" class="nav navbar-nav navbar-right"></ul>
</div><!--/.nav-collapse -->
</div>
</nav>
</div>
<div id="pageContent" class="container">
<div class="jumbotron">
<h1>Welcome</h1>
<p>Use the form below to upload an order feed. Once uploaded, FedEx shipping will be purchased, labels and packing slip generated for us. Use the navigation above to access previously generated files.</p>
</div>
</div>
From the examples you can see that the jumbotron should have some space below the navigation http://getbootstrap.com/examples/theme/
When you used the fixed navbar Bootstrap recommends you add padding to your body to prevent this problem. So in your CSS you need to add
body { padding-top: 70px; }
The navbar is position:fixed so that it stays on the screen as you scroll. Elements with fixed position don't affect layout of other elements, so you'll need to manually set margin or padding on them.
See the Bootstrap documentation for notes on this.
Body padding required
The fixed navbar will overlay your other content, unless you add padding to the bottom of the <body>. Try out your own values or use our snippet below. Tip: By default, the navbar is 50px high.
Copy
body { padding-bottom: 70px; }
Make sure to include this after the core Bootstrap CSS.
The class "navbar-fixed-top" means that the content is scrollable and goes under the navbar.
Add a margin-top to the content if you want to keep this feature or remove the "navbar-fixed-top" class if you don't.
Navigation bar is fixed to the top by default you can change that by removing the class 'navbar-fixed-top'.