I am new to Bootstrap: I want to place logo image, location image with address, phone number with text above the navigation. Logo details should be centered.
What I have tried:
<header >
<div class="container ">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<img class="img-fluid" style="max-width: 50%;" src="images/logo.png" alt="logo">
<img class="img-fluid" style="max-width: 5%" src="images/header-address.png" alt="logo">
<span class="span-text">1234 Abcd Efg <br> HI jk Lm,123466 </span>
<img class="img-fluid" style="max-width: 5%;" src="images/header-phone.png" alt="logo">
<span class="span_text">(123) 456 7890 <br> Call Us </span>
</div>
<div class="col-md-6">
</div>
</div>
</div>
</header>
<section >
<div class="container mx-auto">
<div class="row">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ABOUT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">GALLERY</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT US</a>
</li>
</ul>
</div>
</div>
</nav></div>
</div>
</section>
The alignment of the logo, location, and phone number is not achieved.
How to fix this?
Use margin: 0 auto; for .col-md-6
.col-md-6 {
flex: 0 0 auto;
width: 50%;
text-align: center;
}
and if you want to also center the navigation items then add this:
.navbar-expand-lg .navbar-nav {
flex-direction: row;
margin: 0 auto;
}
Top Phone number... centered:
Nav Items centered:
Both centered with text-align
Related
I have tried using flex property and justify content but that doesn't work as well. I tried the below mentioned code.
the aim is to make a website with a logo on top and navbar right below like shown below
how the site looks like as of now
<header class="top-part">
<div class="logo">
<img class="logo" src="images/logo.png" height=100px width="237px" >
</div>
<nav class="navbar navbar-expand-lg navbar-light bg-light ">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav ">
<li >
<a class="nav-link" id="home"href="#">link 1</a>
</li>
<li class="nav-item">
<a class="nav-link" id="cart" href="#">link 2</a>
</li>
<li class="nav-item">
<a class="nav-link" id="contact"href="#">link 3</a>
</li>
</ul>
</div>
</nav>
</header>
</head>
css :
#media screen and (min-width:777px){
.nav-link {
padding:18px 0;
min-width:120px;
}
.navbar {
padding: 0
}
}
.header{
position:sticky ;
top: 0;
}
I'd recommend doing some research and practicing with some basic HTML/CSS, so you understand the basics and know what everything does.
For this specific example you should look into 'flexbox'!
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<header class="d-flex flex-column align-items-center">
<img style="width: 100px;" src="https://images.unsplash.com/photo-1605666807892-8c11d020bede?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTJ8fGJhbmFuYXxlbnwwfHwwfHw%3D&w=1000&q=80" alt="">
<nav class="w-100 d-flex bg-light">
<a class="p-2 bd-highlight text-black-50 text-decoration-none" href="">link 1</a>
<a class="p-2 bd-highlight text-black-50 text-decoration-none" href="">link 2</a>
<a class="p-2 bd-highlight text-black-50 text-decoration-none" href="">link 3</a>
</nav>
</header>
header {
width: 100%;
text-align: center;
}
a:first-of-type{
float: left;
}
a:last-of-type{
float: right;
}
<header>
<img style="width: 100px;" src="https://images.unsplash.com/photo-1605666807892-8c11d020bede?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTJ8fGJhbmFuYXxlbnwwfHwwfHw%3D&w=1000&q=80" alt="">
<nav>
link 1
link 2
link 3
</nav>
</header>
Here is one method:
Add d-flex, flex-row, and justify-content-center to your parent div containing the logo.
You can add the same to your parent div for the links (ul and li's)
Your links are left aligned, so you can add "text-center" to classes of your <ul> element.
It would look like this:
<header class="top-part">
<div class="logo d-flex flex-row justify-content-center">
<img class="logo" src="images/logo.png" height=100px width="237px" >
</div>
<nav class="navbar navbar-expand-lg navbar-light bg-light ">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse d-flex flex-row justify-content-center" id="navbarNavDropdown">
<ul class="navbar-nav text-center">
<li>
<a class="nav-link" id="home" href="#">link 1</a>
</li>
<li class="nav-item">
<a class="nav-link" id="cart" href="#">link 2</a>
</li>
<li class="nav-item">
<a class="nav-link" id="contact"href="#">link 3</a>
</li>
</ul>
</div>
</nav>
</header>
Also just a note, I see your code above is ending with </head>. Make sure you are not putting this code in the <head> of your site, but the <body> :)
I am trying to create a website with a navigation bar that is the full width of the screen and has a black background. I want the links to also be centered and evenly distributed.
I want to get rid of the white space on the left and right and make it a full black background from end to end. I can't find any fixes.
CSS
.masthead {
height: 25vh;
min-height: 500px;
background-image: url('https://source.unsplash.com/BtbjCFUvBXs/1920x1080');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
/* NAVBAR */
/* Evenly Distribute Navbar Components */
.navbar-nav > li{
padding-left:30px;
padding-right:30px;
}
.navbar {
background-color: #000000;
}
HTML
<body">
<section class="header">
<div class="container">
<!-- Navigation Bar -->
<div class="row">
<div class="navbar2 col-md-12" data-interval="false">
<nav class="navbar navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="#">MAD</a>
<button
class="navbar-toggler"
type="button"
data-mdb-toggle="collapse"
data-mdb-target="#navbarNav"
aria-controls="navbarNav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Book a Service</a>
</li>
<li class=[![enter image description here](https://i.stack.imgur.com/MKM0z.png)](https://i.stack.imgur.com/MKM0z.png)"nav-item">
<a class="nav-link" href="#"
>Shop</a
>
</li>
</ul>
</div>
</div>
</div>
</nav>
</div>
</div>
</section>
The problem you are facing here is due to the container as its limiting your nav to a certain with.
this can be resolved by moving your container element from the parent of nav to the child of nav, something like this.
<section class="header">
<!-- Navigation Bar -->
<div class="row">
<div class="navbar2 col-md-12" data-interval="false">
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="container">
<a class="navbar-brand" href="#">MAD</a>
<button
class="navbar-toggler"
type="button"
data-mdb-toggle="collapse"
data-mdb-target="#navbarNav"
aria-controls="navbarNav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Book a Service</a>
</li>
<li class=[![enter image description here](https://i.stack.imgur.com/MKM0z.png)](https://i.stack.imgur.com/MKM0z.png)"nav-item">
<a class="nav-link" href="#"
>Shop</a
>
</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
</section>
or if you don't need to container you can either remove it or change the container class to container-fluid depending on your situation.
I'm trying to create this navbar design, but I also want to maintain the responsiveness, hamburger menu but only for the upper part (home, contact us, etc links)
.red {
background-color: red;
width: 100px;
height: 100px;
}
.blue {
background-color: blue;
width: 100px;
height: 100px;
}
.yellow {
background-color: yellow;
width: 100px;
height: 100px;
}
.orange {
background-color: orange;
width: 50px;
height: 50px;
border: 2px solid black;
}
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-lg bg-black">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<div class="red">a</div>
</a>
<button class="navbar-toggler ms-auto" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-menu">
<div class="yellow"></div>
</span>
</button>
<div class="container">
<div class="row">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active text-white active-page fs-2" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-white fs-2" href="#">Rooms</a>
</li>
<li class="nav-item">
<a class="nav-link text-white fs-2" href="#">Team</a>
</li>
<li class="nav-item">
<a class="nav-link text-white fs-2" href="#">Info</a>
</li>
<li class="nav-item">
<a class="nav-link text-white fs-2" href="#">Contact us</a>
</li>
</ul>
</div>
</div>
<div class="d-none d-lg-block bg-white p-3">
<!-- Have to make like this, if i put everything in a single div it brakes -->
<div class="row justify-content-md-center">
<div class="col-3 d-flex align-items-center">
<span class="font-SansSerifBldFLFCond text-blue">CALL US NOW</span>
<div class="orange">s</div>
</div>
<div class="col-3 d-flex align-items-center">
<p class="text-blue">From</p>
<div id="today-date ">
<h4 class="fs-6 text-blue">SUNDAY</h4>
<p class="fs-3">15 May</p>
</div>
<div class="orange">s</div>
</div>
<div class="col-3 d-flex align-items-center">
<p class="text-blue">To</p>
<div id="tomorrow-date">
<h4 class="fs-6 text-blue">MONDAY</h4>
<p class="fs-3">16 May</p>
</div>
<div class="orange">s</div>
</div>
<div class="col-3 d-flex align-items-center">
<p class="text-blue font-SansSerifBldFLFCond">INFO</p>
</div>
</div>
</div>
</div>
</div>
</nav>
First main problem is I want to center the links (home, about info)
Second, I want to remove all the padding and margin so the icon (red div) have the same height of the Navbar.
And final thing The height of the 2 columns (links and calendar, phone ecc) should be 50% of the logo each, so combined they have the same height of the logo
I am trying to add a Login button to my navbar in bootstrap, but when I add col-x to separate them equally, but they just cover 50% of the width of the navbar and nothing more. But when I use col-x outside then navbar it works perfectly.
The code
<!-- Navigation -->
<nav class="navbar navbar-dark navbar-expand-md bg-blue sticky-top">
<div class="container-fluid">
<div class="row">
<div class="col-4">
<a class="navbar-brand" href="#">
<h1 class="display-3">Petitions</h1>
</a>
</div>
<div class="col-4">
<button type="button" class="btn btn-primary btn-lg">
Get Started
</button>
</div>
<div class="col-4">
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarResponsive"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Начало</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Цел на компанията</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">За компанията</a>
</li>
</ul>
</div></div>
</div>
</div>
</nav>
<!-- Navigation -->
I Think you want to make something like this:
<nav class="navbar navbar-dark navbar-expand-md sticky-top" style="background-color: #000000;">
<div class="container-fluid">
<div class="row" style="width: 100%; margin-left: 0px; margin-right: 0px;">
<div class="col-4">
<a class="navbar-brand" href="#">
<h1 class="display-3">Petitions</h1>
</a>
</div>
<div class="col-4">
<button type="button" class="btn btn-primary btn-lg">
Get Started
</button>
</div>
<div class="col-4">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Начало</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Цел на компанията</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">За компанията</a>
</li>
</ul>
</div></div>
</div>
</div>
</nav>
.navbar.navbar-expand-lg.navbar-light.bg-light{
width:1920px;
background-color:#eee;
height:50px;
}
footer{
background-color:grey;
}
#media screen and (min-width:320px){
.navbar.navbar-expand-lg.navbar-light.bg-light{
width:100%;
}
}
#media screen and (min-width:985px){
#tog{
height:50px;
}
}
<div class="container-fluid">
<div class="row">
<nav class="navbar navbar-expand-lg navbar-light bg-light" id="tog" role="navigation">
<div class="navbar-header">
<a id="x" class="navbar-brand" href="http://disputebills.com">
<img style="padding-bottom:75px; " id="image;" src="assets/logo.png" alt=" x">MANAGEMENT SYSTEM
</a>
</div>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon" id="but"></span>
</button>
<div class="collapse navbar-collapse justify-content-between" id="collapsibleNavbar">
<div class="col-2"></div>
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" routerLink="/table">Details
</a>
</li>
<li class="nav-item active">
<a class="nav-link" routerLink="/assigned-employees">Employees</a>
</li>
<li class="nav-item active ">
<a class="nav-link" routerLink="/bug-reporting">Report</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="container-fluid">
<div class="row">
<footer id="footer" role="contentinfo">
<div class="container-fluid">
<div class="row footer-list-row">
<div class="col-sm-6">
<div class="row">
<div class="col-xs-6" id="com">
<h3>Company</h3>
<ul>
<li>
<a href=''>About</a>
</li>
<li>
<a href=''>News</a>
</li>
<li>
<a href=''>Careers</a>
</li>
</ul>
</div>
<div class="col-xs-6" id="sol">
<h3>Solutions</h3>
<ul>
<li>
<a href=''>Applications</a>
</li>
<li>
<a href=''>Planning</a>
</li>
<li>
<a href=''>Service</a>
</li>
<li>
<a href=''>Management</a>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="row">
<div class="col-xs-6" id="part">
<h3>Part</h3>
<ul>
<li>
<a href=''>Partner</a>
</li>
<li>
<a href=''>Partner</a>
</li>
<li>
<a href=''>Login</a>
</li>
</ul>
</div>
<div class="col-xs-6" id="contact">
<h3>Contact Us</h3>
<ul>
<li>
<a href=''>Contact Us</a>
</li>
<li>
<a href=''>Addresses</a>
</li>
<li>
<a href=''>Feedback</a>
</li>
<li>
<a href=''>Login</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</footer>
</div>
</div>
I have implemented bootstrap 4 navigation bar inside my web application.Since it is little bit of tall than I expected I needed to customize its height in to 50px. Soon after I did the customization, mobile view stated to show a malicious behavior. when I try to expand the menu by clicking the "List Icon" it expands the list underneath of other DIV s like follow (Like when it has z index -1)
List View
This is the html code I used for navigation bar
<nav class="navbar navbar-expand-lg navbar-light bg-light" id="tog" role="navigation" style="width:1920px; height:50px;">
<div class="navbar-header">
<a id="x" class="navbar-brand" href="http://disputebills.com">
<img style="padding-bottom:75px; " id="image;" src="assets/logo.png" alt="Dispute Bills">ATTENDENCE MANAGEMENT SYSTEM
</a>
</div>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon" id="but"></span>
</button>
<div class="collapse navbar-collapse justify-content-between" id="collapsibleNavbar">
<div class="col-2"></div>
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" routerLink="/table">My Details
</a>
</li>
<li class="nav-item active">
<a class="nav-link" routerLink="/assigned-employees">Assigned Employees List</a>
</li>
<li class="nav-item active ">
<a class="nav-link" routerLink="/bug-reporting">Report Bugs</a>
</li>
</ul>
</div>
</nav>
I have tried by changing the z-index. But it didn't work for me. any clue on this please