Dropdown menu hiding behind content? - html

so I'm new to this and have been trying to put in a dropdown menu on a theme I found online. I've gotten it to work for the most part, however, the dropdown menu is hiding behind the main content. I know this is the problem because it works when I adjust the top padding for ".menu ul #listcontain" but it moves the photo to a place I don't want it. I feel like I've tried everything (adjusting z-indexes, positions, etc.) and still cannot figure it out. I just started doing this a month ago can someone help me out? Many thanks.
So then for the CSS I have this (Just the menu. It's a big page so I'm trying to include just the part I need):
*{padding:0; margin:0;}
body{ font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#1491c1; background:url(../images/bg.jpg) repeat;}
img{border:none;}
h1{ font-family: 'Droid Serif', serif; font-weight:normal; color:#fff;}
h2{ font-family: 'Droid Serif', serif; font-weight:normal; color:#fff; font- size:18px;}
P{ line-height:20px;}
a{text-decoration:none; color:#1491c1;}
a:hover{color:#fff;}
/*-------------------------------------------------
GENERAL CLASSES
-------------------------------------------------*/
.mar-top{ margin-top:40px;}
.mar-top30{ margin-top:30px;}
.mar-bottom{ margin-bottom:40px;}
.mar-Right{ margin-right:40px;}
.mar-right115{ margin-right:115px;}
.float-left{ float:left;}
.float-right{ float:right;}
.clearing { clear:both;}
.bor-bottm-non{border-bottom:none!important;}
.panel{}
.title{}
.content{}
.wrap{width:960px; margin:0 auto;overflow:hidden; background:url(../images/page-bg.jpg);}
.page{ width:580px; margin:0 auto;overflow:hidden; padding-bottom:50px;}
.page-content{ width:580px; margin:0 auto;overflow:hidden; padding- bottom:30px; padding-top:30px;}
.block{padding:20px 20px 20px 20px; margin:0 auto;}
.block2{padding:20px 20px 20px 20px; margin:0 auto;}
.button a{text-decoration:none; display:block; width:70px; height:30px; background:#1491c1; color:#ffffff; font-family:Arial, Helvetica, sans-serif; line-height:30px; text-align:center;}
.button a:hover{ background:#0e5295;}
/*-------------------------------------------------
CONTENT CLASSES
-------------------------------------------------*/
.page-content{ width:580px; margin:0 auto;overflow:hidden; padding- bottom:30px; padding-top:30px;}
.page-content .content h3{ padding-bottom:20px;font-family: 'Droid Serif', serif; font-weight:normal; color:#fff; font-size:16px;}
.page-content .content p{ padding-bottom:15px;}
/*-------------------------------------------------
HEADER CLASSES
-------------------------------------------------*/
.header-wrap{ background:#083266; height:162px; width: 960; }
.header{ width:1200px; margin:0 auto; z-index: 11;}
.logo{ float:left; background:#1491c1; width:300px; }
.logo h1{font-size:25px; text-align:left; padding:40px 0px 36px 25px ;
}
.menu ul #listcontain{ list-style:none; float: left; border-right:#093e76 solid 1px; padding: 0px 20px 30px 20px; }
.menu ul #listcontain a{ text-decoration:none; color:#80d2f8; font- size:14px; text-align:center;padding-right: 5px;}
.menu ul #listcontain a:hover{ color:#1491c1;}
.menu ul #listcontain a.active{ color:#1491c1;}
* {
box-sizing: border-box;
}
#main {
position: relative;
list-style: none;
background: #083266;
font-weight: 400;
font-size: 0;
text-transform: none;
display: inline-block;
padding: 118px 0px 0px 0px;
margin: 0 auto;
}
#main li {
color: #ffffff;
font-size: 0.8rem;
display: inline-block;
position: relative;
padding: 13px 20px;
cursor: pointer;
z-index: 5;
min-width: 120px;
}
li {
margin: 0;
}
#marker {
height: 6px;
background: #1491c1 !important;
position: absolute;
bottom: 0;
width: 120px;
z-index: 2;
-webkit-transition: all 0.35s;
-moz-transition: all 0.35s;
-ms-transition: all 0.35s;
transition: all 0.35s;
}
#main li:nth-child(1):hover ul div {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
#main li:nth-child(1):hover ~ #marker {
-webkit-transform: translate(0px, 0);
-moz-transform: translate(0px, 0);
-ms-transform: translate(0px, 0);
transform: translate(0px, 0);
}
#main li:nth-child(2):hover ul div {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
#main li:nth-child(2):hover ~ #marker {
-webkit-transform: translate(130px, 0);
-moz-transform: translate(130px, 0);
-ms-transform: translate(130px, 0);
transform: translate(133px, 0);
}
#main li:nth-child(3):hover ul div {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
#main li:nth-child(3):hover ~ #marker {
-webkit-transform: translate(260px, 0);
-moz-transform: translate(260px, 0);
-ms-transform: translate(260px, 0);
transform: translate(269px, 0);
}
#main li:nth-child(4):hover ul div {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
#main li:nth-child(4):hover ~ #marker {
-webkit-transform: translate(360px, 0);
-moz-transform: translate(380px, 0);
-ms-transform: translate(360px, 0);
transform: translate(397px, 0);
}
#main li:nth-child(5):hover ul div {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
#main li:nth-child(5):hover ~ #marker {
-webkit-transform: translate(360px, 0);
-moz-transform: translate(380px, 0);
-ms-transform: translate(360px, 0);
transform: translate(529px, 0);
}
#drops {
overflow: hidden;
list-style: none;
position: absolute;
padding: 0;
width: 100%;
left: 0;
top: 58px;
}
#drops div {
-webkit-transform: translate(0, -100%);
-moz-transform: translate(0, -100%);
-ms-transform: translate(0, -100%);
transform: translate(0, -100%);
-webkit-transition: all 0.5s 0.1s;
-moz-transition: all 0.5s 0.1s;
-ms-transition: all 0.5s 0.1s;
transition: all 0.5s 0.1s;
position: relative;
}
#drops li {
display: block;;
padding: 0;
width: 100%;
background: #3E8760 !important;
z-index: 10;
}
<link href='http://fonts.googleapis.com/css?family=Droid+Serif' rel="stylesheet" type="text/css">
<nav>
<div class="wrap">
<div class="header">
<div class="logo"><h1>JHT Market Development Team (MDT) Site</h1></div>
<div class="menu" id="main">
<ul>
<li id="listcontain">Home</li>
<li id="listcontain">MDT Resources
<ul class="drop" id="drops">
<div>
<li>MDT Calender</li>
<li>MDT Agendas</li>
<li>Meeting Materials</li>
</div>
</ul>
<li id="listcontain">Proposals </li>
<li id="listcontain"> CSO Priorities </li>
<li id="listcontain">Contact MDT</li>
<div id="marker"></div>
</ul>
</div>
</div>
</div>
</nav>
I believe the problem lies somewhere in one of the general classes but I can't figure out how to fix it without screwing up the whole page.

I'm guessing that since the DOM for the menu comes before the body the absolute positioning is causing the main content to stack on top.
Imagine two divs right next to each other, and the first one is given absolute positioning. The second div would show up over the first, because that's just how DOM renders.
As #will stated in his comment, adding a z-index is probably the best route to take here.

This cause because you giving to .wrap class overflow:hidden; so if you removed it the submenu will appear, Or if you add some content after .header the menu also will appear in this case

Change the z-index to z-index 1 for the menu and z-index 0 for the rest of the page. I think that that will work...

Related

How to create a circular spinning navigation bar

I am having problems creating a Navigation bar that can spin in a circle in CSS3 and HTML. How can I do this? Below is a picture of the idea from an old game. I want the same animation type that it uses. When it is on the active circle, the page is shown. As you move left and right, the page will change. Is there a way to accomplish this? How can I create this in CSS3 and HTML5.
I have added a code snippet of what I have done so far as a basic idea. I need two buttons that would allow the animation to move left or right instead of 1,2,3,4.
The idea comes from SliderDock. A dock for Windows and MacOS.
CSS3 should be able to accomplish this task if i'm not mistaken.
http://img05.deviantart.net/d13f/i/2011/139/7/4/altimit_mine_os_by_tenshi_no_chi-d3gowsq.png
* {
margin: 0;
padding: 0;
-webkit-backface-visibility: hidden;
}
/*HEADER*/
.header {
height: 25px;
background: #222;
color: #eee;
text-align: center;
font: 10px/25px Helvetica, Verdana, sans-serif;
}
.header a {
color: #999;
}
/*WRAPPER*/
.wrapper {
position: relative;
overflow: hidden;
margin: 20px auto;
width: 370px;
}
.menu a {
margin-right: -4px;
padding: 10px 30px;
width: 50px;
color: #333;
text-decoration: none;
font: 15px/25px Helvetica, Arial, sans-serif;
}
.menu a:hover {
background: #eee;
}
/*INNER CIRCLE*/
.wrapper:before {
content: "Menu";
text-align: center;
font: 30px/120px Georgia, Times, serif;
color: #black;
position: absolute;
top: 140px;
left: 110px;
z-index: 10;
width: 130px;
height: 130px;
border-radius: 50%;
background: #fff;
-webkit-box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.3);
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.3);
}
/*MAIN CIRCLE*/
.circle {
position: relative;
margin-top: 30px;
margin-bottom: 20px;
margin-left: 25px;
width: 300px;
height: 300px;
border-radius: 50%;
background: #white;
box-shadow: inset 0px 0px 30px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: inset 0px 0px 30px rgba(0, 0, 0, 0.3);
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
/*LITTLE CIRCLES*/
.circle li {
position: absolute;
width: 50px;
height: 50px;
border-radius: 50%;
background: white;
list-style-type: none;
text-align: center;
font: 20px/50px Helvetica, Arial, sans-serif;
top: 0;
left: 0;
}
.circle li:nth-child(1) {
top: 15px;
left: 125px;
}
.circle li:nth-child(2) {
top: 125px;
left: 235px;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
}
.circle li:nth-child(3) {
top: 235px;
left: 125px;
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
}
.circle li:nth-child(4) {
top: 125px;
left: 15px;
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
}
/*HOVER STATES*/
.menu > .one:hover ~ .circle {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
.menu > .two:hover ~ .circle {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
}
.menu > .three:hover ~ .circle {
-webkit-transform: rotate(-180deg);
-moz-transform: rotate(-180deg);
-ms-transform: rotate(-180deg);
-o-transform: rotate(-180deg);
transform: rotate(-180deg);
}
.menu > .four:hover ~ .circle {
-webkit-transform: rotate(-270deg);
-moz-transform: rotate(-270deg);
-ms-transform: rotate(-270deg);
-o-transform: rotate(-270deg);
transform: rotate(-270deg);
}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name="description" content="description">
<title>Nav Menu</title>
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
</head>
<body>
<div class="header"></div>
<div class="wrapper">
<div class="menu">
1
2
3
4
<div class="circle">
<ul>
<li>Home</li>
<li>World</li>
<li>Games</li>
<li>AboutUs</li>
</ul>
</div>
</div>
</div>
</body>
</html>
you can do it with CSS3 also. To do this use animation rotate on hover of that numbers and rotate the menu image.
you can do it by using javascript with onmousehover and onmouseleave event.

Need help making h1 appear over-top of image

I've got a few lines of type set in a stylized h1 (type is skewed, underlined with border, etc). I'd like the h1 to appear over the top of the "bg-image" div class, but I'm having trouble. I'm new to using DIV structure.
.bg-image h1 {
display:inline-block;
font-size:48px;
font-family: "sofia-pro",sans-serif;
font-weight:900;
text-transform:uppercase;
color:#fff;
border-bottom:7px solid #fff;
padding-bottom:5px;
margin-top:4px;
-webkit-transform: rotate(-15deg) skew(-15deg, 0);
-moz-transform: rotate(-15deg) skew(-15deg, 0);
-ms-transform: rotate(-15deg) skew(-15deg, 0);
-o-transform: rotate(-15deg) skew(-15deg, 0);
transform: rotate(-15deg) skew(-15deg, 0);
text-transform: uppercase;
}
.bg-image {
position: relative;
}
.bg-image img {
display: block;
width: 100%;
background-size:cover;
max-width: 2000px; /* corresponds to max height of 450px */
margin: 0 auto;
}
<div class="bg-image">
<img src="http://s27.postimg.org/h12ymqn9v/Web_Hdr_Bground_1.jpg">
<h1>Nobody</h1>
<br>
<h1>Ever Says</h1>
<br>
<h1>Seize</h1>
<br>
<h1 class="skewed">Tomorrow.</h1>
</div>
You can use background-image on .bg-image class so you have more control.
Like this:
.bg-image h1 {
display:inline-block;
font-size:48px;
font-family: "sofia-pro",sans-serif;
font-weight:900;
text-transform:uppercase;
color:#fff;
border-bottom:7px solid #fff;
padding-bottom:5px;
margin-top:4px;
-webkit-transform: rotate(-15deg) skew(-15deg, 0);
-moz-transform: rotate(-15deg) skew(-15deg, 0);
-ms-transform: rotate(-15deg) skew(-15deg, 0);
-o-transform: rotate(-15deg) skew(-15deg, 0);
transform: rotate(-15deg) skew(-15deg, 0);
text-transform: uppercase;
}
.bg-image {
position: relative;
width: 500px;
height: 500px;
background: url('http://s27.postimg.org/h12ymqn9v/Web_Hdr_Bground_1.jpg') center;
background-size: cover;
}
<div class="bg-image">
<h1>Nobody</h1>
<br>
<h1>Ever Says</h1>
<br>
<h1>Seize</h1>
<br>
<h1 class="skewed">Tomorrow.</h1>
</div>
You have to play with position: relative and the distance in pixels you feel like for h1 to achieve your desired result. I just tried adding position: relative; and top: -450px;
.bg-image h1 {
display:inline-block;
font-size:48px;
font-family: "sofia-pro",sans-serif;
font-weight:900;
text-transform:uppercase;
color:#fff;
border-bottom:7px solid #fff;
padding-bottom:5px;
margin-top:4px;
-webkit-transform: rotate(-15deg) skew(-15deg, 0);
-moz-transform: rotate(-15deg) skew(-15deg, 0);
-ms-transform: rotate(-15deg) skew(-15deg, 0);
-o-transform: rotate(-15deg) skew(-15deg, 0);
transform: rotate(-15deg) skew(-15deg, 0);
text-transform: uppercase;
position: relative;
top: -450px;
}
.bg-image {
position: relative;
}
.bg-image img {
display: block;
width: 100%;
background-size:cover;
max-width: 2000px; /* corresponds to max height of 450px */
margin: 0 auto;
}
<div class="bg-image">
<img src="http://s27.postimg.org/h12ymqn9v/Web_Hdr_Bground_1.jpg">
<h1>Nobody</h1>
<br>
<h1>Ever Says</h1>
<br>
<h1>Seize</h1>
<br>
<h1 class="skewed">Tomorrow.</h1>
</div>
I am new to code and just saw this question. Have you tried the z-index? The z-index controls the z axis (up and down) of the webpage. Try putting z-index: -1 on css to make sure the picture will appear under the text on the webpage. Hope this helped!

Responsive Hexagon grid with a border

http://codepen.io/web-tiki/pen/HhCyd
I am working using the above pen from a similar question. I was able to edit the size of the hexagon editing the width property and padding but I wanted to add a border to the hexagon, I was able to the left and right of the hexagon by adding a border and editing the box-sizing of the category li div element but was not able to get it for the other sides of the hexagon by editing the category li element.
body{
font-family: 'Open Sans', arial, sans-serif;
background:rgb(0, 0, 0);
}
*{
margin:0;
padding:0;
}
#categories{
overflow:hidden;
width:90%;
margin:0 auto;
}
.clr:after{
content:"";
display:block;
clear:both;
}
#categories li{
position:relative;
border-style: solid;
border-width:10px;
list-style-type:none;
width:27.85714285714286%; /* = (100-2.5) / 3.5 */
padding-bottom: 32.16760145166612%; /* = width /0.866 */
float:left;
overflow:hidden;
visibility:hidden;
-webkit-transform: rotate(-60deg) skewY(30deg);
-ms-transform: rotate(-60deg) skewY(30deg);
transform: rotate(-60deg) skewY(30deg);
}
#categories li:nth-child(3n+2){
margin:0 1%;
}
#categories li:nth-child(6n+4){
margin-left:0.5%;
}
#categories li:nth-child(6n+4), #categories li:nth-child(6n+5), #categories li:nth-child(6n+6) {
margin-top: -6.9285714285%;
margin-bottom: -6.9285714285%;
-webkit-transform: translateX(50%) rotate(-60deg) skewY(30deg);
-ms-transform: translateX(50%) rotate(-60deg) skewY(30deg);
transform: translateX(50%) rotate(-60deg) skewY(30deg);
}
#categories li:nth-child(6n+4):last-child, #categories li:nth-child(6n+5):last-child, #categories li:nth-child(6n+6):last-child{
margin-bottom:0%;
}
#categories li *{
position:absolute;
visibility:visible;
}
#categories li > div{
border-style: solid;
border-width: 5px;
box-sizing:border-box;
width:100%;
height:100%;
text-align:center;
color:#fff;
overflow:hidden;
-webkit-transform: skewY(-30deg) rotate(60deg);
-ms-transform: skewY(-30deg) rotate(60deg);
transform: skewY(-30deg) rotate(60deg);
-webkit-backface-visibility:hidden;
}
/* HEX CONTENT */
#categories li img{
left:-100%; right:-100%;
width: auto; height:100%;
margin:0 auto;
}
#categories div h1, #categories div p{
width:90%;
padding:0 5%;
background-color:#008080; background-color: rgba(0, 128, 128, 0.8);
font-family: 'Raleway', sans-serif;
-webkit-transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
-ms-transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
}
#categories li h1{
bottom:110%;
font-style:italic;
font-weight:normal;
font-size:1.5em;
padding-top:100%;
padding-bottom:100%;
}
#categories li h1:after{
content:'';
display:block;
position:absolute;
bottom:-1px; left:45%;
width:10%;
text-align:center;
z-index:1;
border-bottom:2px solid #fff;
}
#categories li p{
padding-top:50%;
top:110%;
padding-bottom:50%;
}
/* HOVER EFFECT */
#categories li div:hover h1 {
bottom:50%;
padding-bottom:10%;
}
#categories li div:hover p{
top:50%;
padding-top:10%;
}
This worked pretty well for me, hope it will be helpful for you as well.
<div class="hexagon"></div>
.hexagon {
position: relative;
width: 300px;
height: 173.21px;
background-color: #64C7CC;
margin: 86.60px 0;
border-left: solid 5px #333333;
border-right: solid 5px #333333;
}
.hexagon:before,
.hexagon:after {
content: "";
position: absolute;
z-index: 1;
width: 212.13px;
height: 212.13px;
-webkit-transform: scaleY(0.5774) rotate(-45deg);
-ms-transform: scaleY(0.5774) rotate(-45deg);
transform: scaleY(0.5774) rotate(-45deg);
background-color: inherit;
left: 38.9340px;
}
.hexagon:before {
top: -106.0660px;
border-top: solid 7.0711px #333333;
border-right: solid 7.0711px #333333;
}
.hexagon:after {
bottom: -106.0660px;
border-bottom: solid 7.0711px #333333;
border-left: solid 7.0711px #333333;
}
For image inside hexagon use this:
<div class="hexagon">
<div class="hexTop"></div>
<div class="hexBottom"></div>
</div>
.hexagon {
position: relative;
width: 300px;
height: 173.21px;
margin: 86.60px 0;
background-image: url(http://you_image_url.jpg);
background-size: auto 334.8632px;
background-position: center;
border-left: solid 5px #333333;
border-right: solid 5px #333333;
}
.hexTop,
.hexBottom {
position: absolute;
z-index: 1;
width: 212.13px;
height: 212.13px;
overflow: hidden;
-webkit-transform: scaleY(0.5774) rotate(-45deg);
-ms-transform: scaleY(0.5774) rotate(-45deg);
transform: scaleY(0.5774) rotate(-45deg);
background: inherit;
left: 38.93px;
}
/*counter transform the bg image on the caps*/
.hexTop:after,
.hexBottom:after {
content: "";
position: absolute;
width: 290.0000px;
height: 167.4315780649915px;
-webkit-transform: rotate(45deg) scaleY(1.7321) translateY(-83.7158px);
-ms-transform: rotate(45deg) scaleY(1.7321) translateY(-83.7158px);
transform: rotate(45deg) scaleY(1.7321) translateY(-83.7158px);
-webkit-transform-origin: 0 0;
-ms-transform-origin: 0 0;
transform-origin: 0 0;
background: inherit;
}
.hexTop {
top: -106.0660px;
border-top: solid 7.0711px #333333;
border-right: solid 7.0711px #333333;
}
.hexTop:after {
background-position: center top;
}
.hexBottom {
bottom: -106.0660px;
border-bottom: solid 7.0711px #333333;
border-left: solid 7.0711px #333333;
}
.hexBottom:after {
background-position: center bottom;
}
.hexagon:after {
content: "";
position: absolute;
top: 2.8868px;
left: 0;
width: 290.0000px;
height: 167.4316px;
z-index: 2;
background: inherit;
}

CSS: Stop parent element flash when using pseudo elements

I'm trying to create a basic hover transition using pseudo elements. The transition works fine, but the element "flashes" when it begins.
Any idea on how to get around the transition flash?
Issue recreated in a codepen.
I've tried using -webkit-backface-visibility to hidden to solve the issue. It stops the flash but it hides the ::before pseudo element from view.
html:
<a href="#">
<div class="cl">
<img src="http://placekitten.com/200/200" alt="" />
<span>meoww!</span>
</div>
</a>
CSS:
*,
*:after,
*::before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-family: 'Raleway', sans-serif;
}
div {position:relative;}
span{
position:absolute;
left:0;
right: 0;
bottom:50%;
color: black;
text-align:center;
}
a {
position: relative;
display: inline-block;
margin: 15px 25px;
outline: none;
color: #fff;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 1px;
font-weight: 400;
text-shadow: 0 0 1px rgba(255,255,255,0.3);
font-size: 1.35em;
}
a:hover, a:focus {
outline: none;
}
.cl {
padding: 0 20px;
line-height: 0;
}
.cl::before,
.cl::after {
position: absolute;
width: 45px;
height: 2px;
background: #fff;
content: '';
opacity: 0.2;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
pointer-events: none;
}
.cl::before {
top: 0;
left: 0;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
transform: rotate(90deg);
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
transform-origin: 0 0;
}
.cl::after {
right: 0;
bottom: 0;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
transform: rotate(90deg);
-webkit-transform-origin: 100% 0;
-moz-transform-origin: 100% 0;
transform-origin: 100% 0;
}
.cl:hover::before,
.cl:hover::after,
.cl:focus::before,
.cl:focus::after {
opacity: 1;
}
.cl:hover::before,
.cl:focus::before {
left: 50%;
-webkit-transform: rotate(0deg) translateX(-50%) translateY(75px);
-moz-transform: rotate(0deg) translateX(-50%) translateY(75px);
transform: rotate(0deg) translateX(-50%) translateY(75px);
}
.cl:hover::after,
.cl:focus::after {
right: 50%;
-webkit-transform: rotate(0deg) translateX(50%) translateY(-75px);
-moz-transform: rotate(0deg) translateX(50%) translateY(-75px);
transform: rotate(0deg) translateX(50%) translateY(-75px);
}
.cl {
-webkit-backface-visibility: hidden;
padding: 0 20px;
}
http://codepen.io/agconti/pen/xaqKm

CSS Folding Paper Like Menu Issue

I'm trying to build a menu that would have a transition like paper folding, kinda like this one:
Live Test : http://www.cssplay.co.uk/menus/cssplay-3d-unfolding-menu.html
Here is my code:
HTML
<nav>
<li class="hov">Hover Me!
<ul class="main">
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
</ul>
</li>
</nav>
CSS
nav{
}
ul,li{
margin: 0;
padding: 0;
}
.main{
position:absolute;
z-index:1;
}
.main li{
list-style:none;
background: blue;
width:100px;
padding: 0 5px;
border: 1px solid black;
height: 30px;
line-height: 30px;
/*margin-top: -30px;*/
-webkit-transition: all .5s ease-in-out;
}
.main li:nth-child(odd){
-webkit-transform-origin: top;
-webkit-transform: perspective(350px) rotateX(-90deg);
}
.main li:nth-child(even){
-webkit-transform-origin: bottom;
-webkit-transform: perspective(350px) rotateX(90deg);
}
.main {
-webkit-transition: all .5s ease-in-out;
-webkit-transform-origin: 50% 0%;
-webkit-transform: perspective(350px) rotateX(-90deg);
}
.hov:hover .main {
-webkit-transform-origin: top;
-webkit-transform: perspective(350px) rotateX(0deg);
}
.hov:hover li:nth-child(odd){
-webkit-transform-origin: top;
-webkit-transform: perspective(350px) rotateX(0deg);
margin-top:0;
}
.hov:hover li:nth-child(even){
-webkit-transform-origin: bottom;
-webkit-transform: perspective(350px) rotateX(0deg);
margin-top:0;
}
.main li:first-child{
margin-top:0;
}
.hov{
position:relative;
height: 40px;
width:112px;
background: green;
color: white;
font-size: 13px;
font-family: Helvetica;
font-weight:bold;
text-align: center;
line-height: 40px;
list-style:none;
z-index:2;
}
Live DEMO
http://codepen.io/razvan-tudosa/pen/BxgJl
Question :
How can I make the sub-menus stick together as in the example?
He want to stik the sub menus.
For doing that edit these css class like down here:
.main li:nth-child(even){
margin-top:-65px;
-webkit-transform-origin: bottom;
-webkit-transform: perspective(350px) rotateX(90deg);
}
.hov:hover li:nth-child(odd){
-webkit-transform-origin: top;
-webkit-transform: perspective(30px) rotateX(0deg);
margin-top:0;
}
.hov:hover li:nth-child(even){
-webkit-transform-origin: bottom;
-webkit-transform: perspective(30px) rotateX(0deg);
margin-top:0;
}
And then it seem really close to the other effect.
UPDATE:
The example here.
nav{
}
ul,li{
margin: 0;
padding: 0;
}
.main{
position:absolute;
z-index:1;
}
.main li{
list-style:none;
background: blue;
width:100px;
padding: 0 5px;
border: 1px solid black;
height: 30px;
line-height: 30px;
/*margin-top: -30px;*/
-webkit-transition: all .5s ease-in-out;
}
.main li:nth-child(odd){
-webkit-transform-origin: top;
-webkit-transform: perspective(350px) rotateX(-90deg);
}
.main li:nth-child(even){
margin-top:-65px;
-webkit-transform-origin: bottom;
-webkit-transform: perspective(350px) rotateX(90deg);
}
.main {
-webkit-transition: all .5s ease-in-out;
-webkit-transform-origin: 50% 0%;
-webkit-transform: perspective(350px) rotateX(-90deg);
}
.hov:hover .main {
-webkit-transform-origin: top;
-webkit-transform: perspective(350px) rotateX(0deg);
}
.hov:hover li:nth-child(odd){
-webkit-transform-origin: top;
-webkit-transform: perspective(30px) rotateX(0deg);
margin-top:0;
}
.hov:hover li:nth-child(even){
-webkit-transform-origin: bottom;
-webkit-transform: perspective(30px) rotateX(0deg);
margin-top:0;
}
.main li:first-child{
margin-top:0;
}
.hov{
position:relative;
height: 40px;
width:112px;
background: green;
color: white;
font-size: 13px;
font-family: Helvetica;
font-weight:bold;
text-align: center;
line-height: 40px;
list-style:none;
z-index:2;
}
<nav>
<li class="hov">Hover Me!
<ul class="main">
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
</ul>
</li>
</nav>