Helow Guys, I just created a menu links design by following some tutorial in YT, however, I encountered some error, while hovering the links it goes to the logo image space, making the image logo can't see it clearly. What I want is while hovering the links it creates a padding or margin so that the image logo will not disturb and stay the logo where he is. Here's my code
.logo {
height: 65px;
width: 65px;
}
.firstNav {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
.firstNav > a {
position: relative;
font-family: 'Montserrat', sans-serif;
font-weight: 600;
font-size: 14px;
text-transform: uppercase;
text-decoration: none;
padding: 0 12px;
transition: 0.5s;
color: #000;
}
nav:hover a {
transform: scale(1.5);
opacity: .6;
filter: blur(4px);
}
nav .firstNav a:hover {
transform: scale(2);
opacity: 1;
filter: blur(0);
}
nav .firstNav a::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #2575aa;
transition: 0.5s;
transform-origin: right;
transform: scaleX(0);
z-index: -1;
}
nav .firstNav a:hover::before{
transition: 0.5s;
transform-origin: left;
transform: scaleX(1);
}
<nav>
<div class="firstNav">
Home
Blog
Portfolio
<img src="https://i.stack.imgur.com/JWQJm.png" alt="logo" class="logo">
Progress
About
Contact
</div>
</nav>
I think given what you are trying to do it will always invade the space of the logo, so an alternative to Smollet777's answer is that you can adjust its behaviour to push out the items so it wont matter what the width of the text content is.
You can split the nav items in two to keep the logo in a fixed placed and use css transitions to expand the other items like so:
.logo {
height: 65px;
width: 65px;
}
.firstNav {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
width: 800px;
}
.blurLink {
position: relative;
font-family: "Montserrat", sans-serif;
font-weight: 600;
font-size: 14px;
text-transform: uppercase;
text-decoration: none;
padding: 0 12px;
transition: font-size 1s, padding 1s;
color: #000;
}
.blurLink:hover {
font-size: 32px;
padding: 0 20px;
background: #2575aa;
}
.navGroup {
width: 40%;
display: flex;
justify-content: flex-end;
align-items: center;
}
.navGroup2 {
width: 40%;
display: flex;
justify-content: flex-start;
align-items: center;
}
<nav>
<div class="firstNav">
<div class="navGroup">
Home
Blog
Portfolio
</div>
<img src="https://i.stack.imgur.com/JWQJm.png" alt="logo" class="logo">
<div class="navGroup2">
Progress
About
Contact
</div>
</div>
</nav>
You can use element:nth-child(index) to target specific element in CSS.
nav .firstNav a:nth-child(3):hover {
position: relative;
left: -55px;
}
nav .firstNav a:nth-child(5):hover {
position: relative;
right: -55px;
}
.logo {
height: 65px;
width: 65px;
}
.firstNav {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
.firstNav>a {
position: relative;
font-family: 'Montserrat', sans-serif;
font-weight: 600;
font-size: 14px;
text-transform: uppercase;
text-decoration: none;
padding: 0 12px;
transition: 0.5s;
color: #000;
}
nav:hover a {
transform: scale(1.5);
opacity: .6;
filter: blur(4px);
}
nav .firstNav a:hover {
transform: scale(2);
opacity: 1;
filter: blur(0);
}
nav .firstNav a::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #2575aa;
transition: 0.5s;
transform-origin: right;
transform: scaleX(0);
z-index: -1;
}
nav .firstNav a:hover::before {
transition: 0.5s;
transform-origin: left;
transform: scaleX(1);
}
<nav>
<div class="firstNav">
Home
Blog
Portfolio
<img src="https://i.stack.imgur.com/JWQJm.png" alt="logo" class="logo">
Progress
About
Contact
</div>
</nav>
Use this and you'll be ok.
.firstNav>a:nth-of-type(3):hover {
transform: translateX(-55px) scale(2);
}
.firstNav>a:nth-of-type(4):hover {
transform: translateX(55px) scale(2);
}
Related
so here is my problem. I have managed to put the image which is the logo at the left hand side of the header for both tablet and mobile version, however when I display it in the desktop version the logo is the left but not in the corner like I want it. I tried putting a right margin to it, but I think there is a better way to do it instead of doing that. the same thing happens with my ul list. it's in the right corner on both tablet and mobile but it is not in the desktop version. this is my code:
<!DOCTYPE html>
<html>
<link href='https://fonts.googleapis.com/css?family=Montserrat|Cardo' rel='stylesheet' type='text/css'>
<link href='style.css' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.main_h {
position: fixed;
top: 0px;
max-height: 70px;
z-index: 999;
width: 100%;
padding-top: 17px;
background: none;
overflow: hidden;
-webkit-transition: all 0.3s;
transition: all 0.3s;
opacity: 0;
top: -100px;
padding-bottom: 6px;
font-family: "Montserrat", sans-serif;
}
#media only screen and (max-width: 766px) {
.main_h {
padding-top: 25px;
}
}
.open-nav {
max-height: 400px !important;
}
.open-nav .mobile-toggle {
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
}
.sticky {
background-color: rgba(255, 255, 255, 0.93);
opacity: 1;
top: 0px;
border-bottom: 1px solid gainsboro;
}
.logo {
width: 150px;
font-size: 25px;
color: #8f8f8f;
text-transform: uppercase;
float: left;
display: block;
margin-top: 0;
line-height: 1;
margin-bottom: 10px;
}
#media only screen and (max-width: 766px) {
.logo {
float: none;
}
}
nav {
float: right;
width: 60%;
}
#media only screen and (max-width: 766px) {
nav {
width: 100%;
}
}
nav ul {
list-style: none;
overflow: hidden;
text-align: center;
float: right;
}
#media only screen and (max-width: 766px) {
nav ul {
padding-top: 10px;
margin-bottom: 22px;
float: left;
text-align: center;
width: 100%;
}
}
nav ul li {
display: inline-block;
margin-left: 35px;
line-height: 1.5;
text-align: center;
}
#media only screen and (max-width: 766px) {
nav ul li {
width: 100%;
padding: 7px 0;
margin: 0;
text-align: center;
}
}
nav ul a {
color: #000;
text-transform: uppercase;
font-size: 12px;
text-align: center;
}
.mobile-toggle {
display: none;
cursor: pointer;
font-size: 20px;
position: absolute;
right: 22px;
top: 0;
width: 30px;
-webkit-transition: all 200ms ease-in;
-moz-transition: all 200ms ease-in;
transition: all 200ms ease-in;
}
#media only screen and (max-width: 766px) {
.mobile-toggle {
display: block;
}
}
.mobile-toggle span {
width: 30px;
height: 4px;
margin-bottom: 6px;
border-radius: 1000px;
background: #8f8f8f;
display: block;
}
.row {
width: 100%;
max-width: 940px;
margin: 0 auto;
position: relative;
padding: 0 2%;
}
* {
box-sizing: border-box;
}
body {
color: #8f8f8f;
background: white;
font-family: "Cardo", serif;
font-weight: 300;
-webkit-font-smoothing: antialiased;
}
a {
text-decoration: none;
}
h1 {
font-size: 30px;
line-height: 1.8;
text-transform: uppercase;
font-family: "Montserrat", sans-serif;
}
p {
margin-bottom: 20px;
font-size: 17px;
line-height: 2;
}
.content {
padding: 50px 2% 250px;
}
.hero {
position: relative;
background: url(http://www.philippefercha.com/cd/toggle-menu-bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
text-align: center;
color: #fff;
padding-top: 110px;
min-height: 500px;
letter-spacing: 2px;
font-family: "Montserrat", sans-serif;
}
.hero h1 {
font-size: 50px;
line-height: 1.3;
}
.hero h1 span {
font-size: 25px;
color: #e8f380;
border-bottom: 2px solid #e8f380;
padding-bottom: 12px;
line-height: 3;
}
.mouse {
display: block;
margin: 0 auto;
width: 26px;
height: 46px;
border-radius: 13px;
border: 2px solid #e8f380;
position: absolute;
bottom: 40px;
position: absolute;
left: 50%;
margin-left: -26px;
}
.mouse span {
display: block;
margin: 6px auto;
width: 2px;
height: 2px;
border-radius: 4px;
background: #e8f380;
border: 1px solid transparent;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-name: scroll;
animation-name: scroll;
}
#-webkit-keyframes scroll {
0% {
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0);
}
100% {
opacity: 0;
-webkit-transform: translateY(20px);
transform: translateY(20px);
}
}
#keyframes scroll {
0% {
opacity: 1;
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
}
100% {
opacity: 0;
-webkit-transform: translateY(20px);
-ms-transform: translateY(20px);
transform: translateY(20px);
}
}
</style>
<body>
<header class="main_h">
<div class="row">
<img src = "logo.png" class="logo" href="#"></a>
<div class="mobile-toggle">
<span></span>
<span></span>
<span></span>
</div>
<nav>
<ul>
<li>Home</li>
<li>Abous Us</li>
<li>Contact Us</li>
</ul>
</nav>
</div> <!-- / row -->
</header>
<script>
// Sticky Header
$(window).scroll(function() {
if ($(window).scrollTop() > 100) {
$('.main_h').addClass('sticky');
} else {
$('.main_h').removeClass('sticky');
}
});
// Mobile Navigation
$('.mobile-toggle').click(function() {
if ($('.main_h').hasClass('open-nav')) {
$('.main_h').removeClass('open-nav');
} else {
$('.main_h').addClass('open-nav');
}
});
$('.main_h li a').click(function() {
if ($('.main_h').hasClass('open-nav')) {
$('.navigation').removeClass('open-nav');
$('.main_h').removeClass('open-nav');
}
});
// navigation scroll lijepo radi materem
$('nav a').click(function(event) {
var id = $(this).attr("href");
var offset = 70;
var target = $(id).offset().top - offset;
$('html, body').animate({
scrollTop: target
}, 500);
event.preventDefault();
});
</script>
</body>
</html>
sorry to tell you that but I don't like your CSS, and opacity 0 on the entire page? float everywhere, I don't get it ^^ first of all try to put CSS in a CSS file and JS in a JS file
I did not understand what the span things were for, I removed them for the structure
now for the code
I can recommend using a structure, would be easier
something like this:
HTML:
body{
padding: 0;
margin: 0;
}
.col1x3{
width: 33%;
}
.col1x2{
width: 50%;
}
.element{
margin-right: -0.25em;
display: inline-block;
}
<div class="row">
<div class="container">
<div class="element col1x2">
<img src = "https://www.magknit.co.uk/staging/1365/wp-content/uploads/2020/10/descarga-1-1.png" class="logo" href="#"></a>
</div>
<div class="element col1x2">
<nav>
<ul>
<li class="element col1x3">Home</li>
<li class="element col1x3">Abous Us</li>
<li class="element col1x3">Contact Us</li>
</ul>
</nav>
</div>
</div>
</div>
I found out it is the max-width in the .row that is causing the problem. i had it set up to 960px so the row would not be longer than that. I just had to set it to whatever screen size I wanted and that is it.
I'm not knowing how to increase the height of vitaminpic, which is under container. I'm still new to development, and I know this seems like an amateur mistake. I tried everything I can but it's not working. I believe it has to do with with the fact that it is under the container. I'm trying to make a website that sells vitamins, still new to it but I'm still trying.
#import url('https://fonts.googleapis.com/css2?family=Syne+Mono&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}
.background {
width: 100%;
height: 100vh;
background-color: #e0d1cb;
position: relative;
overflow: hidden;
z-index: 2;
}
.nav {
position: fixed;
top: 0;
width: 100%;
display: flex;
justify-content: space-around;
align-items: center;
min-height: 8vh;
background-color: #e0d1cb;
font-family: 'Syne Mono', monospace;
z-index: 3;
}
.nav-links {
display: flex;
justify-content: space-around;
width: 30%;
font-family: 'Syne Mono', monospace;
}
.nav-links li {
list-style: none;
font-family: 'Syne Mono', monospac
}
.nav-links a {
color: rgb(0, 0, 0);
text-decoration: none;
letter-spacing: 2px;
font-weight: bold;
font-size: 14px;
font-family: 'Syne Mono', monospac
}
.burger {
display: none;
}
.burger div {
width: 25px;
height: 3px;
background-color: rgb(226, 226, 226);
margin: 5px;
transition: all 0.3s ease;
}
#media screen and (max-width: 1024px) {
.nav-links {
width: 60%;
}
}
#media screen and (max-width: 768px) {
body {
overflow-x: hidden;
}
.nav-links {
position: fixed;
right: 0px;
height: 92vh;
top: 8vh;
background-color: #e0d1cb;
display: flex;
flex-direction: column;
align-items: center;
width: 20%;
transform: translateX(100%);
transition: transform 0.5s ease-in;
}
.nav-links li {
opacity: 0;
}
.burger {
display: block;
cursor: pointer;
}
}
.nav-active {
transform: translateX(0%);
}
#keyframes navLinkFade {
from {
opacity: 0;
transform: translateX(50px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
.toggle .line1 {
transform: rotate(-45deg) translate(-5px, 6px);
}
.toggle .line2 {
opacity: 0;
}
.toggle .line3 {
transform: rotate(45deg) translate(-5px, -6px);
}
#import url('https://fonts.googleapis.com/css2?family=Syne+Mono&display=swap');
.logo {
resize: both;
font-family: 'Syne Mono', monospace;
}
.link::after {
content: '';
display: block;
width: 0;
height: 2px;
background: #000000;
transition: width .3s;
}
.link:hover::after {
width: 100%;
transition: width .3s;
}
.header {
width: 100%;
background-color: rgba(0, 0, 0, 0.5)
}
.header ul {
text-align: center;
}
.header ul li {
list-style: none;
display: inline-block;
}
.header ul li a {
display: block;
text-decoration: none;
text-transform: uppercase;
color: white;
font-size: 100%;
letter-spacing: 2px;
font-weight: 600;
padding: 25px;
transition: width .3s;
}
.content {
color: #fbfcfd;
position: absolute;
top: 50%;
left: 8%;
transform: translateY(-50%);
z-index: 2;
}
.heading1 {
font-size: 300%;
margin-bottom: 10px 0 30px;
background: transparent;
position: relative;
animation: text 5s 1;
left: 120%;
}
#keyframes text {
0% {
color: transparent;
margin-bottom: -40px;
}
30% {
letter-spacing: 4px;
margin-bottom: -40px;
}
85% {
letter-spacing: 3px%;
margin-bottom: -40px;
}
}
.welcome {
font-size: 30px;
position: relative;
}
.container {
position: absolute;
height: 80%;
width: 30%;
background: #dfcac1;
top: 50%;
left: 35%;
transform: translate(-43%, -60%);
}
.container img {
size: ;
}
.vitaminpic {
width: 100%;
transform: translate(10%, 80%);
padding: 0 10;
}
<head>
<link rel="stylesheet" href="home.css">
</head>
<header class="site-header"></header>
<div class="background">
<div class="nav">
<h1 class="logo">Realvite</h1>
<ul class="nav-links">
<li>
<a href="#" class="link1">
<div class="link1">Home</div>
</a>
</li>
<li>Shop</li>
<li>Contact</li>
</ul>
<div class="burger">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
</div>
</nav>
<div class="container">
<img src="/images/capsule-1079838_1920.jpg" alt="" class="vitaminpic">
</div>
<p style="font-size: 1px;">قيل قديقال</p>
<div class="content">
<small class="welcome"></small>
<h1 class="heading1"></h1>
</div>
</div>
<script src="script.js"></script>
If I were you I would use Bootstrap columns, because not only are these easily configurable, but importing bootstrap also allows you to use a wide variety of HTML, CSS and Javascript libraries which are widely supported. Here's the link - https://getbootstrap.com
In the meantime though, I would recommend removing this:
.container img {
size: ;
}
and changing your container width to 50% to see if that works, because currently you've set your container to 30% width, whereas your image is larger than that, so it isn't fitting inside the container. If 50% doesn't work then try a few different values to try and get it to fit, but as mentioned I would recommend Bootstrap, then you can use "col-md-4" and set the background for that, would probably be much more convenient for you in the long run! :)
Here is what I see for my website:
website
As the image is below Navigation Bar, I want this to center vertically in my responsive website, similar to this website: https://www.ownhour.co.kr/#;
I have added width and height as 100% in internal image stylesheet and added margin and block in external CSS. After inspecting with the mobile version, it seems like the image is sitting at the top with a huge gap at the bottom.
Here is what I see for my website:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="monday.css">
<title>J[a]son</title>
</head>
<body>
<nav>
<div class = "logo">
<h4>J[a]son</h4>
</div>
<ul class = "nav-links">
<li>
HOME
</li>
<li>
PHOTOGRAPHY
<ul class="sub-menu">
<li>Colour</li>
<li>Black</li>
</ul>
</li>
<li>
CODING
</li>
<li>
ABOUT
</li>
</ul>
<div class= "burger">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
</nav>
<script src="testing.js"></script>
<img class="main_car" src="Photos/main_car.jpg" alt="car" width="100%" height="100%"/>
<!--<p>June, 2020. Sunshine Coast, BC, Canada </p>-->
</body>
</html>
CSS
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
nav {
display: flex;
justify-content: space-between;
/*padding-right: 2em;*/
padding-left: 2em;
padding-top: 2em;
padding-bottom: 1.5em;
align-items: center;
min-height: 8vh;
background-color: black;
/*font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;*/
font-family: 'Poppins', sans-serif;
}
.logo {
color: rgb(240, 235, 235);
font-size: 20px;
text-transform: uppercase;
letter-spacing: 5px;
}
.nav-links {
display: flex;
justify-content: space-around;
width: 30%;
}
.nav-links li {
list-style: none;
}
.nav-links a {
color: white;
text-decoration: none;
letter-spacing: 1px;
font-weight: bold;
font-size: 11px;
/*padding: 5px 5px;*/
}
.burger {
display: none;
cursor: pointer;
}
.burger div {
width: 25px;
height: 3px;
background-color: white;
margin: 5px;
transition: all 0.3s ease;
}
#media screen and (max-width:1430px) {
.nav-links {
width: 40%;
}
}
#media screen and (max-width:950px) {
body {
overflow-x: hidden;
}
.nav-links {
position: absolute;
right: 0px;
height: 92vh;
top: 8vh;
background-color: black;
display: flex;
flex-direction: column;
align-items: center;
width: 30%;
transform: translateX(100%);
padding-right: 2em;
transition: transform 0.5s ease-in;
}
.nav-links li {
opacity: 0;
}
.burger {
display: block;
padding-right: 1em;
}
.sub-menu {
position: relative;
}
}
.nav-active {
transform: translate(0%);
}
The question is how to center the car image and remain responsive.
As I understand it (and this may need adjustment for your particular case) the requirement is for the car image to fill space but not leave a huge gap underneath before the footers are reached.
To do this in this case I've set the body element to flex so that once it's decided what is needed space-wise for the navbar and footer it can fill the remaining space with the car.
I initially tried to do this with object-fit: contain and object-position: center within a wrapper around the car img. However, I could not make this work and instead I've removed the car image and set it as a background to a div instead and allowed this div to fill up any remaining space on the screen.
Here's the snippet.
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body {
display: flex;
flex-direction: column;
height: 100vh;
}
nav {
display: flex;
justify-content: space-between;
/*padding-right: 2em;*/
padding-left: 2em;
padding-top: 2em;
padding-bottom: 1.5em;
align-items: center;
min-height: 8vh;
background-color: black;
/*font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;*/
font-family: 'Poppins', sans-serif;
}
.logo {
color: rgb(240, 235, 235);
font-size: 20px;
text-transform: uppercase;
letter-spacing: 5px;
}
.nav-links {
display: flex;
justify-content: space-around;
width: 30%;
}
.nav-links li {
list-style: none;
}
.nav-links a {
color: white;
text-decoration: none;
letter-spacing: 1px;
font-weight: bold;
font-size: 11px;
/*padding: 5px 5px;*/
}
.burger {
display: none;
cursor: pointer;
}
.burger div {
width: 25px;
height: 3px;
background-color: white;
margin: 5px;
transition: all 0.3s ease;
}
#media screen and (max-width:1430px) {
.nav-links {
width: 40%;
}
}
#media screen and (max-width:950px) {
body {
overflow-x: hidden;
}
.nav-links {
position: absolute;
right: 0px;
height: 92vh;
top: 8vh;
background-color: black;
display: flex;
flex-direction: column;
align-items: center;
width: 30%;
transform: translateX(100%);
padding-right: 2em;
transition: transform 0.5s ease-in;
}
.nav-links li {
opacity: 0;
}
.burger {
display: block;
padding-right: 1em;
}
.sub-menu {
position: relative;
}
}
.nav-active {
transform: translate(0%);https://ahweb.org.uk/car.png
}
.main_car_wrapper {
background-image: url(https://ahweb.org.uk/car.png);
background-repeat: no-repeat no-repeat;
background-position: center center;
background-size: contain;
width: 100%;
flex: 1 1 auto;
}
</style>
<nav>
<div class = "logo">
<h4>J[a]son</h4>
</div>
<ul class = "nav-links">
<li>
HOME
</li>
<li>
PHOTOGRAPHY
<ul class="sub-menu">
<li>Colour</li>
<li>Black</li>
</ul>
</li>
<li>
CODING
</li>
<li>
ABOUT
</li>
</ul>
<div class= "burger">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
</nav>
<script src="testing.js"></script>
<div class="main_car_wrapper">
</div>
And some more footer stuff here
<p>June, 2020. Sunshine Coast, BC, Canada </p>
UPDATED
Can use with code like
margin-left: -50px;
margin-right: -50px;
width:100px;
in
.main_car img {
position: absolute;
top: 50%;
left: 50%;
margin-left: [-50% of your image's width];
margin-top: [-50% of your image's height];
}
I'm added css like this
.main_car
{
position: relative;
}
.main_car img
{
position: absolute;
top: 50%;
left: 50%;
margin-left: [-50% of your image's width];
margin-top: [-50% of your image's height];
}
Then will get output like this
Centered Image
body {
background-color: black;
/*rgb(241, 233, 233);*/
}
* {
margin: 0px;
padding: 0px;
}
.main_car
{
position: relative;
}
.main_car img
{
position: absolute;
top: 50%;
left: 50%;
margin-left: -50px;
margin-right: -50px;
width:100px;
}
#media screen and (max-width:1430px) {
.nav-links {
width: 40%;
}
}
#media screen and (max-width:950px) {
body {
overflow-x: hidden;
}
.nav-links {
position: absolute;
right: 0px;
height: 92vh;
top: 8vh;
background-color: black;
display: flex;
flex-direction: column;
align-items: center;
width: 30%;
transform: translateX(100%);
padding-right: 2em;
transition: transform 0.5s ease-in;
}
.nav-links li {
opacity: 0;
}
.burger {
display: block;
padding-right: 1em;
}
.sub-menu {
position: relaative;
}
}
<div class="main_car">
<img src="https://www.gravatar.com/avatar/efb780ba8c3560a06d4c1a1825b1e800?s=32&d=identicon&r=PG" alt="car">
</div>
I am developing a layout of a mobile application, which will be developed in IONIC, the client sent us an example of how like he want the menu of the application, as you can see in the link below:
https://dribbble.com/shots/1701001-GIF-Exercise
Could you give me an idea how to get this result, from the diagonal menu, picking up the whole screen of the cell phone and keep the menu itens inside their colors?
I'm trying this, but i'm stuck here..
https://codepen.io/d3rsonbr/pen/bLvxgb
<div class="container">
<div>
<span>item1</span>
</div>
<div>
<span>item2</span>
</div>
<div>
<span>item3</span>
</div>
<div>
<span>item4</span>
</div>
<div>
<span>item5</span>
</div>
</div>
CSS:
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600,400italic,300italic);
/* ====================================
Navigation
==================================== */
.overlay-navigation {
position: fixed;
z-index: 99;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: hsla(0, 0%, 100%, 0.2);
/*display: none;
opacity: 0;*/
}
nav,
nav ul {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
nav ul {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
list-style: none;
flex-direction: column;
}
nav ul li {
-webkit-flex-basis: 20%;
-ms-flex-preferred-size: 20%;
flex-basis: 20%;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
height: 100%;
overflow: hidden;
/*opacity: 0;
display: none;*/
/*-webkit-transform: rotate(-28deg);
-webkit-transform-origin: top left;
-moz-transform: rotate(-28deg);
-moz-transform-origin: top left;
-ms-transform: rotate(-28deg);
-ms-transform-origin: top left;
-o-transform: rotate(-28deg);
-o-transform-origin: top left;
transform: rotate(-28deg);
transform-origin: top left;*/
}
nav li a {
position: relative;
top: 20%;
color: #fff;
text-transform: uppercase;
font-weight: 300;
letter-spacing: 4px;
text-decoration: none;
display: block;
text-align: center;
font-size: 40px;
opacity: 1;
}
nav li a:before {
content: '';
width: 70px;
height: 2px;
background-color: #fff;
position: absolute;
top: 50%;
left: 0;
z-index: 100;
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
opacity: 0;
-webkit-transition: all .2s linear;
transition: all .2s linear;
}
nav li a:after {
content: attr(data-content);
font-size: 14px;
-webkit-transition: all .2s linear;
transition: all .2s linear;
opacity: 1;
position: absolute;
z-index: 100;
color: #fff;
display: block;
margin-right: auto;
margin-left: auto;
left: 0;
right: 0;
bottom: -25px;
text-transform: none;
font-family: 'Open sans', sans-serif;
font-weight: 600;
letter-spacing: 0;
}
nav li:nth-of-type(1) {
background-color: #29363B
}
nav li:nth-of-type(2) {
background-color: #EA495F
}
nav li:nth-of-type(3) {
background-color: #F4837D
}
nav li:nth-of-type(4) {
background-color: #FDCEA9
}
nav li:nth-of-type(5) {
background-color: #99B998
}
and this another one:
https://codepen.io/d3rsonbr/pen/XZEYKP
I made a mobile responsive hamburger menu to horizontal nav bar, but I'm having trouble making a hover style for the links on the horizontal nav bar that don't make them jump. If you look at my Codpen you'll see the general style I want on those links on hover, but I want that highlight to be larger around the wording. When I've tried to do this the links end up jumping on hover. The other thing is that I can't get the top highlight much bigger... it's like it's cut off with some other property. This is the first menu like this I've made (I'm fairly new) so I played around with a lot of different CSS properties and values to get things to look perfect upon first glance and I'm sure some CSS isn't right, I just don't know what or where. I pasted the code below with everything inline but definitely check out the codpen because that's more accurate to how it looks on my computer. Thanks for your help!
http://codepen.io/sshine2/pen/VbjGaE
EDIT: I edited the code in Codepen to show how the top of the highlight gets cut off and the link jumps when the highlight is the size I want it to be.
SECOND EDIT: Fixed the top being cut off myself. Changed where the entire menu was displayed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
body {
font-family: 'Noto Sans', sans-serif;
margin: 0;
width: 100%;
height: 100vh;
background: #ffffff;
background-color: black;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
header {
width: 100%;
background: #ffffff;
position: fixed;
height: 4em;
line-height: 4em;
display: inline-block;
padding-left: 1em;
border-bottom: .1em solid #dddddd;
}
h2 {
font-size: 2.1em;
}
p {
font-size: 10em;
color: white;
padding-top: 1em;
}
#media only screen and (min-width: 319px) {
.menu {
z-index: 1;
display: none;
font-weight: bold;
font-size: 1.2em;
width: 100%;
background: #f1f1f1;
position: fixed;
text-align: center;
margin-top: 3.3em;
color: black;
}
.menu ul {
margin: 0;
padding: 0;
list-style-type: none;
list-style-image: none;
border-top: #dddddd 1px solid;
}
.menu li {
display: block;
padding: 1em 0 1em 0;
border-bottom: #dddddd 1px solid;
}
.menu li:hover {
display: block;
background: #585858;
padding: 1em 0 1em 0;
cursor: crosshair;
}
.menu ul li a {
text-decoration: none;
margin: 0px;
color: black;
}
.menu ul li a:hover {
color: white;
text-decoration: none;
}
.menu a {
text-decoration: none;
color: black;
}
.menu a:hover {
text-decoration: none;
color: white;
}
#nav-icon4 {
width: 35px;
height: 25px;
float: right;
margin-top: -47px;
margin-right: 30px;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
cursor: cell;
}
#nav-icon4 span {
display: block;
position: absolute;
height: 5px;
width: 100%;
background: darkred;
border-radius: 7px;
opacity: 2;
left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
#nav-icon4 span:nth-child(1) {
top: 0px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#nav-icon4 span:nth-child(2) {
top: 10px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#nav-icon4 span:nth-child(3) {
top: 20px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#nav-icon4.open span:nth-child(1) {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
top: 0;
left: 6px;
}
#nav-icon4.open span:nth-child(2) {
width: 0%;
opacity: 0;
}
#nav-icon4.open span:nth-child(3) {
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
top: 25px;
left: 6px;
}
}
#media only screen and (min-width : 768px) {
h2 {
z-index: 1000000;
font-size: 1.5em;
}
p {
font-size: 20em;
color: white;
padding-top: 1em;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
li {
float: right;
margin-left: 20px;
margin-right: 8px;
margin-top: -10px;
}
li a {
display: block;
text-align: center;
text-decoration: none;
}
.menu {
display: block!important;
position: absolute;
right: 0px;
font-size: .9em;
width: 100%;
padding-right: 15px;
margin-top: 10px;
padding-top: 10px;
padding-bottom: 10px;
background: rgba(255, 255, 255, 0);
}
.menu ul {
border-bottom: 0;
border-top: 0;
}
.menu li {
border-bottom: 0;
border-top: 0;
}
.menu li:hover {
cursor: crosshair;
padding-top: 1em;
padding-bottom: .4em;
padding-right: 0em;
padding-left: 0em;
}
.menu ul li a:hover {
color: white;
}
#nav-icon4 {
display: none;
}
}
#media only screen and (min-width : 922px) {
li {
margin-left: 55px;
margin-right: 18px;
}
.menu {
padding-right: 1px;
}
}
#media only screen and (min-width : 1400px) {
header {
height: 5em;
line-height: 5em;
}
h2 {
font-size: 2.6em;
}
li {
margin-left: 55px;
margin-right: 30px;
}
.menu {
padding-right: 1px;
font-size: 1.2em;
}
}
</style>
<title>hamburgers</title>
</head>
<body>
<header>
<span>Shine Design</span>
<div id="nav-icon4">
<span></span>
<span></span>
<span></span>
</div>
</header>
<div class="menu">
<ul>
<a href="#">
<li>LINK ONE</li>
</a>
<a href="#">
<li>LINK TWO</li>
</a>
<a href="#">
<li>LINK THREE</li>
</a>
<a href="#">
<li>LINK FOUR</li>
</a>
<a href="#">
<li>LINK FIVE</li>
</a>
</ul>
</div>
</body>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">google.load("jquery", "1.3.2");</script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$(document).ready(function(){
$('#nav-icon4').click(function(){
$(this).toggleClass('open');
});
});
</script>
</html>
The jumping issue is because you add padding on hover which isn't there before.
Before your media queries define the padding ones:
.menu li {
border-bottom: 0;
border-top: 0;
padding: 1em;
}
Then remove the defined paddings for .menu li in your min 768px query.,
code pen