Day: May 17, 2020

This tutorial assumes you have the knowledge of CSS and HTML.

We are going to use a simple unordered list to build our menu. We will use css to style it so it looks cool and we will use jQuery to show and hide and slide it down and up.

The image with complete html and jquery code here:

The image of complete css code:CSS

You can view the demo of what we will be building here:DEMO

Before we start I want to say that for best performance you should use Firefox 3.0!

1). HTML FILE

Ok, first of all lets build our html file:

Inside the header, after the title,

link your css and jquery files (the statements below)

 lt; link href=”CSS/style.css” rel=”stylesheet” type=”text/css” /  gt;

 lt; script type=”text/javascript” src=”js/jquery-1.3.1.js”  gt; lt; /script  gt;

As you can see my CSS file is inside the folder I created called CSS.

And my jQuery framework file is in the folder named js. Change the structure to any way you like it. I just like to keep things organized.

Ok, so far your project should consist of an HTML FILE, a folder “js” with the jquery framework file inside of it – that can be downloaded here http://www.jquery.com, and the CSS folder with the blank “style.css” stylesheet inside of it. If you’re a bit confused with this, you can also check out webpagescientist.com to see exact instructions.

2.) continuing with our HTML file

Inside your body tag enter the following:

 lt; a href=”#” class=”menu_class”  gt;Click Me  lt; / a gt;

 lt; ul class=”the_menu” gt; lt; li  gt; lt; a href=”http://www.google.com” gt;Google lt; /a  gt; lt; /li  gt;

 lt; li  gt; lt; a href=”http://www.yahoo.com” gt;Yahoo lt; /a  gt; lt; /li  gt;

 lt; li  gt; lt; a href=”http://www.msn.com” gt;MSN lt; /a  gt; lt; /li  gt;

 lt; li  gt; lt; a href=”http://www.metacrawler.com” gt;MetaCrawler lt; /a  gt; lt; /li  gt;

 lt; li  gt; lt; a href=”http://www.dogpile.com” gt;DOGPILE lt; /a  gt; lt; /li  gt;

 lt; /ul  gt;

Here is the image of what my code looks like now: CodeSnippet

Now Preview your work in browser and you should have something like this: Preview

3).Styling with CSS

Open your style.css and insert the folowing code: (The comments are just for explanation purposes)

body {

font-family:Arial, Helvetica, sans-serif;

font-size:12px;

background-color: Black;

}/* Style our body document. set the font to “Arial”, size of the font to 12 and make the background Black color.*/

a.menu_class

{

background-color: #Bc0022;

border: 1px solid #FF9933;

font-size:20px;

padding:5px 30px 5px 30px;

color:Black;

width:90px;

height:40px;

}/*Style the top menu to look like a button by giving it padding. Make the color of the text black. give it background color and a solid border. */

ul, li {

margin:0;

padding:0;

list-style:none;

}/* Style all the unordered lists within the document to not have any extra spacing and remove bullets*/

.the_menu {

display:block;

width:134px;

border: 1px solid #FF9933;

}/* Style our menu class to be displayed as a block and set its width and border*/

.the_menu li {

background-color: #Bc0022;

}/* Style each individual list item on our menu to have a background color of dark red*/

.the_menu li a {

color:#FF9933;

text-decoration:none;

padding:10px;

display:block;

}/* Style the anchor texts to have no underline and have a 10 pixel distance in between them and the border. Give them a yellowish color*/

.the_menu li a:hover {

padding:10px;

font-weight:bold;

background-color:White;

}/* When user hover over our anchors give it a white background to appear like a highlight, make word bold and keep the padding the same*/

OK, save your style.css and preview your html file in browser. You should get something like this:Preview

So as you can see the menu is looking much better. We are done building it. Now the last step is placing it at the correct position and make it show up only when user clicks on the “Click Me” Button and hide it when the user clicks on it again.

Here is the missing code: its not going to be hard. as it only contains a few lines.

 lt; script type=”text/javascript”  gt;

$(document).ready(function () {

$(‘a.menu_class’).click(function () {

$(‘ul.the_menu’).css(‘top’, 3)

.css(‘left’,144);

$(‘ul.the_menu’).slideToggle(‘medium’)

});

});

 lt; / script  gt;

So lets break it down:

 lt; script type=”text/javascript”  gt;start scripting in javascript

$(document).ready(function () { //when the document ready start the function

$(‘a.menu_class’).click(function () { //get the anchor tag with the class of menu_class and when the user

clicks start the function

$(‘ul.the_menu’).css(‘top’, 3) //get the unordered list with the id of the_menu and add the css top:3px;

.css(‘left’,144); and left:144px; which means attach this unordered list at the coordinates of y=3 and x = 144. Those coordinates relate to the (a.menu_class) or our button. So this will place the submenu on the right.

$(‘ul.the_menu’).slideToggle(‘medium’) //get the unordered list with the id of the_menu and call the slideToggle function with the speed of medium. What tat means is attach our submenu and slide it down at the medium speed, if user clicks it again then slide it up at the medium speed.

});

});

 lt; / script  gt; Close out our functions and end the script.

One more thing. If you remember we seen the whole menu right away. To hide it so that the toggle function starts from showing it, we need to modify the .the_menu class in our styles.css. Change the display:block; to display:hidden. Then save the html document and the css document and we get our final result! DEMO.

I hope you enjoyed this tutorial and learned something. If you have any questions please feel free to post them in the comments. Thanks.Jquery makes it easy to build navigational sliding menus

When it comes to Valentine’s day it seems that most people opt for either the expensive way or the easy way by taking help from saitove za zapoznanstva. Sometimes the two combine to create the perfect storm of “romantic” cliché. Anyone can overpay for flowers that will last a week at best. The thought of my husband in a panic at the local grocery store two hours before he comes home from work on the big day leaves me with mixed emotions. Most of them falling along the lines of, “how could he forget?” and “do you know what I could have done with the $140 dollars he spent on these roses?” How much effort does it take to grab a velvet-covered box of chocolate? Or pick up that thoughtfully mass-produced diamond bauble that six other women will show up at the gym wearing the day after Valentine’s?

When I look back on the nearly ten years I’ve been with my husband it isn’t these things that stick out for me. Don’t get me wrong I love some good chocolate and flowers are great. I’ll forever cherish my Tiffany bracelet. Yet more for the sentiment and thoughtfulness, he put into choosing it than for the label. He picked their Russian Knot design because I am named after Lara from the Russian love story Doctor Zhivago.

I keep a hatbox full of his early love letters and the notes that they’ve been paired down into since having four children. My husband has a great sense of humor and gives me fun, silly, and ultimately very romantic knickknacks that I value above all the roses, chocolates, stuffed animals, lingerie, and baubles I’ve ever received.

It’s in this spirit that I present you with five wonderfully romantic ideas for this Valentine’s day. I promise you that if your valentine has even the smallest romantic bone in their body they will promise their heart to you and never notice the lack of overpriced clichés.

Breakfast at Tiffany’s (or lunch on the lawn):

It does hold true that the way to your love’s heart (be they man or woman) is through their stomach. I’m a talented at-home chef. I consider cooking an art form and an outlet. I cook daily and enjoy doing it. But I tell you when my husband cooks for me (three times in ten years mind you) it is sexy as hell! He doesn’t have to give it the five-star treatment. Just that he did this thing for ME is great. So my first suggestion is a meal. Cook for your love. You can spice it up by getting up early and making a wonderful breakfast in bed. Or, you can pack a nice picnic for two. Because we live in a colder climate I have made a bedroom bistro for just the two of us. I cover a small table or nightstand with beautiful linens, set it with my best dinnerware, light candles throughout the room, and serve up a meal for two. You could even just order your valentine’s favorite take-out meal if cooking is out of the question. It’s all about the effort you went to for them.

*A side note to this suggestion. Many community colleges offer couples cooking class for Valentine’s Day. Some even offer classes leading up to the holiday if you’d like to learn something new to take back to your place and make for your valentine.

The love letters of great men (or women):

I try and do this every time my guy goes away on business or just sometimes out of the blue. I tuck little notes in his bag, wallet, the book he is reading, or the pocket of his jeans before he puts them on. Sometimes I just write “I heart You”. Other times I get a little naughty, pick a great quote, or recall a memory of ours. Step it up for the occasion. Put them everywhere and be really honest and heartfelt (it shows). There is nothing like hearing that he loves the way I look in his t-shirt.

Treasure Island:

At heart, be we women or men, we are all kids who want to have fun. Who says romance has to be fancy and flowery? Make it a game. Buy your valentine that something special you know they want. Wrap it up and hide it. Then make them little clues to get to where the treasure is hidden. Make it extra romantic by adding things into your clues about how and why you love your partner. Or you could even go the naughty route with a few of the clues too.

Dance like no one is watching:

This is my biggie when it comes to being swept off my feet. Don’t bother with a crowded club. Pass up on the overdone dinner place that has hired a DJ and popped for a portable dance floor in honor of the occasion. Make a playlist of songs that are meaningful to the two of you. Set up a room in your house with a CD or mp3 player, dim the lights, put out some candles, and just ask your valentine to dance. When my husband and I went to Tuscany this summer I put together a playlist just for this purpose. We danced and danced and I’ve never done anything more romantic.

The thing about Valentine’s day is, like so many other things, it’s become a consumer holiday. Remind your valentine that it’s about the love the two of you share not the credit card bill.