I am using Bootstrap (5) and have simple footer like this:
What I need is simple divider on top of it (above), adding 100px.
Check the fiddle here: https://jsfiddle.net/Ls1vhncx/5
How can I get the same result using ::before pseudo element, so I can avoid extra div with no content?
footer {
background: #555;
}
.img-border {
height: 100px;
width: 1920px;
background-image: url('https://cdn.shopify.com/s/files/1/0213/6954/files/pattern-1920x100px.png?v=1602752799');
background-color: #555;
background-position: center;
background-attachment: fixed;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="img-border"></div>
<footer>
<div class="container">
<div class="row">
<div class="col">
<h4>Cat 1</h4>
<ul class="nav flex-column">
<li><a class="nav-link" href="#">A</a></li>
<li><a class="nav-link" href="#">B</a></li>
<li><a class="nav-link" href="#">C</a></li>
</ul>
</div>
<div class="col">
<h4>Cat 2</h4>
<ul class="nav flex-column">
<li><a class="nav-link" href="#">D</a></li>
<li><a class="nav-link" href="#">E</a></li>
<li><a class="nav-link" href="#">F</a></li>
</ul>
</div>
</div>
</div>
</footer>
You can make space for the border by setting a top margin on the footer.
Then you can put a before pseudo element on it which has bottom 100% (ie sits on top of the footer) and it can have a width of 100% (I don't think you need to set a specific px value as you have done) and height of 100px.
footer {
background: #555;
position: relative;
margin-top: 100px;
}
footer::before {
content: '';
position: absolute;
width: 100%;
height: 100px;
bottom: 100%;
left: 0;
display: inline-block;
background-image: url('https://cdn.shopify.com/s/files/1/0213/6954/files/pattern-1920x100px.png?v=1602752799');
background-color: #555;
background-position: center;
background-attachment: fixed;
}
<footer>
<div class="container">
<div class="row">
<div class="col">
<h4>Cat 1</h4>
<ul class="nav flex-column">
<li><a class="nav-link" href="#">A</a></li>
<li><a class="nav-link" href="#">B</a></li>
<li><a class="nav-link" href="#">C</a></li>
</ul>
</div>
<div class="col">
<h4>Cat 2</h4>
<ul class="nav flex-column">
<li><a class="nav-link" href="#">D</a></li>
<li><a class="nav-link" href="#">E</a></li>
<li><a class="nav-link" href="#">F</a></li>
</ul>
</div>
</div>
</div>
</footer>
Note: I am unclear about the use of background-attachment: fixed - which doesn't seem to be completely implemented on every browser. Do you need it?
What you need is to target the footer.img-border::before and assign this class to your footer element in the DOM.
Actually, you don't need to set the background-image on the footer.img-border but you have to do it directly on the footer.img-border::before pseudo element.
Check my reproducible example to see the result.
I am pretty sure this is what you need for generating this pseudo element with CSS.
footer {
background: #555;
}
footer.img-border:: {
height: 100px;
width: 1920px;
background-color: #555;
background-position: center;
background-attachment: fixed;
}
footer.img-border::before {
content: "";
display: block;
width: 100%;
background-image: url('https://cdn.shopify.com/s/files/1/0213/6954/files/pattern-1920x100px.png?v=1602752799');
height: 100px;
}
<footer class="img-border">
<div class="container">
<div class="row">
<div class="col">
<h4>Cat 1</h4>
<ul class="nav flex-column">
<li><a class="nav-link" href="#">A</a></li>
<li><a class="nav-link" href="#">B</a></li>
<li><a class="nav-link" href="#">C</a></li>
</ul>
</div>
<div class="col">
<h4>Cat 2</h4>
<ul class="nav flex-column">
<li><a class="nav-link" href="#">D</a></li>
<li><a class="nav-link" href="#">E</a></li>
<li><a class="nav-link" href="#">F</a></li>
</ul>
</div>
</div>
</div>
</footer>
Related
I'm trying to align sub-menus below all parent menus and align with the left parent menu.
Please NOTE I don't want to align the submenus below the parent, I want to align the sub menus below the paint menu
I'm currently unable to achieve what I require even with position absolute and transform
My code (css/html) is below:
<!doctype html>
<html lang="en">
<head>
<title>Title</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
#media (min-width: 768px) {
.nav li {
display: block;
transition-duration: 0.5s;
}
}
#media (min-width: 768px) {
li:hover {
background: #ffffff;
cursor: pointer;
}
}
#media (min-width: 768px) {
ul.nav li ul.multi-column {
visibility: hidden;
opacity: 0;
position: absolute;
transition: all 0.5s ease;
margin-top: 1.1rem;
left: 0;
display: none;
}
}
#media (min-width: 768px) {
ul.nav li:hover > ul.multi-column, ul li ul:hover {
visibility: visible;
opacity: 1;
display: block;
}
}
#media (min-width: 768px) {
ul.nav li ul.multi-column li {
clear: both;
width: 100%;
}
}
#media (min-width: 768px) {
.multi-column {
border: 1px solid black;
border-top: 0;
background-color: #ffffff!important;
margin-top: 0!important;
width: 500px;
}
}
#media (min-width: 768px) {
.multi-column-dropdown {
/*margin: 0;*/
padding: 0 0 0 5px;
}
}
.dropdown-menu-centre {
right: auto!important;
left: auto!important;
/*-webkit-transform: translate(0, 0);*/
/*transform: translate(0, 0);*/
background-color: green!important;
}
.dropdown-menu-last {
right: auto;
left: -85%;
-webkit-transform: translate(-85%, 0);
transform: translate(-85%, 0);
}
</style>
</head>
<body>
<nav class="navbar navbar-light navbar-expand-md navigation-clean">
<div class="container">
<button data-toggle="collapse" class="navbar-toggler" data-target="#navcol-1"><span class="sr-only">Toggle navigation</span><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navcol-1">
<ul class="nav navbar-nav mx-auto">
<li class="nav-item dropdown" role="presentation">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-expand="false">Paints</a>
<ul class="dropdown-menu multi-column dropdown-menu-centre">
<div class="row" role="menu">
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li>
Bristle Paint Brushes
</li>
<li>
Paints Link two
</li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li>
Anti Condensation Paint
</li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li>
Paints Link one
</li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown" role="presentation">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-expand="false">Woodcare</a>
<ul class="dropdown-menu multi-column dropdown-menu-centre">
<div class="row" role="menu">
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
Wood Link one
</li>
<li>
Wood Link two
</li>
</ul>
</div>
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
Wood Link one
</li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown" role="presentation">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-expand="false">Brushes & Rollers</a>
<ul class="dropdown-menu multi-column dropdown-menu-centre">
<div class="row" role="menu">
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
Brushes Link one
</li>
<li>
Brushes Link two
</li>
</ul>
</div>
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
Brushes Link one
</li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown" role="presentation">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-expand="false">PPE</a>
<ul class="dropdown-menu multi-column dropdown-menu-last">
<div class="row" role="menu">
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
PPE Link one
</li>
<li>
PPE Link two
</li>
</ul>
</div>
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
PPE Link one
</li>
</ul>
</div>
</div>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
The issue I am having can be seen in the image attached, all sub menus should align with the paint parent menu
Any help would be appreciated
Working Gif since you said its not working..:
Here you go: https://jsfiddle.net/h4ynogLe/
<!doctype html>
<html lang="en">
<head>
<title>Title</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
#media (min-width: 768px) {
.nav li {
display: block;
transition-duration: 0.5s;
}
}
#media (min-width: 768px) {
li:hover {
background: #ffffff;
cursor: pointer;
}
}
#media (min-width: 768px) {
ul.nav li ul.multi-column {
visibility: hidden;
opacity: 0;
position: absolute;
transition: all 0.5s ease;
margin-top: 1.1rem;
left: 0;
display: none;
}
}
#media (min-width: 768px) {
ul.nav li:hover > ul.multi-column, ul li ul:hover {
visibility: visible;
opacity: 1;
display: block;
}
}
#media (min-width: 768px) {
ul.nav li ul.multi-column li {
clear: both;
width: 100%;
}
}
#media (min-width: 768px) {
.multi-column {
border: 1px solid black;
border-top: 0;
background-color: #ffffff!important;
margin-top: 0!important;
width: 500px;
}
}
#media (min-width: 768px) {
.multi-column-dropdown {
/*margin: 0;*/
padding: 0 0 0 5px;
}
}
.dropdown-menu-centre {
right: auto!important;
left: auto!important;
/*-webkit-transform: translate(0, 0);*/
/*transform: translate(0, 0);*/
background-color: green!important;
}
.dropdown-menu-last {
right: auto;
left: -85%;
-webkit-transform: translate(-85%, 0);
transform: translate(-85%, 0);
}
</style>
</head>
<body>
<nav class="navbar navbar-light navbar-expand-md navigation-clean">
<div class="container">
<button data-toggle="collapse" class="navbar-toggler" data-target="#navcol-1"><span class="sr-only">Toggle navigation</span><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navcol-1">
<ul class="nav navbar-nav mx-auto">
<li class="nav-item dropdown" role="presentation">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-expand="false">Paints</a>
<ul class="dropdown-menu multi-column dropdown-menu-centre ml-4">
<div class="row" role="menu">
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li>
Bristle Paint Brushes
</li>
<li>
Paints Link two
</li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li>
Anti Condensation Paint
</li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li>
Paints Link one
</li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown" role="presentation">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-expand="false">Woodcare</a>
<ul class="dropdown-menu multi-column dropdown-menu-centre ml-n5 pl-5">
<div class="row" role="menu">
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
Wood Link one
</li>
<li>
Wood Link two
</li>
</ul>
</div>
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
Wood Link one
</li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown" role="presentation">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-expand="false">Brushes & Rollers</a>
<ul class="dropdown-menu multi-column dropdown-menu-centre ml-n5 pl-5" style="margin-left: -150px !important;">
<div class="row" role="menu">
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
Brushes Link one
</li>
<li>
Brushes Link two
</li>
</ul>
</div>
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
Brushes Link one
</li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown" role="presentation">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-expand="false">PPE</a>
<ul class="dropdown-menu multi-column dropdown-menu-centre ml-n5 pl-5" style="margin-left: -303px !important;">
<div class="row" role="menu">
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
PPE Link one
</li>
<li>
PPE Link two
</li>
</ul>
</div>
<div class="col-sm-6">
<ul class="multi-column-dropdown">
<li>
PPE Link one
</li>
</ul>
</div>
</div>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
Explanation: I just adjusted the margins as they can be negative. I also removed your last transform class.
Thank you for the reply, I tried your code, but for me, it still did not work as the image below shows.
I finally got it to work yesterday via jQuery, the code I used is below.
$(".nav-link").on("mouseover",function(){
var leftAlign = $("#main-div").offset();
var i;
for(i = 1; i < 7; i++)
{
$(".sub-container-" + i).css("position", "fixed");
$(".sub-container-" + i).css("left", + Math.floor(leftAlign.left) +"px" );
$(".sub-container-" + i).css("width", "600px");
}
CSS used to set the top alignment
#media (min-width: 768px) {
.sub-container-top {
position: absolute;
top: 362px;
}
}
#media (min-width: 992px) {
.sub-container-top {
position: absolute;
top: 262px;
}
}
The code I used produced the desired effect
I've tried using the z-index to move the content to the back. I've also tried to use it as a before pseudo element as my header but it still doesn't work. I've tried to use the clip path on the header but nothing seems to work. Any feedback would be greatly appreciated.
header {
background-image: url('background.JPG'),
url('audio.gif.JPG');
header {
background-image: url('background.JPG'),
url('audio.gif.JPG');
height: 100vh;
width: 100%;
background-repeat: no-repeat;
background-size: cover;
background-position: top, left ;
top: 0;
left: 0;
position: relative;
overflow: hidden;
}
header:after{
content:'';
position: relative;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: white;
clip-path: polygon(100% 1%, 0% 100%, 100% 100%);
z-index: -5;
}
<nav class="navbar">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="HomePage.html">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="About.html">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#targetname">Show Submission</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Sponsors.html">Sponsors</a>
</li>
</ul>
</nav>
<div class="menu-wrapper">
<input type="checkbox" class="toggler">
<div class="hamburger">
<span></span>
<span></span>
</div>
<div class="menu">
<div>
<div>
<ul class="aside-links">
<li class="aside-link">Home</li>
<li class="aside-link">About</li>
<li class="aside-link">Show Submission</li>
<li class="aside-link">Sponsors</li>
</ul>
</div>
</div>
</div>
</div>
I am using bootstrap 4 for my navbar, I can toogle down the hamburger button just fine but I can't toogle it back on the menu, it remains to be in a collapsed form. So how can I toogle it back to its menu?
I've tried data="collapse" on each nav-item just maybe it would work but it remained in a collapsed form.
.nav-fill .nav-item {
-webkit-box-flex: initial;
flex: initial;
text-align: initial;
}
ul li a.nav-link {
text-transform: uppercase;
font-weight: bold;
letter-spacing: 0.02em;
}
.navigation .bg-light{
background-color: transparent !important;
}
<nav class="navbar navbar-expand-lg navbar-dark bg-dark ">
<div class="container">
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbar10">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar10">
<ul class="navbar-nav nav-fill w-100">
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">Codeply</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
</div>
</div>
</nav>
fyi: I placed my navbar under my header (because I needed to), could that be the case?
header{
display: flex !important;
flex-direction: column;
}
/*** HEADER *****/
.logo-wrapper img {
width: 100%;
display: block;
}
.logo-wrapper {
width: 100%;
display: block;
position: relative;
}
/* Navbar */
.nav-fill .nav-item {
-webkit-box-flex: initial;
flex: initial;
text-align: initial;
}
header {
background: url(../images/header_img.png) no-repeat top center transparent;
padding: 0 0;
background-attachment: inherit;
background-size: cover;
}
.header-bottom {
padding: 20px 0;
}
ul li a.nav-link {
text-transform: uppercase;
font-weight: bold;
letter-spacing: 0.02em;
}
.navigation .bg-light{
background-color: transparent !important;
}
<header>
<div class="header-bottom">
<div class="container">
<div class="row">
<div class="icon-call col-md-4 col-xs-12 d-none d-md-block ">
<img src = "images/icon-call.png">xoxoxox
</div>
<div class="col-md-4 col-xs-12 col-sm-12">
<div class="logo-wrapper">
<img src = "images/logo.png" >
</div>
</div>
<div class="icon-social col-md-4 col-xs-12 d-none d-md-block">
<div class="social-media text-right">
<img src = "images/icon-fb.png" >
<img src = "images/icon-mail.png">
<img src = "images/icon-insta.png">
</div>
</div>
</div>
</div>
</div>
<div class="navigation">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbar10">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse text-center" id="navbar10">
<ul class="navbar-nav nav-fill w-100">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Results</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">References</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</header>
your code is working fine, but try to use all the links properly like below
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
header{
display: flex !important;
flex-direction: column;
}
/*** HEADER *****/
.logo-wrapper img {
width: 100%;
display: block;
}
.logo-wrapper {
width: 100%;
display: block;
position: relative;
}
/* Navbar */
.nav-fill .nav-item {
-webkit-box-flex: initial;
flex: initial;
text-align: initial;
}
header {
background: url(../images/header_img.png) no-repeat top center transparent;
padding: 0 0;
background-attachment: inherit;
background-size: cover;
}
.header-bottom {
padding: 20px 0;
}
ul li a.nav-link {
text-transform: uppercase;
font-weight: bold;
letter-spacing: 0.02em;
}
.navigation .bg-light{
background-color: transparent !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<header>
<div class="header-bottom">
<div class="container">
<div class="row">
<div class="icon-call col-md-4 col-xs-12 d-none d-md-block ">
<img src = "images/icon-call.png">xoxoxox
</div>
<div class="col-md-4 col-xs-12 col-sm-12">
<div class="logo-wrapper">
<img src = "images/logo.png" >
</div>
</div>
<div class="icon-social col-md-4 col-xs-12 d-none d-md-block">
<div class="social-media text-right">
<img src = "images/icon-fb.png" >
<img src = "images/icon-mail.png">
<img src = "images/icon-insta.png">
</div>
</div>
</div>
</div>
</div>
<div class="navigation">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbar10">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse text-center" id="navbar10">
<ul class="navbar-nav nav-fill w-100">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Results</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">References</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</header>
I want the images in center but unable to do this on medium, large and extra-large screens
<nav class="navbar">
<div class="row">
<div class="col-12 d-flex justify-content-center">
<img src="./images/devices.png" alt="devices">
<img src="./images/media.png" alt="media">
<img src="./images/logo.png" alt="logo">
<img src="./images/stream.png" alt="stream">
<img src="./images/logout.png" alt="logout">
</div>
</div>
</nav>
I have tried different solutions provided on stackoverflow site but none worked. Please help, I am a newbie
I don't really understand what you need, but I guess you can refer to the following 2 pages:
.nav class
.navbar class
Usually navigations are either a bar with multiple links or dropdowns. So I don't see how this can be justified.
Here-under 2 examples one with the .nav class that I've arranged horizontally.
One with the .navbar class I've arranged vertically.
The content of the items is centered.
Hope this helps.
.navbar, .nav {
background-color: #A4A4A4;
border: 1px solid red;
}
/* for the purpose of demonstration, I added borders to the Nav-ul */
#top-menu {
border: 1px solid red;
}
.nav-link {
width: 100px;
text-align: center;
/* for the purpose of demonstration, I added borders to the list items */
border: 1px solid black;
}
.dont_copy_this {height: 50px;}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="nav">
<div class="row">
<div class="col-12 d-flex justify-content-center">
<a class="nav-link" href="/html"><img src="./images/devices.png" alt="devices"></a>
<a class="nav-link" href="/html"><img src="./images/media.png" alt="media"></a>
<a class="nav-link" href="/html"><img src="./images/logo.png" alt="logo"></a>
<a class="nav-link" href="/html"><img src="./images/stream.png" alt="stream"></a>
<a class="nav-link" href="/html"><img src="./images/logout.png" alt="logout"></a>
</div>
</div>
</nav>
<div class="dont_copy_this"></div>
<nav class="navbar">
<ul id="top-menu" class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="/html"><img src="./images/devices.png" alt="devices"></a></li>
<li class="nav-item"><a class="nav-link" href="/html"><img src="./images/media.png" alt="media"></a></li>
<li class="nav-item"><a class="nav-link" href="/html"><img src="./images/logo.png" alt="logo"></a></li>
<li class="nav-item"><a class="nav-link" href="/html"><img src="./images/stream.png" alt="stream"></a></li>
<li class="nav-item"><a class="nav-link" href="/html"><img src="./images/logout.png" alt="logout"></a></li>
</ul>
</nav>
I have tried couple solutions, but nothing that is working as I intended so far. I just want the links to be in the same level of indentation and in a block level manner. I am trying to get this accomplish without using absolute positioning, otherwise it breaks the rest of the code. Any help would be appreciated.
body {
margin-left: 40px; }
.bookmarks {
border: 1px solid gray;
width: 200px; }
.bookmarks ul {
list-style-type: none; }
.link4 {
box-sizing: border-box;
display: inline-block;
background-color: pink; }
.link4 .left-side {
height: 100%;
width: 80%;
color: white;
background-color: blue;
float: left; }
.link4 .right-side {
height: 100%;
width: 20%;
background-color: yellow;
float: right; }
.second-menu li {
background-color: lightgreen; }
.last-menu li {
background-color: lightgray; }
/*# sourceMappingURL=test2.css.map */
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<div class="col-md-6">
<div class="bookmarks">
<ul class="nav top-menu" id="affix-ul">
<li class="link1">
<a href="#">
Some Text on link 1
</a>
</li>
<li class="link2">
<a href="#">
Some Text on link 2
</a>
</li>
<li class="link 3">
<a href="#">
Some Text on link 3
</a>
</li>
<li class="link4 active">
<div class="left-side">
<a href="#">
<span>Some Text on link 4</span>
</a>
</div>
<div class="right-side">
<a href="#" class="arrow-up" aria-hidden="true" data-toggle="collapse" data-target="#hiddenMenuOne">
<i class="fa fa-chevron-down"> ^
</i>
</a>
</div>
<ul id="hiddenMenuOne" class="collapse second-menu">
<li>
Sublink1
</li>
<li>
Sublink2
</li>
<li>
This is a sublink3 with a bit more text
</li>
<li>
sublink4
</li>
<li>
sublink5
</li>
<li>
sublink6
</li>
<li class="second-level-menu wrapper">
<div class="left-side">
<a href="#" class="">
Last sublink on submenu
</a>
</div>
<div class="right-side">
<a href="#" class="second-dropdown" aria-hidden="true" data-toggle="collapse" data-target="#hiddenMenuTwo">
<i class="fa fa-chevron-down">^
</i>
</a>
</div>
<ul id="hiddenMenuTwo" class="collapse last-menu">
<li>
Tertiary 1
</li>
<li>
Tertiary 2
</li>
<li>
Tertiary 3 with a second line
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
Just in case anyone wants to know the answer. I just removed the padding-left of the li and added a height property to the uls