Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS UL LI Vertical Menu

<%@ Page Language="C#" AutoEventWireup="true" Theme="SF" CodeBehind="ULLITest.aspx.cs" Inherits="ClickDoors_WebApp.ULLITest" %>
<!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 runat="server">
    <title></title>
    <style type="text/css">    

        #Menu
        {
            padding:0;
            margin:0;
            list-style-type:none;
            font-size:13px;
            color:#717171;
            width:100%;
        }

        #Menu li
        {
            border-bottom:1px solid #eeeeee;
            padding:7px 10px 7px 10px;
        }

        #Menu li:hover
        {
            color:White;
            background-color:#ffcc00;
        }

        #Menu a:link
        {
            color:#717171;
            text-decoration:none;
        }

        #Menu a:hover
        {
            color:White;
        }
    </style>
</head>

<body>

    <form id="form1" runat="server">

    <div>
        <ul id="Menu">
            <li><a href="#">Internal Doors</a></li>
            <li><a href="#">Prefinished Internal Doors</a></li>
            <li><a href="#">External Doors</a></li>
            <li><a href="#">Internal Pair [French Doors]</a></li>
            <li><a href="#">External Pair [French Doors]</a></li>
            <li><a href="#">Custom Size Doors</a></li>
            <li><a href="#">Door Frames</a></li>
            <li>Test</li>
        </ul>
    </div>

    </form>
</body>
</html>

When i hover over it background-color is changed immediately but font color remains same until i hover over text.

In short i want my menu to behave similar to stackoverflows menu (Questions Tags Users....)

Any help will be appreciated.

like image 235
Faizal Balsania Avatar asked Dec 29 '22 00:12

Faizal Balsania


2 Answers

I'd do it like this:

  1. Set your <a> tags to display:block

  2. Remove the padding from your <li>'s (make it padding:0px)

  3. Re-add the padding to your <a> tags padding:7px 10px 7px 10px;

  4. Add background-color:#ffcc00; to #Menu a:hover

  5. Get rid of #Menu li:hover

like image 101
james6848 Avatar answered Jan 22 '23 01:01

james6848


need to add #Menu li:hover a {color:White;} This will set white color for a when a li is hovered.

Demo: http://jsfiddle.net/Nceef/

like image 22
Sotiris Avatar answered Jan 22 '23 03:01

Sotiris