Complete Solution for every problem | Mobile Technology | Web Technology | Software | Mobile Apps | Scripts | Tricks | Latest Technology | Wordpress Plugins


Line Post
Showing posts with label Webdesign. Show all posts
Showing posts with label Webdesign. Show all posts

07 March, 2014

N-Level CSS Menu With PHP And MYSQL

A website should have a good and proper navigation from user point of view to attract more visitors. Creating css navigation using php and mysql is always a headache for php newbies.
In this tutorial  I have told that how to manage a horizontal css navigation menu from a single mysql table and a small piece of PHP code. Instead of wasting your time I come to our main tutorial. Go through the following points and make your own navigation menu. Here we make a totally dynamic menu in php which retrieved data from mysql database.



Step: 1 Database "abc":


First of all we make a database and include one table for menu. so we make "abc" database and 'menu' table in database. and also include three field in menu table. U can see in the below picture.



Step: 2 Table Structure:

Now Insert field name like as a "id" (default as primary key), "m_name", "m_link" , "parent_id".  we can see this table structure in below picture.


Step:3 Database table "menu":

After than we insert some data in this table which we want to display in menu. It also see in below picture.



As you are seeing, the table has only four fields. First column is id of each menu that is primary key and last column is the id of parent of each menu. You’ll understand yourself by seeing the structure.

Step 4 Style Sheet for menu (style.css):

Apply the following css to your menu. and save it name as style.css. and include in head section in index page.

@charset "utf-8";
/* CSS Document */
*{margin:0; padding:0; }
body {     background: none repeat scroll 0 0 conten;
    float: left;
    margin: 0px auto;
    padding: 0px;
    text-align: center;     }
#cssmenu {
  height: 80px;
  padding:0px 100px;  text-align:center;
 border-radius: 5px 5px 0 0;
 -moz-border-radius: 5px 5px 0 0;
 -webkit-border-radius: 5px 5px 0 0;
 background: #5FACEB;
 margin:80px 350px;
}
/* =======  Menu  ====*/
#navigation { float: right; z-index:9999;}
.js .selectnav { display: none; }
.menu ul { margin: 0; padding: 0; list-style: none; }
.menu ul li { position: relative;}
.menu ul ul { position: absolute; display: none; top: 100%; left: 0; z-index: 100; width: 175px; }
.menu > ul li { float: left; cursor: pointer;}
.menu ul li:hover > ul { display: block; }
.menu ul a {display: block;position: relative;}
.menu ul ul li a.sf-with-ul:after{
-moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: #FFFFFF;
    -moz-border-top-colors: none;
    border-color: #FFFFFF #FFFFFF #FFFFFF #afafaf;
    border-image: none;
    border-right: 5px solid rgba(0, 0, 0, 0);
    border-style: solid;
    border-width: 5px;
    content: "";
    height: 0;
    margin-top: -5px;
    position: absolute;
    right: .5em;
    top: 50%;
    width: 0;
    margin-right: -3px; }
.menu ul ul li a:hover.sf-with-ul:after{
border-color: #ccc #ccc #ccc #2ecc71;
-moz-border-right-colors:#FBFBFB}
.menu ul ul ul {top: 0;left: 100%;}
.menu ul a { text-decoration: none; }
.menu ul > li > a {
color: #fff;
font-weight: 400;
font-size: 14px;
line-height: 18px;
padding: 35px 18px 31px 18px;
overflow: hidden;
border-bottom: 2px solid transparent;
transition: all .25s ease-in-out;
-moz-transition: all .25s ease-in-out;
-webkit-transition: all .25s ease-in-out;}

#current,
.menu ul li a:hover,
.menu ul > li:hover > a { 
border-bottom: 2px solid #2ecc71;
background-color: #fbfbfb;
color:#2ecc71;}
.menu ul li a:hover .sf-sub-indicator{
color:#2ecc71;}
#current:after {
background: #2ecc71;
bottom: -2.5px;
content: '';
left: 50%;
display: block;
height: 5px;
margin: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
position: absolute;
width: 5px;}
.ie8 #current:after { display: none; }
.menu ul li a {
-webkit-transition: border 150ms ease-in-out, background-color 150ms ease-in-out;
-moz-transition: border 150ms ease-in-out, background-color 150ms ease-in-out;
-o-transition: border 150ms ease-in-out, background-color 150ms ease-in-out;
-ms-transition: border 150ms ease-in-out, background-color 150ms ease-in-out;
transition: border 150ms ease-in-out, background-color 150ms ease-in-out;}

/* Drop-Down */
.menu ul ul {
background-color: #fff;
z-index: 999;
border-radius: 0 0 3px 3px;
border: 1px solid #fefefe;
border-top: 2px solid #2ecc71;
margin: -2px 0 0 0;}
.menu > ul ul li:hover > a {
border-bottom: 0;
background:#000;}
.menu ul ul li {
margin: 0;
padding: 0;
width: 100%;}
.menu ul ul li a {
color: #555;
font-size: 13px;
line-height: 18px;
padding: 10px 16px !important;
border: 0; }
.menu ul ul li { border-top: 1px solid #e8e8e8; }
.menu ul ul li:first-child { border: 0; }
.menu ul ul li a:hover {
color:#2ecc71;
background-color: #000;
border: 0; }
.menu ul ul li a {
-webkit-transition: background-color 50ms ease-in-out;
-moz-transition: background-color 50ms ease-in-out;
-o-transition: background-color 50ms ease-in-out;
-ms-transition: background-color 50ms ease-in-out;
transition: background-color 50ms ease-in-out; }
.menu ul ul ul {
border: 1px solid #e0e0e0;
border-radius: 0 3px 3px 3px;
margin: -1px 0 0 0; }
.sf-sub-indicator {
color: #c6c6c6;
margin: 0 0 0 5px;
width: 11px;
display: inline-block;
font-size: 12px;
line-height: 0;}
.menu ul ul .sf-sub-indicator .fa-angle-down { display: none; }
#jPanelMenu-menu #current { border-bottom: 1px solid #eee; }
#jPanelMenu-menu #current:after,
#jPanelMenu-menu .sf-sub-indicator { display: none; }
#jPanelMenu-menu li a {
display:block;
padding: 12px 20px !important;
background-color: #f6f6f6;
border-bottom: 1px solid #f0f0f0;
color: #888;
font-weight: 500;
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
-ms-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
font-weight: 500;
outline: none; }
#jPanelMenu-menu li a:hover { background-color: #f8f8f8; }
#jPanelMenu-menu li li a {
background-color: #fff;

padding-left: 30px !important;}

Step 5 index.php:

This is the main PHP file that will fetch the menus from database and show them in your navigation menu using while loop. The script is written for 3 Level CSS menu. You can extend it for nth level by running the loop n times as it is.

<?php
//database connection
$dbname = 'abc';
$link = mysql_connect("localhost","root","") or die("Couldn't make connection.");
$db = mysql_select_db($dbname, $link) or die("Couldn't select database");
?>

<!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=utf-8" />
<title>Dynamic menu</title>
<link rel="stylesheet" type="text/css" href="styleseet/style.css"  /> 
</head>

<body>
<div id="cssmenu">
<nav id="navigation" class="menu">
<ul id="responsive">
<?php
function query($parent_id) { //function to run a query
   $query = mysql_query ( "SELECT * FROM menu WHERE parent_id=$parent_id" );
   return $query;
}
function has_child($query) { //This function checks if the menus has childs or not
    $rows = mysql_num_rows ( $query );
   if ($rows > 0) {
        return true;
   } else {
       return false;
   }
}
function fetch_menu($query) {
   while ( $result = mysql_fetch_array ( $query ) ) {
       $m_id = $result ['id'];
       $m_name = $result ['m_name'];
      $m_link = $result ['m_link'];
       echo "<li><a href='{$m_link}'><span>{$m_name}</span></a>";
       if (has_child ( query ( $m_id ) )) {
           echo "<ul>";
           fetch_menu ( query ( $m_id ) );
           echo "</ul>";
       }
       echo "</li>";
   }
}
fetch_menu (query(0)); //call this function with 0 parent id
?>
</ul>
</nav>
</div>
</body>
</html>

Ok so finally we make a totally dynamic menu with css. Just by changing the database connection properties and change your menu names and their links in database table. I hope you enjoyed the tutorial.
Keep Visiting :) 
Read more ...

21 February, 2014

CSS with LESS and SASS

What is LESS and SASS??

LESS and SASS  are 'Css preprocessors'. But after than one question arise in our mind that is what is preprocessor and why to use us.  ‘CSS preprocessors’, which offers to add mind-blowing features to the Cascading Style sheet language, and equip the modern-day front end engineer with tons of nitro and increase productivity.

First of all Let we know why we use preprocessors.? In simple Css we faced many problems like as CSS stylesheets are getting larger, more complex, and harder to maintain in multypage website. To Overcome  this problem, the concept of   Css Preprocessors was born. It offering an advanced way of writing CSS, which extends the basic functionalities. This advanced code is later compiled as normal CSS code using respective compilers (which depends on what preprocessor you are using), which the browser will understand. 


Css  Preprocessor


Which Preprocessors to use?


1. LESS

2. SASS

3. Stylus 


Learning LESS :



LESS (Leaner CSS) is designed by Alexis Sellier. LESS is a dynamic style sheet language that extends CSS and, just like SASS, it has dynamic behavior such as variables, mixins, operations and functions.

It allows you to write CSS in a simpler way by just using and combining mixins, functions, and so on. LESS also increases readability and organization of CSS using imports, nested rules and comments with .less extension.


Resources you need to complete this tutorial:


Step 1:

Installing SimpleLESS

For our LESS client-side compiler we’re going to use SimpleLESS because it is simple to use and it’s free so go ahead and download it.

click Here for download simpleLESS 

If  you don’t see the current version on the top bar, that means it’s not working properly so you need to download it again. 



Step 2: 

Prepare the Markup and LESS Javascript

Before we explain LESS functionalists, we need to prepare our markup and LESS files. So go ahead and create new folder then name it “LESS” or whatever you prefer. Next, inside the LESS folder, create an HTML file and name it index.html and copy and paste the code below. Notice that we have included the LESS library below the less style sheet.



Step 3:

Next, create a new file and name it style.less. For the purpose of showing you how to compile LESS, let’s put some LESS sample codes in this file. Go ahead, copy and paste the code below to style.less file.


So, by this time, it is expected you’ll have a file structure similar to this.


Step 4:  

Compiling LESS using SimpLESS


To compile LESS file to CSS, run the SimpLESS application and drag and drop the LESS folder that we created above in the application.



You can see that the folder was successfully added to the application if the folder appears on the list of the application. Notice that you can see a text that notifies you if the file has been compiled or not. In this example, as you can see in the right corner, it says “never compile” so this means that our LESS folder was never compiled.




The application also offers different features namely: prefix, minify, love. You can see these on the right corner under the status notification. Please take note that all these features can be turned on or off individually. Consider the following use of these features.

Prefix - allows you to attain cross-browser compatibility using vendor prefixes.
Minify- compress your CSS document that’s integrated CSS-minification.
Love- these will comment or state SimpLESS to your document.




So if you open again the LESS folder, you can see that a CSS file was added to the folder. Make sure you link the compiled CSS file (style.css) to your index.html to add the styles you added to your LESS file.





Declaring Variables:


Just like SASS, LESS also uses variables. If you have coded before, you know how variables make each process easier. For a pre-processor like LESS, variables are being used as placeholders for each value of the styles being used throughout the LESS file. LESS uses the @ sign to define a variable. Let’s put this into practice to know how this works.

Open your LESS file and put in the following code. For this code, I created 3 variables for width, border and color. I added the myWidth and myBorder variables on the H2 tag while I added the myColor variable to our list with the ID  of myWork.



So if you are going to open your style.css file, you can see that the code was updated. Go ahead and run this code into your browser and you can see similar to the image below.




LESS Mixins

One of the best features of any CSS preprocessor is the ability to create mixins, which allow you to tie a bunch of properties and customizable values all into one nice little package.  Sometimes we want to create styles that can be repeated throughout the style sheet. Good thing mixins are here to help. Just like SASS, it also has the same features that you can add on each elements repeatedly but without the use of @include directive. Instead, just a simple class style directive would suffice. To show you how mixins work in LESS.Let's see example below



This takes all of the box-shadow code and wraps it up nicely into a single mixin that can be implemented with custom values (or the defaults that we used above). Now, instead of writing a huge chunk of code every time you want a box-shadow, this is all you need:



Nested Rules:


The example above can be simplified even further by utilizing LESS’s nested rules feature. Watch how we can throw all the box styles into the same set of brackets and eliminate the need to type out the div ID every time.


As you can see, all of the box item’s link styles, link hover styles and paragraph styles are contained within the same parent.


LESS Operators


One of the best features of LESS is the ability to perform mathematical operations. Using a style fixed value, you can add, subtract, multiply or even divide. LESS allows you to perform operations on variables. This can save you a lot of mental math in the long run.

As an oversimplified example, say you wanted to create a box that was twice as wide as it was tall. You could declare the height in a variable and then set another variable that is twice that number. Let’s see this in action.



Then later in your code you would use these variables to set the height and width of your box. If you were to then go back and change boxHeight to 400px, boxWidth would automatically be set to 800px.



LESS Functions


LESS provides a bunch of functions to manipulate elements and styles. For this tutorial we will focus on color functions if you want to learn more about LESS functions you can CLICK HERE to learn more.

Check out the series of color functions below.

darken (color, amount)
lighten (color, amount)
saturate(color, amount)
desaturate(color, amount)
alpha(color)

Go ahead and open your style.less file and copy the following codes.



As you can see that the background color was darkened by 60% and then the H1 and H2 tags were lightened  by 10% and also the color of paragraph tags were lightened by 20%. So when you run this in your browser, you can get similar result just like the image below.




Read more ...

21 January, 2014

Best Web Design Of 2013

Here it is , Best website Design example of 2013 .These are websites we featured examples of good use of images, type, texture, font, navigation and much more. Take your time to browse our selection and explore all the websites. 

                     The Good Man


                           
     SI Digital


                   Wild Blue


                 Mail Chimp Annual Report


                Minimal Monkey


                Frank Digital


                  MIXD


                  Kin hr


                bigcartel


              Bjorn Meier


                   Costa


stay tuned and keep visiting 
Read more ...

Comments

Designed By