菜单和子菜单问题?

时间:2010-01-18 03:53:16

标签: html css

使用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

匹配

如何解决这个问题。请。

2 个答案:

答案 0 :(得分:2)

要减少内部列表上方的空间量,请更改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样式。

答案 1 :(得分:1)

使用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