【问题标题】:Menus and sub Menus problem?菜单和子菜单问题?
【发布时间】:2010-01-18 12:35:59
【问题描述】:

使用 CSS 样式表

在我的网页中,我有两个类,如菜单和左侧。在菜单中,我有 ul、li 课程。我也想在左侧使用 ul, li,但问题是如果我使用 ul, li,它与菜单 ul, li 匹配

ul -underlist, li -list

我试图更改工作表的代码,

我的 CSS 代码。

#leftside{
    float: left;
    width: 230px;
    margin-left: 5px;
    margin-top: 15px;
    overflow: hidden;
    font: 13px Arial, Helvetica, sans-serif;
}

a {

    text-decoration: none;
    color: #000000;
}

a:hover {

    text-decoration: underline;
    color: maroon;
}

ul {
    padding: 10px 10px 2px 0;
    margin: 0px;
    list-style: none;
}

li li {

    margin-left: 10px;
    margin-right: 10px;
    line-height: 30px;
    padding-left: 15px;
    border-bottom: 1px dashed #BDBDBD;
    background: url(images/img04.jpg) no-repeat left 50%;
}

HTML 代码

<li>                    
<ul>
<li><a href="#">Company Profile</a></li>
<li><a href="#">Enquiry</a></li>
<li><a href="#">Career</a></li>
<li><a href="#">Location Map</a></li>
</ul>
</li>

ul,list 与菜单 ul,li 匹配

如何解决这个问题。请。

【问题讨论】:

    标签: html css


    【解决方案1】:

    要减少内部列表上方的空间量,请更改 ul 的填充,使其为 0 或负数。

    例如:

    ul {
        padding: 0 10px 2px 0;
        margin: 0px;
        list-style: none;
    }
    

    您还可以使用特殊样式表来纠正 Internet Explorer 中的问题,方法如下:

    <!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="iespecific.css" />
    <![endif]-->
    

    然后您需要另一个名为 iespecific.css 的 CSS 文件,其中包含上述 ul 样式。

    【讨论】:

      【解决方案2】:

      使用 id 来区分两者。

      例如,HTML 将是:

      <ul id="outter">
      <li>The Outter List</li>
      <li>More Outter List                    
        <ul id="inner">
         <li>This is the inner list</li>
         <li><a href="#">Company Profile</a></li>
         <li><a href="#">Enquiry</a></li>
         <li><a href="#">Career</a></li>
         <li><a href="#">Location Map</a></li>
        </ul>
      </li>
      <li>Still The Outter</li>
      </ul>
      

      在 CSS 中你会有这样的东西:

      #outter ul {
         padding: 10px 10px 2px 0;
         list-style: none;
      }
      #outter li {
         margin-left: 10px;
         line-height: 30px;
         padding-left: 15px;
      }
      #inner ul  {
         padding: 10px 10px 2px 15px;
         list-style: none;
      }
      #inner li {
         margin-left: 10px;
         margin-right: 10px;
         line-height: 30px;
         padding-left: 15px;
         border-bottom: 1px dashed #BDBDBD;
         background: url(images/img04.jpg) no-repeat left 50%;
      }
      

      这看起来像这样:

      alt text http://img16.imageshack.us/img16/2376/examplesg.png

      【讨论】:

      • @Josh,谢谢,但问题是我在菜单顶部获得了更多空间。我也调整了填充,但它仍然在顶部显示更多空间。如何删除菜单顶部的空间。
      • 您将不得不减小填充或边距的大小。你甚至可能需要一个负数。但是如果没有您的问题的图像,我无法告诉您更多信息。
      • 在 Firefox 中,它在菜单顶部显示的空间较小,但在资源管理器中,它在菜单顶部显示更多空间。如何删除菜单顶部的空间。请
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-05
      • 1970-01-01
      • 1970-01-01
      • 2012-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多