I have a certain navbar as shown in the figure 2 . I want them to be in figure 1 when i minimize the browser .ie i need a responsive design.
The code i have tried is...
https://codepen.io/poornam/pen/dyGMmdp
<nav class="navbar-custom navbar navbar-expand-sm ">
<!-- Links -->
<ul class="navbar-nav">
<li class="nav-item">
<a class=" navbar-brand nav-link" href="#">balakrsihnan#gmail.com</a>
</li>
<li class="nav-item">
<a class=" navbar-brand nav-link" href="#">+91-9446558430</a>
</li>
</ul>
<div>
</div>
</nav>
figure 1
figure 2
This answer presumes that you are looking for a solution that utilizes Bootstrap 4.x though neither the code presented here or on your Codepen example clarify if you're using the most recent version or an older. With that being said:
By default the Navbar component is going to try to organize everything horizontally. Breaking out of this behavior is fairly straightforward using Bootstrap's various utility classes. In the example below d-flex does all the heavy lifting.
.navbar.navbar-custom {
background: #000;
}
.navbar-custom .navbar-brand,
.navbar-custom .navbar-text,
.navbar-custom .active {
color: #fff;
}
.navbar.navbar-custom .active {
display: inline-flex;
background: #ff0000;
border-radius: 50%;
margin: 0.125rem;
font-size: 1.5rem;
padding: 0.75rem 0.625rem;
text-decoration: none;
}
<nav class="navbar navbar-custom">
<div class="d-flex mr-sm-auto py-2">
<span class="fa fa-envelope fa-fw mr-1"></span>balakrsihnan#gmail.com
<span class="fa fa-phone fa-fw mr-1"></span>+91-9446558430
</div>
<div class="d-flex ml-sm-auto">
<span class="fab fa-fw fa-facebook"></span>
<span class="fab fa-fw fa-twitter"></span>
<span class="fab fa-fw fa-google"></span>
<span class="fab fa-fw fa-linkedin"></span>
<span class="fab fa-fw fa-youtube"></span>
<span class="fab fa-fw fa-instagram"></span>
<span class="fab fa-fw fa-pinterest"></span>
</div>
</nav>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css">
Your duplicate use of .navbar-brand seemed unnecessary to me and counter-intuitive to that classes purpose. I've wrapped your two hyperlinks in <div lass="d-flex mr-sm-auto py-2">...</div> which does the following:
Ensures the child elements will behave like flex children.
Makes sure on 'Small' breakpoint screens (and above) that we're pushing this to the left
Applies a top/bottom padding (PY-2)
A similar behavior is applied to the <div> that was housing your social media links. Applying flex behavior here lets everything get organized nicely. And we can ensure that this element aligns to the right of the screen using ml-sm-auto.
The format of the social media icons has also been updated to provide you more granular control of the shape / output. <font awesome icon>.
Related
I'm trying to vertically align a fontawesome icon with some text in a navbar from bootstrap. The vertical size of the navbar is set to 10vh. I'm not able to get the text aligned with the icon, it appears like in the below image:
Also I would like to add some horizontal space between the icon and the text. Here is my code:
<nav class="navbar navbar-expand-lg sticky-top navbar-dark bg-dark h-100">
<ul class="navbar-nav nav-fill w-100">
<li class="nav-item active">
<a class="nav-link d-flex align-items-center justify-content-center" href="#">
<i class="fa fa-home fa-2x icon-white"></i>
<p>Home</p><!--<span class="sr-only">(current)</span>-->
</a>
</li>
... (some more li)
</ul>
</nav>
I've also tried to put the icon inside the paragraph, placing the a element inside a div, and setting both of the same font-size, but I cannot make it work.
Try the following code, it worked for me:
<nav class="navbar navbar-expand-lg sticky-top navbar-dark bg-dark h-100">
<ul class="navbar-nav nav-fill w-100">
<li class="nav-item active">
<a class="nav-link" style="display: flex; align-items: center;" href="#">
<i class="fa fa-home fa-2x icon-white"></i>
<p style="margin-left: 12px;">Home</p>
</a>
</li>
... (some more li)
</ul>
</nav>
Also, here I'm giving the space between the text and the icon as 12px, you can change this according to your need.
You should make the tag a flex container with height 100% (obviously after setting position: relative. Then you can easily do justify-content: center; and align-items: center;
For any other HTML and CSS noob like me, it seems that p elements have margin by default. I have seen this question where it says that CSS 2.1 specification has a default style sheet for basic elements. Removing the bottom margin of the p element made it aligned with the icon.
Regarding horizontal space, DIVYIA BAID's suggestion to set a left margin is exactly what I was looking for.
it's very simple
Try This code for best alignment for Fontawesome or any other icon
<li styles="display:flex">
Home
<i class="fal fa-home" style="vertical-align: middle;margin: auto;"></i>
</li>
Wrap the content in a flex container and then align items center to horizontally align them.
This question already has answers here:
Center a flex item in a row when there are a different number of items on each side
(5 answers)
Closed 5 years ago.
JSFiddle
The point is to make left ul with max-width align left, center block without specified width be always centered (content of this ul may vary) and right ul be always floated to right with max-width in my top navbar.
The main problem is that when I specify widths for ul's flex properties dont't work as I expect: 3rd ul must be aligned to right while the 2nd should take as much space as posible in one line. It's ok with alignment but 3rd ul takes too much space (more than needed) and visually isn't floated to right. If a specify it's width to fix this center aligmnment of 2nd ul won't work. All elements have different width, as far as I know flex can handle only elements with equal width.
However, I guess this is a right bahaviour for flex.
HTML
<nav class="nav_wrapper" role="navigation">
<ul class="nav navbar-nav navbar-left">
<li data-item-id="nav-profile-menu">
<a id="menu_toggle"><i class="fa fa-bars"></i></a>
</li>
</ul>
<ul class="nav navbar-nav navbar-center">
<li data-item-id="nav-profile-menu">
<a class="summary" data-toggle="tooltip" title="" data-placement="bottom" data-original-title="usd">
<span class="summary-item">USD</span>
<span>
<i class="fa fa-arrow-circle-o-down red hidden-sm hidden-xs" aria-hidden="true"></i>
99 <span class="small-text hidden-sm hidden-xs">-0,0474</span>
</span>
</a>
</li>
<li data-item-id="nav-profile-menu">
<a class="summary">
<span class="summary-item">Brent</span>
<span>
<i class="fa fa-arrow-circle-o-down red hidden-sm hidden-xs" aria-hidden="true"></i>
99 <span class="small-text hidden-sm hidden-xs">-0,86%</span>
</span>
</a>
</li>
<li data-item-id="nav-profile-menu" class="hidden-xs">
<a class="summary">
<span class="summary-item">Ni</span>
<span>
<i class="fa fa-arrow-circle-o-up green hidden-sm hidden-xs" aria-hidden="true"></i>
105,00 <span class="small-text hidden-sm hidden-xs">1,29%</span>
</span>
</a>
</li>
<li data-item-id="nav-profile-menu" class="hidden-xs">
<a class="summary">
<span class="summary-item">Al</span>
<span>
<i class="fa fa-arrow-circle-o-up green hidden-sm hidden-xs" aria-hidden="true"></i>
2131,50 <span class="small-text hidden-sm hidden-xs">0,35%</span>
</span>
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-auth">
<li data-item-id="nav-profile-menu">
<span>reg</span> <i class="fa fa-user-plus"></i><span></span>
</li>
<li data-item-id="nav-profile-menu" data-toggle="tooltip" title="" data-placement="bottom">
<span>auth</span> <i class="fa fa-sign-in"></i>
</li>
</ul></nav>
why you don't use flex + absolute and u use float?
Much cleaner and no need for clear after floats.
.nav_wrapper {
position: relative;
display: flex;
justify-content: center;
}
.navbar-left {
position: absolute;
left: 0;
}
.navbar-auth {
position: absolute;
right: 0;
}
and you can remove the width of ul
I was wondering how can I put my bootstrap buttons in a vertical line going down in the middle of my web page? I tried using vertical-align: top;
but it didn't work.
My site code.
Here is the HTML to the buttons I want to go down one after the other in a vertical line in the middle of the web page.
<ul class="list-inline intro-social-buttons">
<li>
<i class="fa fa-linkedin fa-fw"></i> <span class="network-name">Web Development Portfolio</span>
</li>
<li>
<i class="fa fa-linkedin fa-fw"></i> <span class="network-name">GFX Design Portfolio</span>
</li>
<li>
<i class="fa fa-linkedin fa-fw"></i> <span class="network-name">About Me</span>
</li>
<li>
<i class="fa fa-linkedin fa-fw"></i> <span class="network-name">Contact Me</span>
</li>
</ul>
As a side note if anyone could also help me with this it would be much appreciated.
How can I adjust the width of how long the <hr class="content-divider"> is but I need it to be responsive. I don't want the line to go past from where the buttons on each side end.
ul.intro-social-buttons li {
padding-bottom: 10px;
float: left;
display: block;
width: 100%;
}
I have problem, I am trying to get the same result as in the example (Fontawesom) https://fortawesome.github.io/Font-Awesome/examples/
I want to implement
Fixed Width Icons
I have downloaded FontAwesome package in my folder and add link in head I have also tried CDN like but the same result. Icons are showed but styles are not applied as in the example.
http://imgur.com/3KZgMoV
Here is my result
<link rel="stylesheet" href="css/font-awesome.min.css">
And list
<div class="list-group">
<a class="list-group-item" href="#"><i class="fa fa-home fa-fw"></i> Home</a>
<a class="list-group-item" href="#"><i class="fa fa-book fa-fw"></i> Library</a>
<a class="list-group-item" href="#"><i class="fa fa-pencil fa-fw"></i> Applications</a>
<a class="list-group-item" href="#"><i class="fa fa-cog fa-fw"></i> Settings</a>
</div>
Please help, what I am doing wrong ?
The styles are not the same because you have the fontawesoms icons in an anchor tag, so the icons are inheriting the anchors styles. Just override those styles, like:
.list-group-item{
color: #000; /* black */
text-decoration: none; /* remove the underline */
display: block; /* to make the anchors take full width */
}
Well to achieve this you have to update your CSS accordingly. change color and size of your font as per your requirement.
I have a small issue. I've added a bottom navbar with 3 social icons and a text to present what are these icons. Screenshot
I would like to put this text really at the right, or left, but not like this. It does the same thing if I do in the other side.
Like that the icons would be really at the middle.
<nav class="navbar navbar-default navbar-fixed-bottom" role="navigation">
<div class="container">
<p class="navbar-text navbar-right text-right">Suivre l'IUT de Lens</p>
<div class="social">
<ul>
<li><i class="fa fa-lg fa-facebook"></i></li>
<li><i class="fa fa-lg fa-twitter"></i></li>
<li><i class="fa fa-lg fa-google-plus"></i></li>
</ul>
</div>
</div>
</nav>
First, I should comment that I don't see any question marks in your "question." I would urge you to edit your question to be more clear for future readers' sake. In any case, I think I know what you are asking (the picture did help). The answer is, you need CSS!
There are more than one way to accomplish the spacing and placement you want. Here's one:
HTML (I removed some stuff that didn't seem to matter):
<nav>
<p style="width:100%">
<div class="linktext">
Suivre l'IUT de Lens
</div>
<div class="linkgroup">
<i class="link fa fa-lg fa-facebook"></i>
<i class="link fa fa-lg fa-twitter"></i>
<i class="link fa fa-lg fa-google-plus"></i>
</div>
</p>
CSS:
.link {
padding-right: 10px
}
.linkgroup{
padding-right:20px;
float:right;
}
.linktext {
padding-right:20px;
float: right;
}
So, you just need to define your properties in the CSS, then assign the relevant CSS class to your <div>/<p>/<whatever>
Here is a JSFiddle: http://jsfiddle.net/af8rpc99/