I want to add two logos to my bootstrap navbar, but I also want them to be responsive (i.e. I want them to get smaller, not stacked when I decrease the screen size). Here's the navbar code I have been working on-
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="Brand" id="brand1" src="img/image.png">
</a>
<a class="navbar-brand" href="#">
<img alt="Brand" id="brand2" src="img/image2.png">
</a>
</div>
</div>
</nav>
Any help would be greatly appreciated!
I have created the example of having two logo side by side.
Please check the working example at CODEPEN
HTML:
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="nav-header">
<div class="row">
<div class="col-sm-4">
<div class="row">
<div class="col-xs-6">
<a class="navbar-brand" href="#">
<img alt="Brand" id="brand2" src="http://www.kratosuk.com/wp-content/uploads/2013/07/joomla-logo.png" class="img img-responsive">
</a>
</div>
<div class="col-xs-6">
<a class="navbar-brand" href="#">
<img alt="Brand" id="brand1" class="img img-responsive" src="http://www.kratosuk.com/wp-content/uploads/2013/07/drupal-logo.png">
</a>
</div>
</div>
</div>
</div>
</div>
</nav>
CSS:
.navbar-brand {
display: inline-block;
float: none;
font-size: 18px;
height: 100%;
padding: 0;
vertical-align: middle;
}
I hope it helps you
Enjoy :)
The 'img-reponsive' class should help you.
<img alt="Brand" id="brand1" src="img/image.png" class="img-responsive">
Hope it helped you :)
Related
I am working on a top banner with Bootstrap and my condensed menu always is wrapping to a new line for 1024x768. This is working well for resolution greater than 1024x768. Please advise in correcting my html so that the banner stays fixed on the top for 1024x768 resolution.
The banner text has to be centered, the logo should be on the left and logged in user name should be on the right.
.headerBackGroundColor {
background-color: cyan;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar navbar-inverse navbar-static-top headerBackGroundColor">
<div class="logo">
<a href="">
<img src="https://via.placeholder.com/100" alt="Title" />
</a>
</div>
<div class="navbar-header navbar-brand">
Application Title on Banner Goes Here
</div>
<div class="navbar-nav nav navbar-right">
<button class="btn btn-default" type="button" style="cursor:default !important;">
<span class="user-name">
Welcome loggedInUser
</span>
</button>
</div>
</div>
Does this look good to you?
.headerBackGroundColor {
background-color: cyan;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar navbar-inverse navbar-static-top headerBackGroundColor">
<div class="container">
<div class="row w-100 justify-content-md-around row-cols-3">
<div class="col-lg-auto">
<div class="logo">
<a href="">
<img src="https://via.placeholder.com/100" alt="Title" />
</a>
</div>
</div>
<div class="col-lg-auto d-flex align-items-center">
<div>Application Title on Banner Goes Here</div>
</div>
<div class="col-lg-auto d-flex align-items-center">
<div class="navbar-nav nav navbar-right">
<buttonclass="btn btn-default" type="button" style="cursor:default !important;">
<span class="user-name"> Welcome loggedInUser </span>
</button>
</div>
</div>
</div>
</div>
</div>
I have a html page which has a logo on the top:
default logo
After I resized my logo with the same size and kept it over there, its not appearing:
current status
The code for logo is the following
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="logo">
<div class="relative-logo">
<img src="assets/images/logo" alt="logo">
</div>
</div>
<div class="container">
<div class="navbar-header">
<div class="responsive-logo visible-xs">
<img src="assets/images/logo-mobile.png" alt="">
</div>
The logo is appearing in mobile mode when I did the same with the mobile logo resizing. Can anyone tell me why my logo is not appearing in desktop mode?
You forgot the file-extension (.png, .jpg etc.) in the src of the <img>. Change
<img src="assets/images/logo" alt="logo">
to
<img src="assets/images/logo.png" alt="logo">
Here is the full code:
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="logo">
<div class="relative-logo">
<img src="assets/images/logo.png" alt="logo">
</div>
</div>
<div class="container">
<div class="navbar-header">
<div class="responsive-logo visible-xs">
<img src="assets/images/logo-mobile.png" alt="">
</div>
</div>
Try to add a / at the top of src: "/"
This is for absolute path.
Example <img src="/image.png"/> --> http://www.something.com/image.png
Example 2 <img src="/folder/image.png"/> --> http://www.something.com/folder/image.png
I am creating a navbar with icons (svg icons).
What is the best way to achieve this with Bootstrap 4?
This is what I want:
This is the closest I've achieved (without giving a fixed size to my icons or the link) is:
<div class="row justify-content-center">
<div class="col-sm-10">
<nav class="navbar d-flex align-items-end">
<a class="navbar-item active" href="#">
<img src="../images/icons/icon-type-blue.svg">
Type</a>
<a class="navbar-item" href="#">
<img src="../images/icons/icon-size-lightgrey.svg">
Size</a>
<a class="navbar-item" href="#">
<img src="../images/icons/icon-fitting-lightgrey.svg">
Fitting</a>
<a class="navbar-item" href="#">
<img src="../images/icons/icon-results-lightgrey.svg">
Results</a>
</nav>
</div>
</div>
Using the following CSS:
.navbar{
padding: 2em;
border-bottom: solid 2px #00588A;
}
.navbar a{
font-size: 1.25em;
font-weight: 700;
text-align: center;
text-transform: uppercase;
color: #ccc;
}
.navbar a.active{
color: #00588A;
}
.navbar a img{
margin-bottom: 0.75em;
}
Maybe I'm not integrating the right way?
Is giving the link a fixed size the best way?
Try This Code.
<div class="row justify-content-center">
<div class="col-sm-12">
<nav class="navbar d-flex align-items-end">
<div class="col-sm-3">
<a class="navbar-item active" href="#">
<img src="../images/icons/icon-type-blue.svg">Type</a>
</div>
<div class="col-sm-3">
<a class="navbar-item" href="#">
<img src="../images/icons/icon-size-lightgrey.svg">Size</a>
</div>
<div class="col-sm-3">
<a class="navbar-item" href="#">
<img src="../images/icons/icon-fittinglightgrey.svg">Fitting</a>
</div>
<div class="col-sm-3">
<a class="navbar-item" href="#">
<img src="../images/icons/icon-resultslightgrey.svg">Results</a>
</div>
</nav>
</div>
</div>
There are classes for icons in bootstrap search and check them out use these classes in a span element for example <span class="caret"></span> this will result in a drop-down icon and there is more icons just check them out
Ok my second option why don't you create your own icon class for example .icon-car { background-image: url("http://cdn5.iconfinder.com/data/icons/Symbolicons_Transportation/24/Car.png"); background-position: center center; }
You can have a more detailed answer in here How to add custom icon in Twitter Bootstrap?
I would like to position my image inside the navbar and my name on the right of the image. Here's my code:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img src="http://i665.photobucket.com/albums/vv18/luckycharm_boy/lucky_zpsfnt9dbol.jpg" border="0" alt=" photo lucky_zpsfnt9dbol.jpg" class="img-circle" height="50px">luckycharm-boy</a>
</div>
</div>
</nav>
You can use Flexbox on .navbar-brand and reduce padding a little bit
.navbar-default .navbar-brand {
display: flex;
align-items: center;
padding: 5px;
}
.navbar-brand img {
height: 100%;
margin-right: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><img src="http://i665.photobucket.com/albums/vv18/luckycharm_boy/lucky_zpsfnt9dbol.jpg" border="0" alt=" photo lucky_zpsfnt9dbol.jpg" class="img-circle" height="50px">luckycharm-boy</a>
</div>
</div>
</nav>
I have a solution without flex. You just need to setup some attributes for .navbar-brand and .navbar-brand>img.
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
.navbar-brand {
height: auto;
}
.navbar-brand>img {
display: inline-block;
padding-right: 10px;
}
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img src="http://i665.photobucket.com/albums/vv18/luckycharm_boy/lucky_zpsfnt9dbol.jpg" border="0" alt=" photo lucky_zpsfnt9dbol.jpg" class="img-circle" height="50px">luckycharm-boy</a>
</div>
</div>
</nav>
Why not use a media object here?
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<div class="media">
<div class="media-left media-middle">
<a href="#">
<img src="http://i665.photobucket.com/albums/vv18/luckycharm_boy/lucky_zpsfnt9dbol.jpg" border="0" alt=" photo lucky_zpsfnt9dbol.jpg" class="img-circle" height="50px">
</a>
</div>
<div class="media-body media-middle">
<h4 class="media-heading">Luckycharm-boy</h4>
</div>
</div>
</div>
</div>
</nav>
An another way which I prefer is - create a whole "row" div in full nav bar without nav-header , then you can fully control the positioning of img and text location in various screen sizes for mobile as well as large screens. Then you can give various col (columns) sizes and write in that .
I am saying this as it will help you to place it in any location
Easy fix would be using span. Check this out. DEMO here.
HTML:
<nav class="navbar navbar-default">
<div class="navbar-header">
<a class="navbar-logo" href="#">
<span><img src="http://i665.photobucket.com/albums/vv18/luckycharm_boy/lucky_zpsfnt9dbol.jpg" border="0" alt=" photo lucky_zpsfnt9dbol.jpg" class="img-circle" height="50px"/></span>
luckycharm-boy
</a>
</div>
</nav>
CSS:
a.navbar-logo {
color: #666666;
}
I have a bootstrap navbar. I have 3 pictures. I want one to pull right, one to pull left, and one to be in the center. I got the right and left, can't figure out how to center the last image. Tried CSS and wrapping it in a <p>, but it makes a separate line from the rest of the images.
Is there some CSS/bootstrap/html trick I'm not aware of?
<div class="nav navbar-inverse navbar-fixed-bottom">
<div class="container">
<img class="contactPicture pull-center" src="img/gmailIcon.png">
<img class="contactPicture pull-left" src="img/githubIcon.png">
<img class="contactPicture pull-right" src="img/linkedinIcon.png">
</div>
</div>
Asumming that the images are in relative positioning. You should just re-order your html?
So instead of:
<img class="contactPicture pull-center" src="img/gmailIcon.png">
<img class="contactPicture pull-left" src="img/githubIcon.png">
<img class="contactPicture pull-right" src="img/linkedinIcon.png">
You want:
<img class="contactPicture pull-left" src="img/githubIcon.png">
<img class="contactPicture pull-center" src="img/gmailIcon.png">
<img class="contactPicture pull-right" src="img/linkedinIcon.png">
if all else fails you can wrap it in a which may or may not work depending on your css.
I don't think there is any built it way to do this so you'll (most likely) have to position it yourself. Here's an example.
See Snippet.
.footer-img-center {
left: 50%;
position: absolute;
margin-left: -25px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="nav navbar-inverse navbar-fixed-bottom">
<div class="container">
<img class="contactPicture pull-left" src="http://placehold.it/50x50/f00">
<img class="contactPicture footer-img-center" src="http://placehold.it/50x50/fff">
<img class="contactPicture pull-right" src="http://placehold.it/50x50/ff0">
</div>
</div>
Since there's no "pull-center" in bootstrap, you can keep your markup the same and add the following to the CSS:
.nav .container {text-align:center;}
http://www.bootply.com/hsZ9HaJJmO
Okay folks, figure this one out. Put the image, in a row, in a col. Put the trouble image as a brand. here's my html
<div class="nav navbar-inverse navbar-fixed-bottom">
<div class="container">
<div class="row">
<div class="col-md-4">
<img class="contactPicture pull-left" src="img/githubIcon.png">
</div>
<div class="col-md-4">
<a class="navbar-brand-gmail" href="#"><img class="contactPicture gmail" src="img/gmailIcon.png"></a>
</div>
<div class="col-md-4">
<img class="contactPicture pull-right" src="img/linkedinIcon.png">
</div>
</div>
</div>
</div>
here's my custom css, taken from here http://www.bootply.com/9SOuY3vHlF
.navbar-brand-gmail {
position: absolute;
width: 100%;
left: 0;
text-align: center;
padding-top: 0;
margin: auto;}
the only thing I changed was adding padding top to zero, so it's in line with the other images.