主要内容左侧的垂直弹出菜单

时间:2013-03-12 18:33:32

标签: html css

我当前的HTML / CSS设置将leftmenu和main放在容器中,但主div出现在菜单下方。我一使用float:left;在导航上,导航变为水平菜单。如何将左侧菜单和主要内容放在同一水平线上?

这是HTML:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CMAP Playground 4</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <div class="header">
            <ul class="headernav">
                <li><a class="headernav" href="#" title="Main website">CMAP</a></li>
                <li><a class="headernav" href="#" title="SharePoint Server">SharePoint</a></li>
                <li><a class="headernav" href="#" title="Wiki Pages">Wiki</a></li>
                <li><a class="headernav" href="#" title="MetroPulse">Metropulse</a></li>
            </ul>

        <div id="logo"></div>
    </div>

<div id="container">

    <div id="leftmenuwrapper">
        <ul>
            <li><a href="#" title="IT Homepage">IT Home</a></li>
            <li><a href="#" title="Our Services">Services</a>
                <ul>
                    <li><a href="#" title="Product 1">Product 1</a>    </li>
                    <li><a href="#" title="Product 2">Product 2</a></li>
                </ul><li>
            <li><a href="#" title="About IT">About IT</a></li>
            <li><a href="#" title="The IT Index">IT A-Z Index</a></li>
            <li><a href="#" title="Current News">Hot Topics</a></li>
        </ul>
    </div>

<div class="rightmenu">
        Print this page!
</div>

    <div class="main">
        <h1>
            Welcome to CMAP Intranet
        </h1>

        <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        </p></br>

        <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        </p></br>
</div>

    <div class="footer">
        <ul>
            <li><a class="footernav" href="#" title="Get connected">Get Connected</a></li>
            <li><a class="footernav" href="#" title="IT Services">IT Services</a></li>
            <li><a class="footernav" href="#" title="About IT">About IT</a></li>
            <li><a class="footernav" href="#" title="CMAP website">CMAP</a></li>
            <li><a class="footernav" href="#" title="SharePoint Server">SharePoint</a></li>
            <li><a class="footernav" href="#" title="Wiki page">Wiki</a></li>
            <li><a class="footernav" href="#" title="Metropulse">Metropulse</a></li>
            </ul>
        </div>
    </div>
</div>

</body>
</html>

这是CSS:

#container {
  height:auto;
    border:1px solid green;
    vertical-align: middle;
  }

  #leftmenuwrapper ul, #leftmenuwrapper ul li {
      margin: 0;
      padding: 0;
      list-style: none;
      display: inline-block;
  }

  #leftmenuwrapper ul li {
      background-color:#7f95db;
      border-bottom:solid 1px white;
      width:140px;
      display: block;
  }

  #leftmenuwrapper ul li:hover {
      background-color: #6679e9;
      position: relative;
  }

  #leftmenuwrapper ul li a {
      padding: 5px 15px;
      color: #FFF;
      display: block;
      text-decoration: none;
  }

  #leftmenuwrapper ul li ul {
      position: absolute;
      display: none;
  }

  #leftmenuwrapper ul li:hover ul {
      left: 140px;
      top: 0px;
      display: block;
  }

  #leftmenuwrapper ul li ul li{
      background-color:#cae25a;
  }

      .main {
          width: 60%;
          margin: 0 10em 0 10em;
          padding: 0 10px;
          display: inline-block;
      }

0 个答案:

没有答案