Home >Web Front-end >JS Tutorial >Create a fluid navigation menu with Jquery CSS Fluid Navigation_jquery
So how should we implement a mobile navigation menu?
1. Rendering
Mouse over the Menu to show the prompt information.
2. Implementation steps
1. CSS code
menuBarHolder { width: 730px; height:45px; background-color:#000; color:#fff; font-family:Arial; font-size:14px; margin-top:20px;}
#menuBarHolder ul{ list-style-type:none; display:block;}
#container { margin-top:100px;}
#menuBar li{ float:left; padding:15px; height:16px; width:50px; border -right:1px solid #ccc; }
#menuBar li a{color:#fff; text-decoration:none; letter-spacing:-1px; font-weight:bold;}
.menuHover { background- color:#999;}
.firstchild { border-left:1px solid #ccc;}
.menuInfo { cursor:hand; background-color:#000; color:#fff;
width:74px ; font-size:11px;height:100px; padding:3px; display:none;
position:absolute; margin-left:-15px; margin-top:-15px;
-moz-border-radius- bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-khtml-border-radius-bottomright: 5px;
-khtml-border-radius-bottomleft: 5px;
border-radius-bottomright: 5px;
}
menuInfo: Control whether prompt information is displayed or not.
2. HTML code
DIV element: Prompt content information.
3. Javascript code
{
$('#menuBar li').click(function()
{
var url = $(this).find('a').attr( 'href');
document.location.href = url;
});
$('#menuBar li').hover(function()
{
$(this) .find('.menuInfo').slideDown();
},
function()
{
$(this).find('.menuInfo').slideUp();
});
});
click(), hover(): Bind click events and mouse over events to Li elements.
find() function: Search for all elements matching the specified expression. This function is a great way to find out the descendant elements of the element being processed.
slideDown(speed, [callback]): Dynamically display all matching elements through height changes (increase downward), optionally triggering a callback function after the display is completed.
slideUp(speed, [callback]): Dynamically hide all matching elements by changing the height (decreasing upward), optionally triggering a callback function after the hiding is completed.
If you need to introduce external Js, you need to refresh to execute ]