This is my navbar... When I hover over a link it should turn to normal text but it is showing me diagonal text....
.navbar-menu2 li a:hover{
color: black;
width: 100%;
height: auto;
background-color: red;
transform: skewX(-30deg);
transform-origin: top;
/* Zentriert den Inhalt */
display: flex;
justify-content: center;
align-items: center;
text-transform: uppercase;
font-family: 'Lato', sans-serif;
}
.navbar-menu2 li a span:hover{
transform: skewX(30deg);
}
<nav class="navbar navbar-expand-md bg-dark p-0">
<div class="container">
<button class="navbar-toggler" data-toggle="collapse" data-target="#navbarNav1">
<span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarNav1">
<ul class="navbar-nav navbar-menu2 text-white">
<li class="nav-item">
<span>Home</span>
</li>
<li class="nav-item">
<span>Classes</span>
</li>
<li class="nav-item">
<span>Trainers</span>
</li>
<li class="nav-item">
<span>Pricing</span>
</li>
<li class="nav-item">
<span>Gallery</span>
</li>
<li class="nav-item">
<span>Blog</span>
</li>
<li class="nav-item">
<span>Contact</span>
</li>
</ul>
</div>
</div>
</nav>
It works fine when we hover over the text. i.e my span tag.. I want the same in li tag: get normal text when we hover over it.
Thanks in advance !
You need to put the reversed transform (transform: skewX(30deg);) on
.navbar-menu2 li a:hover span
instead of
.navbar-menu2 li a span:hover
because the span doesn't always get hovered when the related a is hovered:
.navbar-menu2 li a:hover{
color: black;
width: 100%;
height: auto;
background-color: red;
transform: skewX(-30deg);
transform-origin: top;
/* Zentriert den Inhalt */
display: flex;
justify-content: center;
align-items: center;
text-transform: uppercase;
font-family: 'Lato', sans-serif;
}
.navbar-menu2 li a:hover span{
transform: skewX(30deg);
}
<nav class="navbar navbar-expand-md bg-dark p-0">
<div class="container">
<button class="navbar-toggler" data-toggle="collapse" data-target="#navbarNav1">
<span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarNav1">
<ul class="navbar-nav navbar-menu2 text-white">
<li class="nav-item">
<span>Home</span>
</li>
<li class="nav-item">
<span>Classes</span>
</li>
<li class="nav-item">
<span>Trainers</span>
</li>
<li class="nav-item">
<span>Pricing</span>
</li>
<li class="nav-item">
<span>Gallery</span>
</li>
<li class="nav-item">
<span>Blog</span>
</li>
<li class="nav-item">
<span>Contact</span>
</li>
</ul>
</div>
</div>
</nav>
Try this:-
Remove:- transform: skewX(-30deg); from your CSS.
.navbar-menu2 li a:hover{
color: black;
width: 100%;
height: auto;
background-color: #f0f0f0;
transform-origin: top;
/* Zentriert den Inhalt */
display: flex;
justify-content: center;
align-items: center;
text-transform: uppercase;
font-family: 'Lato', sans-serif;
}
.navbar-menu2 li a span:hover{
transform: skewX(30deg);
}
<nav class="navbar navbar-expand-md bg-dark p-0">
<div class="container">
<button class="navbar-toggler" data-toggle="collapse" data-target="#navbarNav1">
<span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarNav1">
<ul class="navbar-nav navbar-menu2 text-white">
<li class="nav-item">
<span>Home</span>
</li>
<li class="nav-item">
<span>Classes</span>
</li>
<li class="nav-item">
<span>Trainers</span>
</li>
<li class="nav-item">
<span>Pricing</span>
</li>
<li class="nav-item">
<span>Gallery</span>
</li>
<li class="nav-item">
<span>Blog</span>
</li>
<li class="nav-item">
<span>Contact</span>
</li>
</ul>
</div>
</div>
</nav>
Related
I am recreating Apple page from Youtobe video to learn more css and html. I encountered a problem with a styling of navigation.
My problem is that the nav section is too wide. As you can see on a first photo icons are a lot closer and in the middle. Not wide on a lenght of side as in photo 2(my code).
This is how it sholud look like:
And How it looks:
I have the same code as a in video.
Link(Styling nav about 17:30):
https://www.youtube.com/watch?v=DEpF1nNz1l0&t=183s
This is mine:
*,
*::before,
*::after{
margin: 0;
padding: 0;
}
html{
font-size: 10px;
font-family: "SF Pro Text","Myriad Set Pro","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif
}
a{
display: block;
text-decoration: none;
}
.container{
max-width: 98rem;
margin: 0 auto;
padding: 0 2.2rem;
}
header{
position: fixed;
top: 0;
z-index: 1400;
width: 100%;
height: 4.4rem;
background-color: rgba(0,0,0,.8);
backdrop-filter: blur(2rem);
}
.nav-list{
list-style: none;
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 -1rem;
}
<header>
<div class="cointainer">
<nav class="nav">
<ul class="nav-list nav-list-mobile">
<li class="nav-item">
<div class="mobile-menu">
<span class="line line-top"></span>
<span class="line line-botton"></span>
</div>
</li>
<li class="nav-item">
</li>
<li class="nav-item">
</li>
</ul>
<!-- /.nav-list nav-list-mobile -->
<ul class="nav-list nav-list-larger">
<li class="nav-item nav-item-hidden">
</li>
<li class="nav-item">
Mac
</li>
<li class="nav-item">
iPad
</li>
<li class="nav-item">
iPhone
</li>
<li class="nav-item">
Watch
</li>
<li class="nav-item">
TV
</li>
<li class="nav-item">
Music
</li>
<li class="nav-item">
Sport
</li>
<li class="nav-item">
Support
</li>
<li class="nav-item">
</li>
<li class="nav-item nav-item-hidden">
</li>
</ul>
<!-- /.nav-list nav-list-larger -->
</nav>
</div>
</header>
I added a width of 80% to .nav and centered it in the .container class.
try adding the icons (I couldn't find them)
*,
*::before,
*::after{
margin: 0;
padding: 0;
}
html{
font-size: 10px;
font-family: "SF Pro Text","Myriad Set Pro","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif
}
a{
display: block;
text-decoration: none;
font-weight: bold;
color: white;
}
.cointainer {
max-width: 98rem;
padding: 0 2.2rem;
height: 100%;
display: flex;
align-items:center;
justify-content: center;
}
.nav {
width: 80%
}
header{
position: fixed;
top: 0;
z-index: 1400;
width: 100%;
height: 4.4rem;
background-color: rgba(0,0,0,.8);
backdrop-filter: blur(2rem);
}
.nav-list{
list-style: none;
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 -1rem;
}
<header>
<div class="cointainer">
<nav class="nav">
<ul class="nav-list nav-list-mobile">
<li class="nav-item">
<div class="mobile-menu">
<span class="line line-top"></span>
<span class="line line-botton"></span>
</div>
</li>
<li class="nav-item">
</li>
<li class="nav-item">
</li>
</ul>
<!-- /.nav-list nav-list-mobile -->
<ul class="nav-list nav-list-larger">
<li class="nav-item nav-item-hidden">
</li>
<li class="nav-item">
Mac
</li>
<li class="nav-item">
iPad
</li>
<li class="nav-item">
iPhone
</li>
<li class="nav-item">
Watch
</li>
<li class="nav-item">
TV
</li>
<li class="nav-item">
Music
</li>
<li class="nav-item">
Sport
</li>
<li class="nav-item">
Support
</li>
<li class="nav-item">
</li>
<li class="nav-item nav-item-hidden">
</li>
</ul>
<!-- /.nav-list nav-list-larger -->
</nav>
</div>
</header>
first question, how to swap two divs, i want the image on the left and the text next to it
https://codepen.io/madaffakiren/pen/PomedWx
2nd question, I want to lower the "dropdown" but when I do it with margin-top then the "dropdown" disappears on hover, how to assign this blind spot (https://i.imgur.com/8mpN8BL.png) to dropdown?
HTML:
<!-- ======== Navbar ======= -->
<nav class="navbar sticky-top navbar-expand-lg navbar-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="/"><img src="img/logo4.svg" width="120px" height="32px" alt="logo"></a>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link " href="/" data-target=".navbar-collapse.show">XXX</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown"
data-target=".navbar-collapse.show">Sample</a>
<ul class="dropdown-menu">
<a class="dropdown-item" href="#">Sample</a>
<a class="dropdown-item" href="#">Sample</a>
</ul>
</li>
</li>
<li class="nav-item">
<a class="nav-link " href="#" data-target=".navbar-collapse.show">XXX</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" data-target=".navbar-collapse.show">XXX</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" data-target=".navbar-collapse.show">XXX</a>
</li>
</ul>
</div>
</div>
</nav>
CSS:
.navbar {
padding: 10px 0;
background-color: #37517e;
}
.navbar .nav-item {
margin: 0;
padding: 0;
}
.navbar .nav-item .nav-link {
font-size: 15px;
font-weight: 500;
color: #ffffff;
padding: 0;
margin-left: 35px;
transition: all 0.3s ease-in-out;
}
.navbar .nav-item .nav-link:hover {
transform: translateY(-3px);
color: #03b0d5;
}
.navbar .nav-item .dropdown-menu {
border: none;
margin: 20px 0;
background-color: blue;
}
.navbar .nav-item:hover .dropdown-menu {
display: block;
}
I am trying to get the Navbar links inside my navbar and they are showing up under it. I am not sure what happened but I am using a flexbox because it is a requirement for the project I am working on but it moved my nav links and I am not sure why
.mynav {
border: 5px solid black;
position: absolute;
margin-top: 550px;
background-color: #fbc616;
width: 100%;
height: 40px;
}
.navbar ul {
display: flex;
list-style: none;
font-size: 150%;
font-family: RockSalt-Regular;
}
.navbar li {
flex: 3;
}
<div class="mynav">
<nav class="navbar navbar-expand navbar-dark bg-primary">
<div class="navbar-collapse collapse">
<ul class="navbar-nav pt-1">
<li class="nav-item active">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#work">Work</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
The magic of flex is that it scales to the size it needs, so usually hardcoding height and width are counter purpose to the usage of flex. removing the hardcoded height fixed the issue for me
.mynav {
border: 5px solid black;
position: absolute;
margin-top: 550px;
background-color: #fbc616;
width: 100%;
}
.navbar ul {
display: flex;
list-style: none;
font-size: 150%;
font-family: RockSalt-Regular;
}
.navbar li {
flex: 3;
}
<div class="mynav">
<nav class="navbar navbar-expand navbar-dark bg-primary">
<div class="navbar-collapse collapse">
<ul class="navbar-nav pt-1">
<li class="nav-item active">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#work">Work</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
Your navbar ist simply cut off. I removed the height and now its showing correctly.
.mynav {
border: 5px solid black;
position: absolute;
margin-top: 550px;
background-color: #fbc616;
width: 100%;
}
.navbar ul {
display: flex;
list-style: none;
font-size: 150%;
font-family: RockSalt-Regular;
}
.navbar li {
flex: 3;
}
<div class="mynav">
<nav class="navbar navbar-expand navbar-dark bg-primary">
<div class="navbar-collapse collapse">
<ul class="navbar-nav pt-1">
<li class="nav-item active">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#work">Work</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
I have been trying to make my navbar transparent but so far nothing has worked for me. Can someone teach me how to do it? I assume it has something to do with the space that it is taking up in regards to the body content, but I am not sure what can be done as I have already tried reversing the div tags to be outside of the body.
This is my desired result :
Fiddle : https://jsfiddle.net/zr1qh780/
My HTML :
<body>
<div id="container">
<!-- Navigation menu -->
<header>
<nav class="my-nav navbar navbar-light navbar-expand-lg">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-
target="#navbarsExample08" aria-controls="navbarsExample08" aria-expanded="false" aria-
label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-md-center" id="navbarsExample08">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="index.html" id="dropdown08" data-toggle="dropdown" aria-
haspopup="true" aria-expanded="false">ACTIVITÉS</a>
<div class="dropdown-menu" aria-labelledby="dropdown08">
<a class="dropdown-item" href="rafting.html">Rafting</a>
<a class="dropdown-item" href="canyoning.html">Canyoning</a>
<a class="dropdown-item" href="saut-parachute.html">Saut en parachute</a>
<a class="dropdown-item" href="soufflerie.html">Simulation de chute libre</a>
<a class="dropdown-item" href="saut-elastique.html">Saut à l’élastique</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">OFFRES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ÉVÉNEMENTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">À PROPOS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ESPACE HANDICAP</a>
</li>
<li class="nav-item">
<a class="nav-link contact" href="contact.html">CONTACT</a>
</li>
</ul>
</div>
<div class="hamburger">
<span style="font-size:30px;cursor:pointer;color: white;" onclick="openNav()">☰</span>
</div>
</nav>
</header>
<div id="myNav" class="overlay">
×
<div class="bar overlay-content">
ACTIVITÉS
OFFRES
ÉVÉNEMENTS
À PROPOS
ESPACE HANDICAP
CONTACT
</div>
</div>
My CSS:
.logo {
margin-right:5px;
}
.my-nav{
display: flex;
align-items: center;
justify-content: space-around;
padding: 8px;
}
.navbar-light .navbar-nav .nav-link {
color: white;
}
.navbar-nav > li {
padding-left:25px;
padding-right:45px;
float:none;
display:table-cell;
text-align:center;
font-size: 15px;
font-weight: 500;
}
.navbar-light .navbar-nav .nav-link:focus, .navbar-light .navbar-nav .nav-link:hover {
color: #fc3218;
}
.nav-link:active {
color: #fc3218;
}
.navbar {
background: grey
}
.dropdown-menu {
color: white;
background-color: #fc3218;
}
.dropdown-item {
color: white;
font-size: 14px;
}
.navbar-collapse {
flex-grow: 0.3;
}
Have you tried something like this?
navbar{
background-color: transparent;
}
If that doesn't work, add !important to break the predefined bootstrap styles
Set the opacity of the container for nav bar to 0.
Note: Place the elements of nav bar in different div otherwise the text in nav bar will also get effected.
I'm creating a header that will be composed by different redirection links, and some of the cases will be some dropdown elements composed by several links that will be shown when clicking on the main link.
here si my html
<div id="row">
<div class="col-xs-12">
<header>
<nav class="navbar navbar-expand-lg navbar-light header">
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav menu">
<li class="nav-item">
<a class="nav-link">PERSONAL INFO</a>
</li>
<li class="nav-item">
<a class="nav-link menu-link-toggle" v-on:click="displayAnimalList = !displayAnimalList">PERSONAL FORM</a>
<ul class='dropdown-menu' v-show="!displayAnimalList">
<li class='dropdown-menu-item'>
<a class='dropdown-menu-link'>DATA</a>
</li>
<li class='dropdown-menu-item'>
<a class='dropdown-menu-link'>FORM DATA</a>
</li>
<li class='dropdown-menu-item'>
<a class='dropdown-menu-link' >AUTOCOMPLETE</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class='menu-link menu-link-toggle' v-on:click="displayServiceList = !displayServiceList">SERVICES</a>
<ul class='dropdown-menu' v-show="!displayServiceList">
<li class='dropdown-menu-item'>
<a class='dropdown-menu-link' >LA CRÉMATION PRIVÉE</a>
</li>
<li class='dropdown-menu-item'>
<a class='dropdown-menu-link' href="https://www.esthima.fr/incineration-reference">PERSONAL S</a>
</li>
<li class='dropdown-menu-item'>
<a class='dropdown-menu-link'>COMPANY S</a>
</li>
<li class='dropdown-menu-item'>
<a class='dropdown-menu-link' >FULL S INFO</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link ">SHOP</a>
</li>
<li class="nav-item active">
<router-link class="nav-link" to="/devis">TARIFS ET DEVIS </router-link>
</li>
<li class="nav-item">
<a class='menu-link menu-link-toggle' v-on:click="displayContactList = !displayContactList">CONTACT</a>
<ul class='dropdown-menu' v-show="!displayContactList">
<li class='dropdown-menu-item'>
<a class='dropdown-menu-link'>MAIL</a>
</li>
<li class='dropdown-menu-item'>
<a class='dropdown-menu-link' >PHONE</a>
</li>
</ul>
</li>
</ul>
</div>
</nav>
</header>
</div>
</div>
and here mi css
.header {
display: flex;
justify-content: center;
align-items: baseline;
}
.menu {
list-style: none;
display: flex;
}
.nav-item {
padding: 25px;
}
.menu-link-toggle {
cursor: pointer;
}
.dropdown-menu {
list-style: none;
}
a {
font-size: 14px;
color: #D53865;
font-weight: bold;
letter-spacing: 1px;
text-decoration: none;
}
.added {
display: none;
}
I have it laid out as it should be, but the problem arises when I click on the drop-down menus, which pushes the rest of the elements of the header and unlays them. I have tried to introduce an absolute position to the elements that make up the header but it does not respect the original layout as shown in the following link
https://codepen.io/carlosurra/pen/YzqXjdP
Greetings and thanks in advance for your time and help
You should be able to fix that by adding position: relative; to the class .nav-items and position: absolute; to the class .dropdown-menu
here is the updated css
.header {
display: flex;
justify-content: center;
align-items: baseline;
}
.menu {
list-style: none;
display: flex;
}
.nav-item {
padding: 25px;
position: relative;
}
.menu-link-toggle {
cursor: pointer;
}
.dropdown-menu {
list-style: none;
position: absolute;
}
a {
font-size: 14px;
color: #D53865;
font-weight: bold;
letter-spacing: 1px;
text-decoration: none;
}
.added {
display: none;
}