CSS UL LI垂直菜单 [英] CSS UL LI Vertical Menu

查看:167
本文介绍了CSS UL LI垂直菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <%@ Page Language =C#AutoEventWireup =trueTheme =SFCodeBehind =ULLITest.aspx.csInherits =ClickDoors_WebApp.ULLITest%> ; 
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://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;
}

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

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

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

< body>

< form id =form1runat =server>

< div>
< ul id =Menu>
< li>< a href =#>内部门< / a>< / li>
< li>< a href =#>预制内门< / a>< / li>
< li>< a href =#>外部门< / a>< / li>
< li>< a href =#>内部对[法式门]< / a>< / li>
< li>< a href =#>外部对[French Doors]< / a>< / li>
< li>< a href =#>自定义尺寸门< / a>< / li>
< li>< a href =#>门框< / a>< / li>
< li>测试< / li>
< / ul>
< / div>

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

当我将鼠标悬停在其上时,背景颜色立即更改,但字体颜色保持不变,直到鼠标悬停在文本上。



总之,我希望我的菜单的行为类似stackoverflows菜单(问题标签用户....)


解决方案

我会这样做:


  1. < a> 标记设为 display:block


  2. 移除< li> 的填充c $ c> padding:0px


  3. 将填充重新添加到< a& 标签 padding:7px 10px 7px 10px;


  4. $ c> background-color:#ffcc00; 到 #Menu a:hover


  5. 摆脱 #Menu li:hover



<%@ 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.

解决方案

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

这篇关于CSS UL LI垂直菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆