Friday, 26 September 2014

How to creat CSS Responsive Drop Down Menu






HTML :

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Responsive Drop Down Menu</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

</head>
<body>
    <label for="show-menu" class="show-menu">Show Menu</label>
    <input type="checkbox" id="show-menu" role="button">
        <ul id="menu">
        <li><a href="#">Home</a></li>
        <li>
            <a href="#">About &darr; </a>
            <ul class="hidden">
                <li><a href="#">Who We Are</a></li>
                <li><a href="#">What We Do</a></li>
            </ul>
        </li>
        <li>
            <a href="#">Portfolio &darr;</a>
            <ul class="hidden">
                <li><a href="#">Photography</a></li>
                <li><a href="#">Web & User Interface Design</a></li>
                <li><a href="#">Illustration</a></li>
            </ul>
        </li>
        <li><a href="#">News</a></li>
        <li><a href="#">Contact</a></li>
    </ul>
</body>
</html>


CSS:

 /*Strip the ul of padding and list styling*/
ul {
    list-style-type:none;
    margin:0;
    padding:0;
    position: absolute;
}

/*Create a horizontal list with spacing*/
li {
    display:inline-block;
    float: left;
    margin-right: 1px;
}

/*Style for menu links*/
li a {
    display:block;
    min-width:140px;
    height: 50px;
    text-align: center;
    line-height: 50px;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: #fff;
    background: #2f3036;
    text-decoration: none;
}

/*Hover state for top level links*/
li:hover a {
    background: #19c589;
}

/*Style for dropdown links*/
li:hover ul a {
    background: #f3f3f3;
    color: #2f3036;
    height: 40px;
    line-height: 40px;
}

/*Hover state for dropdown links*/
li:hover ul a:hover {
    background: #19c589;
    color: #fff;
}

/*Hide dropdown links until they are needed*/
li ul {
    display: none;
}

/*Make dropdown links vertical*/
li ul li {
    display: block;
    float: none;
}

/*Prevent text wrapping*/
li ul li a {
    width: auto;
    min-width: 100px;
    padding: 0 20px;
}

/*Display the dropdown on hover*/
ul li a:hover + .hidden, .hidden:hover {
    display: block;
}

/*Style 'show menu' label button and hide it by default*/
.show-menu {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    text-decoration: none;
    color: #fff;
    background: #19c589;
    text-align: center;
    padding: 10px 0;
    display: none;
}

/*Hide checkbox*/
input[type=checkbox]{
    display: none;
}

/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #menu{
    display: block;
}


/*Responsive Styles*/

@media screen and (max-width : 760px){
    /*Make dropdown links appear inline*/
    ul {
        position: static;
        display: none;
    }
    /*Create vertical spacing*/
    li {
        margin-bottom: 1px;
    }
    /*Make all menu links full width*/
    ul li, li a {
        width: 100%;
    }
    /*Display 'show menu' link*/
    .show-menu {
        display:block;
    }
}


CSS even and odd rules





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
.listing
{
width:980px; margin:0 auto;
}

.listing ul
{
margin:0px; padding:0px; float:left; list-style:none; width:100%;
}

.listing ul li
{
float:none; width:100%; height:50px;
}

.listing ul li:nth-child(even) { background-color:#009900;}
.listing ul li:nth-child(odd) { background-color:#99CC00;}


</style>
</head>

<body>

<div class="listing">
  <ul>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
  </ul>
</div>


</body>
</html>

Thursday, 25 September 2014

Creat Easy Drop Down Menu






<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
body
{
margin:0px; padding:0px; font-family:Candara;
}

.header
{
width:100%; background:#000000; 
}

.nav
{
width:80%; margin:0 auto; height:auto; overflow:hidden;
}

.nav ul ul
{
display:none;
}

.nav ul
{
margin:0px; padding:0px; float:right; list-style:none; display:inline-table;
}

.nav ul li
{
float:left;
}

.nav ul li a
{
color:#FFFFFF; font-size:16px; padding:10px 25px; text-decoration:none; display:block;
}

.nav ul li:hover
{
background-color:#990000;
}

.nav ul li:hover > ul
{
display:block;
}

.nav ul li ul
{
position:absolute; background-color:#000000; padding-top:10px; padding-bottom:10px;
}

.nav ul ul li
{
float:none;
}

.nav ul ul li:hover
{
background-color:#990000
}

.nav ul ul ul
{
position:absolute; left:100%; top:50%; width:200px;
}

</style>
</head>

<body>

<div class="header">
      <div class="nav">
           <ul>
               <li><a href="#">HOME</a></li>
               <li><a href="#">ABOUT US</a></li>
               <li><a href="#">SERVICES</a>
                   <ul>
                       <li><a href="#">SERVICES 1</a></li>
                       <li><a href="#">SERVICES 1 RVICES 1</a></li>
                       <li><a href="#">SERVICES 1</a></li>
                       <li><a href="#">SERVICES 1</a>
                           <ul>
                               <li><a href="#">SERVICES 1</a></li>
                                <li><a href="#">SERVICES 1</a></li>
                                <li><a href="#">SERVICES 1</a></li>
                               <li><a href="#">SERVICES 1</a></li>
                               <li><a href="#">SERVICES 1</a></li>
                              <li><a href="#">SERVICES 1</a>
                             </li>
                           </ul>
                       </li>
                       <li><a href="#">SERVICES 1</a></li>
                       <li><a href="#">SERVICES 1</a></li>
                   </ul>
               </li>
               <li><a href="#">BLOG</a></li>
               <li><a href="#">CONTACT US</a></li>
           </ul>
      </div>
</div>

<div style="width:100%; height:400px; background:#003399"></div>

</body>
</html>

Monday, 22 September 2014

Creating an CSS background slider with jQuery

<script type="text/javascript" src="path/to/js/jquery.js"></script>
<script language="JavaScript" type="text/javascript">
 $(document).ready(function(){
 
 var imgArr = new Array( // relative paths of images
 'path/to/images/1.jpg',
 'path/to/images/2.jpg',
 'path/to/images/3.jpg',
 'path/to/images/4.jpg'
 );
 
 var preloadArr = new Array();
 var i;
 
 /* preload images */
 for(i=0; i < imgArr.length; i++){
 preloadArr[i] = new Image();
 preloadArr[i].src = imgArr[i];
 }
 
 var currImg = 1;
 var intID = setInterval(changeImg, 6000);
 
 /* image rotator */
 function changeImg(){
 $('#masthead').animate({opacity: 0}, 1000, function(){
 $(this).css('background','url(' + preloadArr[currImg++%preloadArr.length].src +') top center no-repeat');
 }).animate({opacity: 1}, 1000);
 }
 
 });
</script>
 
 
 
 
 
 
 
 
<div id="mast-head" style=”background: url(path/to/images/1.jpg) no-repeat; height: 300px; width: 300px;"></div>