• Follow us on Twitter
  • Join me on Google Plus
  • Add me on Linkedin
  • RSS
I'm a front-end, web developer and WordPress lover, since 2009. Actually working in Altran-ais as a front-end and web developer with Ruby on Rails . I also have skills with Ruby on Rails, PHP, JSP and jQuery. My hobbies is photography , playing games and dancing. close

  • Blog
  • Contact
  • About

Tag Archive for: css3

Simple menu drop down with CSS3

0 Comments/ in Blog, CSS / by admin
April 4, 2013

In this post i’ll create a simple menu with a drop down made 100% in CSS3. it’s very simple and great for designer that don’t want to use javascript.

First let’s create our html

<ul id="menu"> 
  <li>
    <a href="" title="">Link1</a>
  </li>
  <li>
    <a href="" title="">2</a>
    <ul>
      <li>
        <a href="" title="">2.1</a>
      </li>
    </ul>
  </li>
  <li>
    <a href="" title="">3</a>
  </li>
  <li>
    <a href="" title="">4</a>
    <ul>
      <li>
        <a href="" title="">4.1</a>
      </li>
      <li>
        <a href="" title="">4.2</a>
      </li>
    </ul>
  </li>
  <li>
    <a href="" title="">5</a>
  </li>
  <li>
    <a href="" title="">6</a>
    <ul>
      <li>
        <a href="" title="">6.1</a>
      </li>
      <li>
        <a href="" title="">6.2</a>
      </li>
    </ul>
  </li>
</ul>

And now the CSS

ul{
  list-style:none;
}
ul li{
  float:left;
  padding:10px;
  bordeR:1px solid #ccc;
  width:8%;
}
ul li:hover ul{
  opacity: 1;
  height: auto;
}
ul li a{
  color:black;
  text-decoration:none;
}
ul li ul{
  -webkit-transition: opacity 1s ease-out;
  -moz-transition: opacity 1s ease-out;
  -ms-transition: opacity 1s ease-out;
  -0-transition: opacity 1s ease-out;
  transition: opacity 1s ease-out;

  opacity: 0;
  height: 0;
  overflow: hidden;
}
ul li ul li{
  border:none;
  clear:both;
  width:100%;
}

As you can see, we set the a list inside a list and set it with the height with 0px and also opacity with 0px , it was done to make the inner list hidden, and we set the mouse hover on the element of the main list and change the inner list size and transparency.

This was already enough to make a drop down, now let’s add some animation on it, adding css3 transitions, this awesome tool let’s us to make real fantastic things, in this example is just a simple fade effect.

We set it on the element that will suffer the animation and change the values, in this case we change the opacity that was set with 0px before, the next value is the time of the animation and then the type of animation, in this example I used ease-out.

here is a list with all the type of animation that you can use.

  • linear
  • ease
  • ease-in
  • ease-out
  • ease-in-out
  • bezier-cubic
DEMO

Recent Posts

  • Base64 images on HTML/CSS
  • Simple menu drop down with CSS3
  • CSS hack for IE8 and IE9 and rails assets:precompile
  • Get current controller name/action name from view
  • Using the native pagination function in wordpress

Archives

  • April 2013
  • March 2013
  • May 2012

Categories

  • Blog
  • CSS
  • Ruby on Rails
  • WordPress

Tag Cloud

code css3 menu navigation pagination paginação rails ruby on rails simple menu tips tutorial tutorial wordpress wordpress

Latest Tweets

  • No more curly hair!!
    May 18, 2013 - 3:42 pm
  • Arduino para mac dando bufferoverflow, tela branca 2x ja ¬¬
    May 18, 2013 - 11:53 am
  • Great CSS triangle generator http://t.co/GwfUAmWwXw via @ekykwan
    May 17, 2013 - 10:16 am

Categories

  • Blog
  • CSS
  • Ruby on Rails
  • WordPress

Recent Posts

  • Base64 images on HTML/CSS
  • Simple menu drop down with CSS3
  • CSS hack for IE8 and IE9 and rails assets:precompile
  • Get current controller name/action name from view
  • Using the native pagination function in wordpress
© Copyright - Gabriel Del Fiaco - Wordpress Theme by Kriesi.at