How can I create cubic menu like this image: (When I hover on menu item)
ul li {
border-left: 1px solid #515151;
text-align: center;
padding: 4px 1rem;
font-size: 0.625rem;
}
ul {
display: flex;
padding: 0;
list-style: none;
border: 0 solid #515151;
border-width: 1px 1px 1px 0;
width: 275px;
}
<ul>
<li>Home</li>
<li>About Us</li>
<li>Products</li>
<li>Contact Us</li>
</ul>
This was my prototype for the 3d box
I then applied the prototype to your menu. What I like least is the need to set a default size. You can find in the comments where to set the height (the variabler --height) and width (--width) of the individual menu items or the height of the extrusion (--extrude).
body {
margin: 100px;
transform: translate3d(0,0,0);
transform-style: flat;
}
ul {
display: flex;
padding: 0;
list-style: none;
width: 275px;
--extrude: 0px;
--height: 35px; /* Your menu height */
}
ul li {
position: relative;
font-size: 16px;
}
.home {
--width: 75px; /* Your static width */
z-index: 1000;
}
.aboutus {
--width: 85px; /* Your static width */
z-index: 999;
}
.products {
--width: 85px; /* Your static width */
z-index: 998;
}
.contactus {
--width: 100px; /* Your static width */
z-index: 997;
}
.wrap {
position: relative;
width: var(--width);
height: var(--height);
background-color: #cccccc;
border: solid 1px #000000;
perspective: 1000px;
perspective-origin: -200px 300px;
}
.wrap * {
box-sizing: border-box;
border: none;
transition: all 0.25s;
}
.front {
position: absolute;
width: 100%;
height: 100%;
text-align: center;
line-height: var(--height);
background-color: #ffffff;
color:#000000;
transform-origin: 50% 50%;
transform: translateZ(var(--extrude));
}
ul li:hover {
--extrude: 30px; /* Your extrude height */
}
ul li:hover .front {
background-color: #f7a62f;
color:#ffffff;
}
ul li:hover .front,
ul li:hover .bottom,
ul li:hover .left {
border: solid 1px #000000;
}
.bottom {
position: absolute;
width: 100%;
height: var(--extrude);
background-color: #a3a3a3;
transform-origin: 50% 100%;
transform: translateY(calc(var(--height) - var(--extrude))) rotateX(270deg);
}
.left {
width: var(--extrude);
height: 100%;
background-color: #ffffff;
transform-origin: 0% 50%;
transform: translateZ(var(--extrude)) rotateY(90deg);
}
<ul>
<li>
<div class="wrap home">
<div class="front">
home
</div>
<div class="bottom"></div>
<div class="left"></div>
</div>
</li>
<li>
<div class="wrap aboutus">
<div class="front">
About Us
</div>
<div class="bottom"></div>
<div class="left"></div>
</div>
</li>
<li>
<div class="wrap products">
<div class="front">
Products
</div>
<div class="bottom"></div>
<div class="left"></div>
</div>
</li>
<li>
<div class="wrap contactus">
<div class="front">
Contact Us
</div>
<div class="bottom"></div>
<div class="left"></div>
</div>
</li>
</ul>
Try this example,it uses combination of :before&:after,(I know there is some lag)
*,
*:before,
*:after {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
}
body {
display: flex;
align-items: center;
justify-content: center;
transform: translate3d(0, 0, 0);
}
.clearfix {
zoom: 1;
}
.clearfix:before, .clearfix:after {
content: " ";
display: block;
height: 0;
overflow: hidden;
}
.clearfix:after {
clear: both;
}
body {
background: #f2f2f2;
}
ul {
display:inline-flex;
transform: rotate(0deg) skew(0deg, 0deg);
width:100%;
}
.list-item {
background: #000;
color: #575757;
text-align: center;
height: 2.5em;
width: 4em;
vertical-align: middle;
line-height: 2.5em;
border-bottom: 1px solid #060606;
position: relative;
display: inline-block;
text-decoration: none;
transition: all 0.25s linear;
}
.list-item:hover {
background: #ff6e42;
color: #fffcfb;
transform: translate(0.9em, -0.9em);
transition: all 0.25s linear;
}
.list-item:hover{
z-index:100;
}
.list-item:hover:before, .list-item:hover:after {
transition: all 0.25s linear;
}
.list-item:hover:before {
background: #b65234;
width: 1em;
top: 0.5em;
left: -1em;
}
.list-item:hover:after {
background: #b65234;
width: 1em;
bottom: -2.5em;
left: 1em;
height: 4em;
}
.list-item:before, .list-item:after {
content: "";
position: absolute;
transition: all 0.25s linear;
width: 0.5em;
}
.list-item:after {
height: 4em;
background: #000;
bottom: -2.25em;
left: 1.5em;
transform: rotate(90deg) skew(0, 45deg);
}
.list-item:before {
height: 2.5em;
background: #000;
top: 0.25em;
left: -0.5em;
transform: skewY(-45deg);
}
<ul>
<li>
<a class='list-item' href=''>
hi
</a>
</li>
<li>
<a class='list-item' href=''>
hello
</a>
</li>
<li>
<a class='list-item' href=''>
i am a
</a>
</li>
<li>
<a class='list-item' href=''>
menu
</a>
</li>
<li>
<a class='list-item' href=''>
item
</a>
</li>
</ul>
Related
I am trying to use HTML and CSS instead of images to show some arrows -- Here is the image:
I'm trying to make these arrows with before and after pseudo-elements, but I have got problems.
Here's my code:
HTML:
<ul class="steps-list">
<li class="step-item">
Contact us
</li>
<li class="step-item">
Consult with RCIC
</li>
<li class="step-item">
Apply via your pathway
</li>
<li class="step-item">
Settle in Canada
</li>
</ul>
SASS:
.steps-list {
display: flex;
.step-item {
display: inline-block;
text-align: center;
width: 25%;
.step-link {
font-weight: bold;
background: #e2e3e4;
width: 100%;
display: inline-block;
padding: 2rem 1rem;
&:hover {
#include gradient(left, $gradientList2);
}
}
}
}
I have followed this article by the way:
https://css-tricks.com/snippets/css/css-triangle/
[Edit] After looking at your image again, I failed to account for the first element being flat. I have updated my answer.
Using before,after, and nth-child selectors, you can achieve what you showed in your image. The before and after pseudo elements are used to create the top and bottom half of the arrows while the nth-child selectors are used to make the arrows appear to be progressively closer together.
.steps-list {
display: flex;
list-style: none;
}
.steps-list .step-item {
position: relative;
display: flex;
align-items:center;
text-align: center;
width: 25%;
}
.steps-list .step-item .step-link {
font-weight: bold;
width: 100%;
display: inline-block;
padding:10px 5px;
box-sizing:border-box;
}
.step-link::before {
content: "";
display: block;
position: absolute;
transform: skew(-40deg, 0);
background: #e2e3e4;
height: 50%;
bottom: 0;
z-index: -1;
left:5px;
}
.step-link::after {
content: "";
display: block;
position: absolute;
transform: skew(40deg, 0);
background: #e2e3e4;
height: 50%;
top: 0;
z-index: -1;
left:5px;
}
.step-item:nth-child(1){
overflow:hidden;
}
.step-item:nth-child(1) .step-link::after {
width:95%;
left:-15px;
}
.step-item:nth-child(1) .step-link::before {
width: 95%;
left:-15px;
}
.step-item:nth-child(2) .step-link::after {
width: 90%;
}
.step-item:nth-child(2) .step-link::before {
width: 90%;
}
.step-item:nth-child(3) .step-link::after {
width: 95%;
}
.step-item:nth-child(3) .step-link::before {
width: 95%;
}
.step-item:nth-child(4) .step-link::after {
width: 100%;
}
.step-item:nth-child(4) .step-link::before {
width: 100%;
}
<ul class="steps-list">
<li class="step-item">
Contact us
</li>
<li class="step-item">
Consult with RCIC
</li>
<li class="step-item">
Apply via your pathway
</li>
<li class="step-item">
Settle in Canada
</li>
</ul>
Check this site
.clearfix:after {
clear: both;
content: "";
display: block;
height: 0;
}
.container {
font-family: 'Lato', sans-serif;
width: 1000px;
margin: 0 auto;
}
.wrapper {
display: table-cell;
height: 400px;
vertical-align: middle;
}
.nav {
margin-top: 40px;
}
.arrow-steps .step {
font-size: 14px;
text-align: center;
color: #666;
cursor: default;
margin: 0 3px;
padding: 10px 10px 10px 30px;
min-width: 180px;
float: left;
position: relative;
background-color: #d9e3f7;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
transition: background-color 0.2s ease;
}
.arrow-steps .step:after,
.arrow-steps .step:before {
content: " ";
position: absolute;
top: 0;
right: -17px;
width: 0;
height: 0;
border-top: 19px solid transparent;
border-bottom: 17px solid transparent;
border-left: 17px solid #d9e3f7;
z-index: 2;
transition: border-color 0.2s ease;
}
.arrow-steps .step:before {
right: auto;
left: 0;
border-left: 17px solid #fff;
z-index: 0;
}
.arrow-steps .step:first-child:before {
border: none;
}
.arrow-steps .step:first-child {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.arrow-steps .step span {
position: relative;
}
<div class="container">
<div class="wrapper">
<div class="arrow-steps clearfix">
<div class="step current"> <span> Step 1</span> </div>
<div class="step"> <span>Step 2 some words</span> </div>
<div class="step"> <span> Step 3</span> </div>
<div class="step"> <span>Step 4</span> </div>
</div>
</div>
</div>
I am have a menu for my website and which is currently align on the left side of the browser. I am try to align on the right side of the browser.
here is the demo: here
what I want is just put the hole menu and align it on the right side of the browser screen. currently its showing on the left side.
trying to do:https://i.stack.imgur.com/D0y00.png
html code:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css">
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<header>
<span class="toggle-button">
<div class="menu-bar menu-bar-top"></div>
<div class="menu-bar menu-bar-middle"></div>
<div class="menu-bar menu-bar-bottom"></div>
</span>
<div class="menu-wrap">
<div class="menu-sidebar">
<ul class="menu">
<li>Home</li>
<li class="children">News
<span class="arrow"></span>
<ul class="child-menu ">
<li>Link 1</li>
<li>Link 2</li>
<li>link 3</li>
</ul>
</li>
<li class="children">Contact
<span class="arrow"></span>
<ul class="child-menu ">
<li>Link 1</li>
<li>Link 2</li>
<li>link 3</li>
</ul>
</li>
<li class="children">About
<span class="arrow"></span>
<ul class="child-menu ">
<li>Link 1</li>
<li>Link 2</li>
<li>link 3</li>
</ul>
</li>
<li>FAQ</li>
<li>Services</li>
</ul>
</div>
</div>
</header>
<div class="wrapper" style="background-color:;padding:15px;">
<section class="text" style="background-color:;">
<h2 class="heading" id="headings" style="background-color:;text-align:center;">Three Line Menu & CSS Transitions</h2>
<p class="buttons" style="min-width: 200px;margin:auto;background-color:;text-align:center;">
Learn More
</p>
</section>
</div>
CSS:
html {
background: url(https://s33.postimg.cc/tm1vd9yy7/Background_2.jpg);
background-attachment:fixed;
background-repeat: no-repeat;
background-size: cover;
}
.btn_one {
text-decoration: none;
color: white;
font-weight: 100;
border: 1px #fbbc05 solid;
padding: 1em 3em;
border-radius: 100px;
}
a {
text-decoration: none;
}
ul {
padding-left: 0;
}
li {
list-style: none;
}
* {
box-sizing: border-box;
}
body {
font-family: 'Montserrat', Arial, serif;
}
::selection {
background-color: #EBEBF2;
color: #83828D;
}
/* ==================================== */
/* Navigaton Menu */
/* ==================================== */
.menu-wrap {
background-color: #625871;
position: fixed;
top: 0;
height: 100%;
width: 280px;
margin-left: -280px;
font-size: 1em;
font-weight: 700;
overflow: auto;
transition: .25s;
z-index: 10;
}
.menu-show {
margin-left: 0;
box-shadow: 4px 2px 15px 1px #262424;
}
.menu-sidebar {
margin: 75px 0 80px 10px;
position: relative;
top: 70px;
}
.menu-sidebar li {
padding: 18px 22px 0;
}
.menu-sidebar li > a {
color: #f3f3f3;
font-size: 1.18em;
position: relative;
}
.menu-sidebar li > a::after {
content: "";
display: block;
height: 0.15em;
position: absolute;
top: 100%;
width: 100%;
left: 50%;
transform: translate(-50%);
background-image: linear-gradient(to right, transparent 50.3%, #FFFA3B 50.3%);
transition: background-position .2s .1s ease-out;
background-size: 200% auto;
}
.menu-sidebar li > a:hover::after {
background-position: -100% 0;
}
.menu-sidebar .children {
position: relative;
}
.menu-sidebar .children .child-menu {
display: none;
}
.arrow::after {
content: "\f107";
font-family: 'FontAwesome';
padding: 10px;
color: #FFFA3B;
position: relative;
}
.arrow:hover::after {
cursor: pointer;
color: #fff;
}
.arrow:active::after {
top: 2px;
}
/*Hamburger Button*/
.toggle-button {
position: fixed;
width: 44px;
height: 40px;
top: 50px;
left: 40px;
padding: 4px;
transition: .25s;
z-index: 15;
}
.toggle-button:hover {
cursor: pointer;
}
.toggle-button .menu-bar {
position: absolute;
border-radius: 2px;
transition: .5s;
}
.toggle-button .menu-bar-top {
border: 4px solid #fff;
border-bottom: none;
top: 0;
width: 80%;
}
.toggle-button .menu-bar-middle {
height: 4px;
background-color: #fff;
margin-top: 7px;
margin-bottom: 7px;
width: 40%;
top: 4px;
}
.toggle-button .menu-bar-bottom {
border: 4px solid #fff;
border-top: none;
top: 22px;
width: 60%;
}
.toggle-button:hover div
{
width: 80%;
}
.button-open {
left: 25px;
}
.button-open .menu-bar-top {
border-color: #fff;
transform: rotate(45deg) translate(8px, 8px);
transition: .5s;
}
.button-open .menu-bar-middle {
background-color: #fff;
transform: translate(230px);
transition: .1s ease-in;
opacity: 0;
}
.button-open .menu-bar-bottom {
border-color: #fff;
transform: rotate(-45deg) translate(7px, -7px);
transition: .5s;
}
/* Text Block */
.wrapper {
width: 40%;
margin: 100px auto 0;
color: #83828D;
}
.wrapper .text {
padding: 30px;
}
.wrapper .text .heading {
margin-bottom: 40px;
font-size: 2em;
color:#fff;
}
.wrapper .text p {
line-height: 1.6em;
}
.wrapper .text .buttons {
margin-top: 40px;
}
/* Buttons */
.wrapper .buttons .button {
display: inline-block;
margin-right: 20px;
padding: 20px 25px;
border-radius: 2em;
background-color: #70CE64;
color: #fff;
font-size: .9em;
font-weight: 700;
transition: background-color .3s;
}
.wrapper .buttons .button-secondary {
background-color: #FF6746;
}
.wrapper .buttons .button-primary:hover {
background-color: #84D07A;
}
.wrapper .buttons .button-secondary:hover {
background-color: #FF7D60;
}
/*Active state for the buttons*/
.wrapper .buttons .button-primary:active {
background-color: #70CE64;
}
.wrapper .buttons .button-secondary:active {
background-color: #FF6746;
}
/*Icons*/
.wrapper .buttons .button span {
position: relative;
display: inline-block;
padding-right: 20px;
}
.wrapper .buttons .button span::after {
position: absolute;
font-family: "FontAwesome";
right: -3px;
font-size: 14px;
top: 0;
transition: top .3s, right .3s;
}
.wrapper .buttons .button-primary span::after {
content: "\f019";
}
.wrapper .buttons .button-secondary span::after {
content: "\f178";
}
/*Slight icons animation*/
.wrapper .buttons .button-primary:hover span::after {
top: 4px;
}
.wrapper .buttons .button-secondary:hover span::after {
right: -6px;
}
#media screen and (max-width: 480px) {
#headings{
margin-bottom:20px;
font-size: 18px;
color:#fff;
}
.btn_one {
text-decoration: none;
color: #fff;
font-size:12px;
font-weight: 100;
border: 1px #fbbc05 solid;
padding: 8px 23px;
border-radius: 100px;
}
ul {
padding-left: 35px;
}
.menu-sidebar li
{
padding:0;
}
.menu-wrap {
width: 200px;
}
}
SCRIPT:
$(document).ready(function() {
var $toggleButton = $('.toggle-button'),
$menuWrap = $('.menu-wrap'),
$sidebarArrow = $('.arrow');
// Hamburger button
$toggleButton.on('click', function() {
$(this).toggleClass('button-open');
$menuWrap.toggleClass('menu-show');
});
// Sidebar navigation arrows
$sidebarArrow.click(function() {
$(this).next().slideToggle(300);
});
});
Here is the source code for reference: https://nofile.io/f/9bKHsuOoUza/source_code_new.zip
Can anybody guide me? Any input is appreciated.
Thank you so much.
change the toggle button to:
default:
.toggle-button {
position: fixed;
width: 44px;
height: 40px;
top: 50px;
left: auto;
padding: 4px;
transition: .25s;
z-index: 15;
right: 40px;
}
open:
.button-open {
left: auto;
right: 25px;
}
then change the menu to:
closed:
.menu-wrap {
background-color: #00000030;
position: fixed;
top: 0;
height: 100%;
width: 240px;
margin-left: 0;
right: -280px;
font-size: 1em;
font-weight: 700;
overflow: auto;
transition: .25s;
z-index: 10;
left: auto;
}
open:
.menu-show {
left: auto;
right: 0;
margin-left: 0;
box-shadow: 4px 2px 15px 1px #080707;
}
easy as that!
Okey, I'm working on a project and run in to a smal problem. I have a list that have text with an underline animation but now I want to include an img in the list. So i want to hover both the img and the text and the animation will only aply to the text. I have tried with a p element but didnt really work.
This is what I have at the moment:
/*Not imortant*/
.wrapper {
background-color: white;
color: white;
height: 500px;
margin: auto;
margin-top: 50px;
max-width: 1024px;
padding: 20px;
text-shadow: 1px 1px 1px #333;
width: 65%;
}
.wrapper h2 {
font-size: 44px;
margin: 0;
}
.wrapper p {
font-size: 25px;
font-weight: 500;
}
/*Here the important stuff happens*/
.wrapper li {
text-align: center;
}
.wrapper a img {
width: 100%;
height: 100px;
}
.wrapper a p {
color: white;
display: inline-block;
font-size: 25px;
font-weight: 500;
position: relative;
margin: 0;
}
.wrapper a p:before {
content: "";
position: absolute;
width: 100%;
height: 2px;
bottom: 0;
left: 0;
background-color: white;
visibility: hidden;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
.wrapper a p:hover:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.main {
background-color: rgba(51, 51, 51, 0.3);
}
<main class="wrapper main">
<div class="row--no-gutter">
<h2>Gnestarias</h2>
<p>Some text :)</p>
</div>
<div class="row--no-gutter">
<ul>
<li class="col col--1-of-5">
<a href="arena.html">
<p>Arena</p>
<img src="#" alt="bild">
</a>
</li>
<li class="col col--1-of-5">
<a href="athena.html">
<p>Athena</p>
</a>
</li>
<li class="col col--1-of-5">
<a href="eatmeat.html">
<p>Eatmeat</p>
</a>
</li>
<li class="col col--1-of-5">
<a href="georges.html">
<p>Georges</p>
</a>
</li>
<li class="col col--1-of-5">
<a href="vitavillan.html">
<p>Vitavillan</p>
</a>
</li>
</ul>
</div>
</main>
Note that there is an grid behind it also (toast grid to be spesific) :)
Can i do something with only css or do I have to fix it with Javascript?
I want to be able to hover both the img and the text and the animation should only apply on the text, nothing else, and the underline should stop when the text stops
Hope you can help :)
http://johhag98.github.io/Gnesta-Pizza/
Move the hover trigger to the wrapping anchor
.wrapper a:hover p:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
/*Not imortant*/
.wrapper {
background-color: white;
color: white;
height: 500px;
margin: auto;
margin-top: 50px;
max-width: 1024px;
padding: 20px;
text-shadow: 1px 1px 1px #333;
width: 65%;
}
.wrapper h2 {
font-size: 44px;
margin: 0;
}
.wrapper p {
font-size: 25px;
font-weight: 500;
}
/*Here the important stuff happens*/
.wrapper li {
text-align: center;
list-style: none;
}
.wrapper a {
display: block;
}
.wrapper a img {
max-width: 100%;
height: 100px;
}
.wrapper a p {
color: white;
display: inline-block;
font-size: 25px;
font-weight: 500;
position: relative;
margin: 0;
}
.wrapper a p:before {
content: "";
position: absolute;
width: 100%;
height: 2px;
bottom: 0;
left: 0;
background-color: white;
visibility: hidden;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
.wrapper a:hover p:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.main {
background-color: rgba(51, 51, 51, 0.3);
}
<main class="wrapper main">
<div class="row--no-gutter">
<h2>Gnestarias</h2>
<p>Some text :)</p>
</div>
<div class="row--no-gutter">
<ul>
<li class="col col--1-of-5">
<a href="arena.html">
<p>Arena</p>
<img src="http://www.fillmurray.com/100/100" alt="bild">
</a>
</li>
</ul>
</div>
</main>
Why don't you trigger the animation on hovering on the parent anchor tag?
Like this:
.wrapper a:hover p:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
Demo here:
/*Not imortant*/
.wrapper {
background-color: white;
color: white;
height: 500px;
margin: auto;
margin-top: 50px;
max-width: 1024px;
padding: 20px;
text-shadow: 1px 1px 1px #333;
width: 65%;
}
.wrapper h2 {
font-size: 44px;
margin: 0;
}
.wrapper p {
font-size: 25px;
font-weight: 500;
}
/*Here the important stuff happens*/
.wrapper li {
text-align: center;
}
.wrapper a img {
width: 100%;
height: 100px;
}
.wrapper a p {
color: white;
display: inline-block;
font-size: 25px;
font-weight: 500;
position: relative;
margin: 0;
}
.wrapper a p:before {
content: "";
position: absolute;
width: 100%;
height: 2px;
bottom: 0;
left: 0;
background-color: white;
visibility: hidden;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
.wrapper a p:hover:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.wrapper a:hover p:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.main {
background-color: rgba(51, 51, 51, 0.3);
}
<main class="wrapper main">
<div class="row--no-gutter">
<h2>Gnestarias</h2>
<p>Some text :)</p>
</div>
<div class="row--no-gutter">
<ul>
<li class="col col--1-of-5">
<a href="arena.html">
<p>Arena</p>
<img src="#" alt="bild">
</a>
</li>
<li class="col col--1-of-5">
<a href="athena.html">
<p>Athena</p>
</a>
</li>
<li class="col col--1-of-5">
<a href="eatmeat.html">
<p>Eatmeat</p>
</a>
</li>
<li class="col col--1-of-5">
<a href="georges.html">
<p>Georges</p>
</a>
</li>
<li class="col col--1-of-5">
<a href="vitavillan.html">
<p>Vitavillan</p>
</a>
</li>
</ul>
</div>
</main>
I've used overflow: hidden to make my layout fluid. Please see (following code) the top right button named Dropdown Menu. This is what needs to be fixed.
Please see the following code for reference.
* {
padding: 0;
margin: 0;
}
*:focus {
outline: 0;
}
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
a {
text-decoration: none;
color: inherit;
}
body {
font: 14px/18px Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.float-left {
float: left;
}
.float-right {
float: right;
}
.dropdown-box {
position: relative;
}
.dropdown-box:hover .dropdown-menu {
display: block;
}
.dropdown-menu {
display: none;
position: absolute;
top: 100%;
left: 0;
}
.overlay-block {
display: none;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
position: absolute;
top: 0;
left: 0;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
transition: all 0.2s;
}
.position-center {
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
left: 50%;
}
.profile-header {
display: block;
}
.profile-cover {
height: 100px;
background-color: rgba(0, 0, 0, 0.5);
}
.profile-header-content {
padding-bottom: 15px;
margin-top: -72px;
position: relative;
}
.profile-header-content:after {
content: '';
clear: both;
display: block;
}
.profile-user-image,
.profile-user-video {
width: 140px;
height: 140px;
background-color: rgba(234, 234, 234, 0.5);
color: #fff;
padding: 5px;
margin: 0 15px;
overflow: hidden;
position: relative;
}
.profile-user-image:hover .overlay-block,
.profile-user-video:hover .overlay-block {
display: block;
}
.profile-user-image:active .overlay-block,
.profile-user-video:active .overlay-block {
background: rgba(0, 0, 0, 0.95);
}
.profile-user-image img,
.profile-user-video img {
display: block;
width: 100%;
}
.profile-center-content {
overflow-x: hidden;
overflow-y: visible !important;
}
<div class="profile-header">
<div class="profile-cover"> </div>
<div class="profile-header-content">
<a class="profile-user-image float-left" href="javascript:;">
<div class="overlay-block">
<div class="position-center">Overlay</div>
</div>
</a>
<a class="profile-user-video float-right" href="javascript:;">
<div class="overlay-block">
<div class="position-center">Overlay</div>
</div>
</a>
<div class="profile-center-content">
<div class="float-left">
Lorem Ipsum
</div>
<div class="float-right">
<div class="dropdown-box">
Dropdown Menu
<ul class="dropdown-menu">
<li>Home
</li>
<li>About
</li>
<li>Services
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
when you are using position: absolute; the element goes out of the scope. so remove it from .dropdown-menu so it stay's in the scope of profile-center-content and not considered out of it so it get's scrolled.
* {
padding: 0;
margin: 0;
}
*:focus {
outline: 0;
}
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
a {
text-decoration: none;
color: inherit;
}
body {
font: 14px/18px Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.float-left {
float: left;
}
.float-right {
float: right;
}
.dropdown-box {
position: relative;
}
.dropdown-box:hover .dropdown-menu {
display: block;
}
.dropdown-menu {
display: none;
}
.overlay-block {
display: none;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
position: absolute;
top: 0;
left: 0;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
transition: all 0.2s;
}
.position-center {
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
left: 50%;
}
.profile-header {
display: block;
}
.profile-cover {
height: 100px;
background-color: rgba(0, 0, 0, 0.5);
}
.profile-header-content {
padding-bottom: 15px;
margin-top: -72px;
position: relative;
}
.profile-header-content:after {
content: '';
clear: both;
display: block;
}
.profile-user-image,
.profile-user-video {
width: 140px;
height: 140px;
background-color: rgba(234, 234, 234, 0.5);
color: #fff;
padding: 5px;
margin: 0 15px;
overflow: hidden;
position: relative;
}
.profile-user-image:hover .overlay-block,
.profile-user-video:hover .overlay-block {
display: block;
}
.profile-user-image:active .overlay-block,
.profile-user-video:active .overlay-block {
background: rgba(0, 0, 0, 0.95);
}
.profile-user-image img,
.profile-user-video img {
display: block;
width: 100%;
}
.profile-center-content {
overflow-x: hidden;
overflow-y: visible !important;
}
<div class="profile-header">
<div class="profile-cover"> </div>
<div class="profile-header-content">
<a class="profile-user-image float-left" href="javascript:;">
<div class="overlay-block">
<div class="position-center">Overlay</div>
</div>
</a>
<a class="profile-user-video float-right" href="javascript:;">
<div class="overlay-block">
<div class="position-center">Overlay</div>
</div>
</a>
<div class="profile-center-content">
<div class="float-left">
Lorem Ipsum
</div>
<div class="float-right">
<div class="dropdown-box">
Dropdown Menu
<ul class="dropdown-menu">
<li>Home
</li>
<li>About
</li>
<li>Services
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
I want to create a dropdown menu, that works with mobile (i'm using media queries) platforms.
I am able to create the media query to make it work only on 320/480/720px but I am not able to create this sub-menu class, has dropdown menu.
Any tips or tutorials, I could see? Any help would be appreciated...
HTML
<div class="header">
<div class="menu">
<ul>
<li><img src="www.wemadeyou.pt/img/menu.png" alt="Menu" width="22" height="17"/>
<ul class="sub-menu">
<li>Home</li>
<li>Portfolio</li>
<li>Services</li>
<li>About</li>
<li>Contacts</li>
</ul>
</li>
</ul>
</div>
</div>
CSS
.header{
position: relative;
width: 100%;
height: 50px;
margin: 0 auto;
padding: 0;
display: block;
text-align: center;
margin-bottom: 25px;
background-color: rgba(0, 0, 0, 0.2);
}
.menu{}
Maybe not the best solution for you but I did my best.
https://codepen.io/leobezr/pen/VweOELv
Note: Use devTools to change window size.
Note: You might need to use the following code
<body>
<div class="header">
<div class="logo">LOGO</div>
<div class="navigation">
<ul class="sub-menu">
<li>Home</li>
<li>Portfolio</li>
<li>Services</li>
<li>About</li>
<li>Contacts</li>
</ul>
</div>
<div class="mobileController" style="display: none;">
<a href="#" role="button" action="openMenu">
<span class="sandwich">
<span></span>
</span>
</a>
</div>
</div>
<div class="content">
Hello world
</div>
</body>
#import url('https://fonts.googleapis.com/css2?family=Montserrat:wght#300;500&display=swap');
body {
font-family: 'Montserrat', sans-serif;
font-size: 15px;
min-height: calc(100vh * 2);
}
.header {
display: flex;
flex: 1;
flex-direction: row;
justify-content: space-around;
align-items: center;
z-index: 1000;
height: 40px;
background: #ecf5ff;
}
.header:not(.fixed) {
position: relative;
}
.header.fixed {
position: fixed;
left: 0;
top: 0;
width: 100%;
animation: fadeDown 400ms 1 ease-in;
animation-fill-mode: forwards;
}
.header .navigation ul {
padding: 0;
margin: 0;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center
}
.header .navigation li {
display: flex;
padding: 12px 6px;
}
.header .navigation li a {
text-decoration: none;
font-weight: 600;
position: relative;
color: #222;
}
.header .navigation li a:before {
content: "";
position: absolute;
left: 0;
bottom: 5px;
opacity: 0;
height: 2px;
width: 100%;
display: block;
background: #222;
}
.header .navigation li a:hover {
filter: brightness(1.1);
transition: all 200ms ease-in;
}
.header .navigation li a:hover:before {
opacity: 1;
transform: translateY(7px);
transition: all 200ms ease-in;
}
.mobileController .sandwich span {
display: block;
width: 35px;
height: 2px;
background: #222;
position: relative;
}
.mobileController .sandwich span:before {
content: "";
width: inherit;
height: inherit;
position: absolute;
left: 0;
top: -6px;
background: inherit;
}
.mobileController .sandwich span:after {
content: "";
width: inherit;
height: inherit;
position: absolute;
left: 0;
top: 6px;
background: inherit;
}
.mobileController>a {
display: flex;
height: 20px;
align-content: center;
align-items: center;
cursor: pointer;
}
.mobileController>a:hover {
transform: scale(.9);
transition: all 200ms ease-in;
}
#media (max-width: 992px) {
.navigation {
display: none;
position: absolute;
left: 0;
top: 40px;
background: #fff;
width: 100%;
z-index: -1;
border-bottom: solid 1px #ebebeb;
}
.navigation.view {
display: block !important;
animation: slideIn 400ms ease-in 1;
animation-fill-mode: forwards;
}
.navigation ul {
flex-direction: column !important;
}
.mobileController {
display: block !important;
}
}
#keyframes fadeDown {
0% {
opacity: 0;
transform: translateY(-100%);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
#keyframes slideIn {
0% {
opacity: 0;
display: block !important;
transform: translateX(-100%);
}
100% {
opacity: 1;
display: block !important;
transform: translateX(0);
}
}
window.addEventListener("scroll", () => {
const $header = document.querySelector(".header");
const headerHeight = $header.offsetHeight;
if (window.pageYOffset >= Math.round(headerHeight * 2)) {
$header.classList.add("fixed");
} else {
$header.classList.remove("fixed");
}
})
!function(){
window.addEventListener("load", init);
}()
function init() {
const $button = document.querySelector(".mobileController");
const $navigation = document.querySelector(".navigation");
$button.addEventListener("click", () => $navigation.classList.toggle("view"));
}
Ok #uniqezor I do smth^^
Look:
<div class="header">
<div class="menu">
<ul>
<li><img src="www.wemadeyou.pt/img/menu.png" alt="Menu" width="22" height="17"/>
<ul class="sub-menu">
<li>Home</li>
<li>Portfolio</li>
<li>Services</li>
<li>About</li>
<li>Contacts</li>
</ul>
</li>
</ul>
</div>
<div class="topmenu container clearfix">
<div class="top">
<a href="#" class="logo">
<img src="http://wemadeyou.pt/img/logo.png" alt="WeMadeYou - Future Together" class="logo" width="65"
height="21" itemprop="image"/>
</a>
<span class="textbox">This is what we made of you!</span>
<div class="clear"></div>
<div class="nav">
<ul>
<li>Home</li>
<li>Portfolio</li>
<li>Services</li>
<li>About</li>
<li>Contacts</li>
</ul>
</div>
</div>
</div>
</div>
.header{
position: relative;
width: 100%;
height: 50px;
margin: 0 auto;
padding: 0;
display: block;
text-align: center;
margin-bottom: 25px;
background-color: rgba(0, 0, 0, 0.2);
}
.logo{
float: left;
margin-top: 6px;
margin-right: 10px;
margin-left: 5px;
}
.topmenu{
text-align: center;
height: 50px;
margin: 0 auto;
}
.top{
display: inline;
padding: 0;
}
span.textbox{
display: inline;
float: left;
font-size: 13px;
margin-top: 14px;
color: white;
font-weight: bold;
}
.nav{
float: right;
display: inline;
margin: 0;
padding: 0;
margin-left: auto;
margin-right: auto;
}
.nav ul{margin: 0;}
.nav li{
width: 100px;
height: 50px;
display: inline-block;
float: right;
margin-right: 5px;
}
.nav li a{
height: 40px;
color: white;
font-size: 12px;
font-weight: bold;
text-decoration: none;
text-transform: uppercase;
line-height: 48px;
padding: 16px 20px 14px 20px;
}
.nav li a#home{
height: 40px;
padding: 16px 30px 14px 30px;
}
.nav li a:hover{border-bottom:thick solid #fff;}
.menu{display: none; }
#media screen and (max-width: 294px) {
span.textbox {
font-size: 10px;
}}
#media screen and (max-width: 859px) {
.clear{clear: both}
.nav{float: left;max-width: 100%;width: 100%;}
.nav li {display: block;width: 100%;
float: none;margin: 0 auto;}
.nav ul{padding: 0}
.nav li a{color:black}
}