Css Transition For My Home Made Nav - css

I have created a nav menu myself for my website, I'm no expert but I think the menu turned out great ... I would like for my the menus to open a little slower then instant, maybe have a .5s transition ... I have tried to implement myself but I just don't seem to be able to figure it out .... I have created a jsfiddle to show my nav bar ... I was hoping to someone could show me how to had a transition to all the drop down menus if its possible ... Thank You
jsfiddle : http://jsfiddle.net/vRdEp/ (its a little broken on here)
my site : www.curious-howto.com
My css:
ul#navitemul {
border-radius: 0px 20px 20px 20px;
margin:0px!important;
width:500px;
}
.belownav {
top:0px;
left:183px;
position:absolute;
z-index:100;
box-shadow: 0 0 10px #000 inset;
border-radius: 5px 0px 0px 5px;
padding:20px!important;
background:#282828!important;
}
.navitem a {
margin-right: 10px;
border: 1px solid #424242!important;
text-overflow:ellipsis;
display:block;
overflow:hidden;
border-radius:5px;
width:200px!important;
padding:0px!important;
float:left;
height:40px;
background:#424242!important;
}
.navitem a:hover {
border:1px solid #585858!important;
background:#000!important;
}
img.fl {
float:left;
}
span.marleft {
letter-spacing:1px;
font-size:12px!important;
text-decoration:none;
color:white!important;
margin-left:15px!important;
line-height:38px;
}
li.marright{
float:left!important;
margin-bottom:10px!important;
margin-right:10px!important;
}
.ontop{
color:white;
font-size:28px!important;
margin-bottom:20px!important
}
ul#loginmenu {
border-radius:0px 0px 30px 30px;
z-index:1000;
left:200px;
width:500px!important;
overflow:auto;
max-height:600px;
left:-100px!important;
}
li.logo {
margin:0px!important;
line-height:10px!important;
border-radius: 30px 0px 0px 0px;
padding:10px 40px 10px 40px!important
}
span#navlogo {
font-size:20px;
}
#menu{
position:relative;
top:10px;
width:80%;
max-width:750px;
min-width:660px;
height:47px;
border-radius: 30px 30px 0px 0px;
background-color:#172322;
margin:0px;
padding:0px;
list-style:none;
color:#fff;
display:inline-block;
float:right;
z-index:1000;
}
#menu a {
color:#fff;
text-decoration:none;
}
#menu > li {
transition:width 2s, height 2s;
-webkit-transition:width 2s, height 2s, -webkit-transform 2s;
/* Safari */padding: 13px 0px;
background:#172322 none repeat scroll 0 0;
cursor:pointer;
float:left;
position:relative;
}
#menu > li a:hover {
color:#B0D730;
}
#menu .logo {
background-color: #7cb7e3;
width:87px;
padding:0px;
}
/* sub-menus*/
#menu ul {
padding:0px;
margin:0px;
display:block;
display:inline;
}
#menu li ul {
position:absolute;
left:-24px;
top:0px;
margin-top:45px;
line-height:16px;
background-color:#172322;
color:#0395CC;
/* for IE */ display:none;
}
#menu li:hover ul {
display:block;
}
#menu li ul li{
display:block;
margin:5px 20px;
padding: 5px 0px;
list-style-type:none;
}
#menu li ul li:first-child {
border-top: none;
}
#menu li ul li a {
display:block;
color:#0395CC;
}
#menu li ul li a:hover {
color:#7FCDFE;
}
/* main submenu */
#menu #main li {
text-align:center;
margin:10px 10px 10px 10px!important
}
#menu #main {
border-radius: 0px 0px 30px 30px;
width:167px;
left:0px;
top:-20px;
padding-top:20px;
background-color:#7cb7e3;
color:#fff;
z-index:999;
}
/* search */
.searchContainer div {
background-color:#fff;
display:inline;
padding:5px;
}
.searchContainer input[type="text"] {
border:none;
}
.searchContainer ul {
vertical-align:middle;
}

The problem is that transitions animate a property when that property changes. For example, if I had a div that was 100px wide, then added a class to it that switched it to be 300px wide, you could set transition: width 3s and it would grow over that 3 second period.
In your case, all that's changing is display:block / display:hidden
To get it to transition, you'll need to change things so that, rather than hiding it with display:hidden, you're hiding it by shrinking it to be really tiny and growing, or changing the opacity, etc.

Related

Wordpress menu center aligned and spaced evenly

I need some help regarding my menu arrangement. I'm using Wordpress on my site, with Vantage theme of which I even bought the premium theme.
My problem is the following: I'd like to make my menu items centered, spaced evenly, and I can't seem to achieve that without messing up my sub-menus.
Here's what I tried so far, without success:
https://stackoverflow.com/a/14103766/3990536
http://icode4you.net/wordpress-tricks-create-an-automatically-centered-and-evenly-spaced-navigation-menu/
https://stackoverflow.com/a/16274725/3990536
The codes actually work; my menu gets aligned niceley, but it also affects my sub-menus, I assume because they use the same class. I can't seem to figure out how to define new class for them, or separate the sub-menu from the actual main menu.
The thing I don't understand here, is the connection between my sub-menus and the main menu. If I edit .main-navigation li, my sub-menu is affected as well, even tough there should be a separate li for my main and my sub menu.
My site is the following: http://classwebdesign.hu/testing/
My menu's css looks like this:
/* =Menu
----------------------------------------------- */
.main-navigation{
margin:0 -35px;
background:#343538;
font-size:1em;
position:relative;
text-transform:uppercase;
letter-spacing: 0.08em;
/* Font awesome icons */
/* General menu link styling */
/* For when the menu becomes a sticky menu */
}
.main-navigation [class^="icon-"]{
display:inline-block;
margin-right:15px;
font-size:16px;
line-height:0.5em;
color:#CCCCCC;
}
.main-navigation a:hover [class^="icon-"]{
color:#FFFFFF;
}
.main-navigation ul{
list-style:none;
margin:0;
padding-left:0;
zoom:1;
/* Second level menu items */
}
.main-navigation ul:before{
content:'';
display:block;
}
.main-navigation ul:after{
content:'';
display:table;
clear:both;
}
.main-navigation ul li{
display:block;
position:relative;
float:left;
}
.main-navigation ul li:hover > a{
background:#00bcff;
color:#FFFFFF;
}
.main-navigation ul li a{
padding:20px 35px;
-ms-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
}
.main-navigation ul li a,.main-navigation ul li a > *{
-webkit-transition:all 0.4s ease;
-moz-transition:all 0.4s ease;
-o-transition:all 0.4s ease;
transition:all 0.4s ease;
}
.main-navigation ul ul{
-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.15);
-moz-box-shadow:0 1px 2px rgba(0,0,0,0.15);
box-shadow:0 1px 2px rgba(0,0,0,0.15);
background:#464646;
display:none;
position:absolute;
top:100%;
left:0;
z-index:99999;
/* Third Level Items */
}
.main-navigation ul ul a{
width:200px;
padding:15px 20px;
}
.main-navigation ul ul li{
position:relative;
/* Hovering over 2nd level items */
}
.main-navigation ul ul li:hover > a{
background:#00bcff;
color:#FFFFFF;
}
.main-navigation ul ul ul{
left:100%;
top:0;
margin-left:0;
}
.main-navigation ul li:hover > ul{
display:block;
}
.main-navigation a{
display:block;
text-decoration:none;
color:#e2e2e2;
font-weight:bold;
}
.main-navigation.sticky{
-webkit-box-shadow:0 2px 1px rgba(0,0,0,0.15);
-moz-box-shadow:0 2px 1px rgba(0,0,0,0.15);
box-shadow:0 2px 1px rgba(0,0,0,0.15);
}
body.has-menu-search .main-navigation ul{
margin-right:59px;
}
/* Handle the navigation slightly differently on mobile devices */
body.mobile-device .main-navigation ul ul{
display:none;
}
body.mobile-device .main-navigation li:hover > ul{
display:block;
}
.mobile-nav-frame [class^="icon-"]{
display:inline-block;
margin-right:10px;
min-width:1em;
}
.mobile-nav-icon{
font-family:'FontAwesome';
display:inline-block;
margin-right:10px;
}
.mobile-nav-icon:before{
font-size:14px;
content:"\f00b";
}
#search-icon{
position:absolute;
top:0;
right:0;
height:100%;
}
#search-icon #search-icon-icon{
-ms-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
position:relative;
display:block;
cursor:pointer;
background-color:#303134;
width:59px;
height:100%;
}
#search-icon #search-icon-icon,#search-icon #search-icon-icon .icon-search{
-webkit-transition:all 0.4s ease;
-moz-transition:all 0.4s ease;
-o-transition:all 0.4s ease;
transition:all 0.4s ease;
}
#search-icon #search-icon-icon .icon{
position:absolute;
display:block;
width:17px;
height:17px;
top:50%;
left:50%;
margin-top:-8px;
margin-left:-8.5px;
background: url('images/sprites-1-2.png') no-repeat -102px 0;
}
#search-icon #search-icon-icon:hover{
background-color:#00bcff;
}
#search-icon #search-icon-icon:hover .icon{
background: url('images/sprites-1-2.png') no-repeat 0 0;
}
#media screen and (-webkit-min-device-pixel-ratio: 2) {
#search-icon #search-icon-icon .icon{
background: url(images/retina/search-icon.png) no-repeat;
background-size:17px 17px;
}
#search-icon #search-icon-icon:hover .icon{
background: url(images/retina/search-icon-white.png) no-repeat;
background-size:17px 17px;
}
}
#search-icon .searchform{
display:none;
position:absolute;
top:100%;
right:0;
width:1080px;
background:#2d2e31;
z-index:10;
overflow-x:hidden;
}
#search-icon .searchform input[name=s]{
color:#d1d1d1;
font-size:17px;
font-weight:200;
-ms-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
display:block;
width:100%;
height:42px;
border:none;
-webkit-border-radius:0px;
-moz-border-radius:0px;
border-radius:0px;
background:transparent;
outline:none;
padding:0 15px;
}
Thanks for your help in advance!
EDIT: With the answer below I was able to align them centered, but they are not evenly spaced which would be very important for me as well. Thanks!
Have a look at answers like this on on the site;
Align center menu within div
It's a simple way of achieving what you want without messing your sub-menus. Remove the float from the li and set their display property to inline-block. Then set text-align: center on the parent ul;
.main-navigation ul {
list-style: none;
margin: 0;
padding-left: 0;
zoom: 1;
text-align: center;
}
.main-navigation ul li {
display: block;
position: relative;
/* float: left; */
display: inline-block;
}

CSS li.before circle within coloured box just as li text

I might be going about this the wrong way, but what I'm trying to achieve is a list style horizental that links in with some js that changes the navigation from one tab to another. The tab headings should have a counter before the text within a css circle using radius and I've got this far.
What I can't seem to resolve is how to then place this circle within a box the same colour as the li text background and ensure it changes colour when hovered/selected.
Here's my code so far:
OL.evotab {
counter-reset:li;
list-style: none;
float:left;
width:100%;
padding:0px;
}
OL.evotab LI {
list-style:none;
position:relative;
display: inline;
float:left;
margin:0 0 6px 2em;
padding:4px 8px;
}
ol.evotab > li:before {
content:counter(li); /* Use the counter as content */
counter-increment:li; /* Increment the counter by 1 */
/* Position and style the number */
position:absolute;
top:-2px;
left:-2em;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
width:2em;
/* Some space between the number and the content in browsers that support
generated content but not positioning it (Camino 2 is one example) */
margin-right:8px;
padding:4px;
border-radius:50%;
color:#fff;
background:#666;
font-weight:bold;
font-family:"Helvetica Neue", Arial, sans-serif;
text-align:center;
}
OL.evotab LI A {
background-color: #f8f8f8;
color: #28343d;
text-decoration: none;
padding-top: 30px;
padding-left:20px;
padding-right:20px;
padding-bottom:30px;
border-bottom:5px solid #dfdfdf;
}
OL.evotab LI A.selected,
OL.evotab LI A:hover {
background-color: #f8f8f8;
color: #e51f38;
padding-top: 30px;
padding-bottom:30px;
border-bottom: 5px solid #e51f38;
}
OL.evotab LI A:focus {
outline: 0;
}
FIDDLE
Its a little difficult to see what you mean without any HTML....but have a look at the fiddle linked for an idea.
HTML
<a href='#'>This is an Item</a>
CSS:
a {
background:grey;
border:1px solid black;
display:inline-block;
padding:20px;
color:white;
text-decoration:none;
position:relative;
}
a:before {
content:'7';
color:black;
position:absolute;
display:inline-block;
background:yellow;
border:1px solid black;
border-radius: 999px;
left:-5px;
width:20px;
text-align:center;
line-height:20px;
height:20px;
}
a:hover, a:hover:before {
color:red;
}

vertical gap on menu without using jquery

I was wondering how, in this example, it is possible to have a gap between the menu item and the list.
This is the CSS code for the demo
#colorNav > ul{
width: 450px; /* Increase when adding more menu items */
margin:0 auto;
}
#colorNav > ul > li{ /* will style only the top level li */
list-style: none;
box-shadow: 0 0 10px rgba(100, 100, 100, 0.2) inset,1px 1px 1px #CCC;
display: inline-block;
line-height: 1;
margin: 1px;
border-radius: 3px;
position:relative;
}
#colorNav > ul > li > a{
color:inherit;
text-decoration:none !important;
font-size:24px;
padding: 25px;
}
#colorNav li ul{
position:absolute;
list-style:none;
text-align:center;
width:180px;
left:50%;
margin-left:-90px;
top:70px;
font:bold 12px 'Open Sans Condensed', sans-serif;
/* This is important for the show/hide CSS animation */
max-height:0px;
overflow:hidden;
-webkit-transition:max-height 0.4s linear;
-moz-transition:max-height 0.4s linear;
transition:max-height 0.4s linear;
}
#colorNav li ul li{
background-color:#313131;
}
#colorNav li ul li a{
padding:12px;
color:#fff !important;
text-decoration:none !important;
display:block;
}
#colorNav li ul li:nth-child(odd){ /* zebra stripes */
background-color:#363636;
}
#colorNav li ul li:hover{
background-color:#444;
}
#colorNav li ul li:first-child{
border-radius:3px 3px 0 0;
margin-top:25px;
position:relative;
}
#colorNav li ul li:first-child:before{ /* the pointer tip */
content:'';
position:absolute;
width:1px;
height:1px;
border:5px solid transparent;
border-bottom-color:#313131;
left:50%;
top:-10px;
margin-left:-5px;
}
#colorNav li ul li:last-child{
border-bottom-left-radius:3px;
border-bottom-right-radius:3px;
}
/* This will trigger the CSS */
/* transition animation on hover */
#colorNav li:hover ul{
max-height:200px; /* Increase when adding more dropdown items */
}
Here is the link:
http://demo.tutorialzine.com/2012/10/css3-dropdown-menu/
#colorNav li ul li:first-child {
margin-top: 25px;
}
Is what is creating the gap.

Dropdown menu broken on IE9

I am building a website from a bought theme, and in FF and in Chrome it looks perfect.But,on IE9 in compatibility mode, i am having a big problem.
One menu item has dropdown, and on IE, that dropdown menu is moved bellow the next menu item, and it is very hard to click o it.I tried "playing" around with CSS navigation and menu setting, but no luck...
Can anyone help:
/* Mainmenu Styling */
#mainmenu{
width:680px;
margin:1px 0px 0px 0px;
float:left;
}
.navigation{
width:630px;
margin-top:38px;
padding-left:160px;
float:left;
list-style-type:none;
}
.navigation ul{
margin:0px;
padding:0px;
list-style-type:none;
position:left;
clear:both;
}
.navigation li{
list-style-type:none;
padding:0px;
margin:0px;
float:left;
z-index:100;
position:relative;
}
.navigation li a{
font-size:16px;
text-decoration:none;
color:#a7a6a6;
display:block;
padding:10px 30px 16px 8px;
float:left;
z-index:100;
margin-right:0px;
}
.navigation li.current a, .navigation li a:hover, .navigation li.current li a:hover{
text-decoration:none;
color: #d23a3b;
}
.navigation li.current li a{
text-decoration:none;
color:#a7a6a6;
}
.navigation li li{
margin:0 0 0px 0px;
padding:0px;
position:relative;
z-index:100;
}
.navigation ul{
display:none;
position:absolute;
top:45px;
width:159px;
padding-bottom:5px;
z-index:100;
background-color:#fafafa;
border-top:none;
border-bottom:1px solid #d3d3d3;
border-left:1px solid #d3d3d3;
border-right:1px solid #d3d3d3;
}
.navigation li ul a{
width:109px;
height:auto;
float:left;
padding:0px 15px 8px 15px;
font-size:14px;
color:#a7a6a6;
line-height:24px;
z-index:100;
text-decoration:none;
}
Link is : http://goo.gl/LHDtg
try the below css for desired IE version
.navigation ul {
background-color: #FAFAFA;
border-color: -moz-use-text-color #D3D3D3 #D3D3D3;
border-style: none solid solid;
border-width: medium 1px 1px;
display: none;
padding-bottom: 5px;
position: absolute;
top: 85px; /* in your website it is 45px but for IE i just tried 85px which work fine*/
width: 159px;
z-index: 100;
}
see image for demo: I tried it in IE8

div overlapping/misplaced

I have a footer on my page, where the content is placing correctly, under div#main (which includes div#left and div#right), but the background (the big blue thing) is placed way over div#main.
I have tried display:block and z-indexing the divs, to no avail.
Anyone have any idea what's going on?
Code:
body {
background:url(aaa-bg.jpg) repeat-x #e7e9e9;
margin:0;
padding:0;
color:#383838;
font:12pt verdana;
}
img {
border:0;
}
a:link {
color:#e29511;
text-decoration:none;
}
a:hover {
color:#e29511;
text-decoration:underline;
}
a:visited {
color:#808080;
}
/* header ------------------------------------------------------------------------------ */
#header {
margin:10px auto 10px;
width:800px;
height:97px;
}
/* nav ------------------------------------------------------------------------------ */
#nav {
width:800px;
margin:0px auto 3px;
height:30px;
}
#nav ul {
margin:0 0px 0px 0;
padding:0;
list-style:none;
}
#nav ul li {
width:140px;
height:20px;
padding:5px 0 5px 0;
float:left;
margin:0 10px 0 0;
background:#cdcdcd;
color:#000000;
position:relative;
z-index:99999;
text-align:center;
border-top-left-radius:10px;
border-top-right-radius:10px;
border-top:3px solid transparent;
border-left:3px solid transparent;
border-right:3px solid transparent;
}
#nav ul li:hover {
cursor:pointer;
border-top:3px solid #e29511;
border-left:3px solid #e29511;
border-right:3px solid #e29511;
}
#nav ul li.home {
width:140px;
height:20px;
padding:5px 0 5px 0;
float:left;
margin:0 10px 0 0;
background:#cdcdcd;
color:#000000;
position:relative;
z-index:99999;
text-align:center;
border-top-left-radius:10px;
border-top-right-radius:10px;
border-top:3px solid transparent;
border-left:3px solid transparent;
border-right:3px solid transparent;
}
#nav ul li.home:hover {
cursor:pointer;
-moz-box-shadow: 5px 5px 2px #656565;
-webkit-box-shadow: 5px 5px 2px #656565;
box-shadow: 5px 5px 2px #656565;
}
#nav ul li ul {
width:140px;
margin:5px 0 0 -3px;
float:left;
-moz-box-shadow: 5px 5px 2px #656565;
-webkit-box-shadow: 5px 5px 2px #656565;
box-shadow: 5px 5px 2px #656565;
background:url(aaa-navbg3.png) repeat-x #ffffff;
border-bottom:3px solid #e29511;
border-left:3px solid #e29511;
border-right:3px solid #e29511;
}
#nav ul li ul li {
width:140px;
font-weight:normal;
font-size:10pt;
background:none;
border-top:1px solid #808080;
border-left:none;
border-right:none;
border-top-left-radius:0px;
border-top-right-radius:0px;
}
#nav ul li ul li:hover {
background:url(aaa-libg2.png) repeat-x;
border-top:1px solid #808080;
border-left:none;
border-right:none;
}
/* toppane ------------------------------------------------------------------------------ */
#toppane {
width:100%;
height:210px;
background:url(aaa-toppane3.jpg) repeat-x;
padding:20px 0 20px;
margin:0px 0 20px 0;
position:relative;
z-index:-1;
border-top:1px solid #000000;
border-bottom:1px solid #000000;
}
#toppane-inner {
width:800px;
height:210px;
margin:0px auto;
}
/* slideshow ------------------------------------------------------------------------------ */
#window {
clear:both;
width:800px;
height:210px;
overflow:hidden;
position:relative;
margin:0;
padding:0;
}
#slideshow {
width:1600px;
height:420px;
overflow:hidden;
position:relative;
margin:0;
padding:0;
}
#slideshow li {
width:800px;
height:210px;
float:left;
display:inline;
margin:0;
padding:0;
}
/* main ------------------------------------------------------------------------------ */
#main {
width:800px;
margin:5px auto;
padding:0px;
}
#left {
width:390px;
margin:0 20px 0 0;
padding:0px;
float:left;
}
#right {
width:390px;
font-size:11pt;
margin:0;
padding:0px;
float:right;
}
#right img {
margin:0 0 5px 0;
}
#right a:link {
text-decoration:none;
color:#383838;
}
#right a:hover {
text-decoration:none;
color:#383838;
}
#right a:visited {
text-decoration:none;
color:#383838;
}
h2 {
width:390px;
font:14pt verdana;
border-bottom:1px solid #383838;
margin:0 0 5px 0;
text-align:right;
}
.segment {
margin:0 0 40px 0;
}
#footer {
background:blue;
width:800px;
margin:30px auto;
color:#ffffff;
}
#footer table {
width:800px;
}
#footer tr {
width:800px;
}
#footer td {
width:200px;
}
Adding clear:left; to your footer solves this problem.
The issue you're seeing is that #left and #right both extend outside of the #main div since they're floating and nothing inside the #main div is clearing those floats.
The footer is then stacking vertically against the #main div which is not the same height as #left and #right.
One thing you can do to pull the main div down over the floated items is add something at the end of it to clear the floats. You can do this with CSS as follows:
#main:after{
content:".";
display:block;
clear:both;
visibility:hidden;
}
What you need to use is what's called a "clear fix". Things are overlapping because the browser doesn't know when to stop "floating" things, so to speak.
You can either:
a) Add after your main divs the following
<div style="clear: both;"> </div>
b) Add the clear: both style to your footer itself.

Resources