gpt4 book ai didi

javascript - 如何在下拉菜单中重新定位无序列表元素
  • 以便它显示在下拉列中
  • 转载 作者:太空宇宙 更新时间:2023-11-04 08:48:35 25 4
    gpt4 key购买 nike

    The li elements not in the dropdown box

    请帮我重新定位无序列表元素<li>在下拉菜单中,因此它将显示在下拉列中。

    在我的 HTML 和 CSS 代码下面:

    body, ul, li {
    font-size:14px;
    font-family:Arial, Helvetica, sans-serif;
    line-height:21px;
    text-align:left;
    margin:0;
    }

    img {
    width: auto;
    max-height: 100%;
    }

    /* Navigation Bar */

    #menu {
    list-style:none;
    margin: 50px auto auto auto;
    position: fixed;
    top: -50px;
    background: #1a1a1a;
    background: -moz-linear-gradient(top, #0272a7, #013953);
    background: #1a1a1a;
    -moz-box-shadow:inset 0px 0px 1px #edf9ff;
    -webkit-box-shadow:inset 0px 0px 1px #edf9ff;
    box-shadow:inset 0px 0px 1px #edf9ff;
    }
    body {behavior: url("csshover3.htc");}
    #menu li .drop {
    background:url("img/drop.gif")
    no-repeat right 8px;
    }
    #menu li {
    border-style: none;
    border-color: inherit;
    border-width: medium;
    float:left;
    text-align:center;
    position:relative;
    padding: 4px 10px 4px 10px;
    margin-right:30px;
    margin-top:15px;
    top: -3px;
    left: 368px;
    }
    #menu li:hover {
    border: 1px solid #777777;
    padding: 4px 9px 4px 9px;
    background: #F4F4F4;
    background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));
    -moz-border-radius: 5px 5px 0px 0px;
    -webkit-border-radius: 5px 5px 0px 0px;
    border-radius: 5px 5px 0px 0px;
    }

    #menu li a {
    font-family:Arial, Helvetica, sans-serif;
    font-size:14px;
    color: #EEEEEE;
    display:block;
    outline:0;
    text-decoration:none;
    text-shadow: 1px 1px 1px #000;
    }

    #menu li:hover a {
    color:#161616;
    text-shadow: 1px 1px 1px #FFFFFF;
    }
    #menu li .drop {
    padding-right:21px;
    background:url("img/drop.png") no-repeat right 8px;
    }
    #menu li:hover .drop {
    background:url("img/drop.png") no-repeat right 7px;
    }
    h1.header-line, h2.header-line,
    h3.header-line, h4.header-line,
    h5.header-line, h6.header-line{
    padding-bottom: 21px;
    margin-bottom: 11px;
    position:relative;
    }
    /* Drop Down */

    .dropdown_1column, .dropdown_2columns,
    .dropdown_3columns, .dropdown_4columns,
    .dropdown_5columns {
    margin:4px auto;
    float:left;
    position:absolute;
    left:-999em; /* Hides the drop down */
    text-align:left;
    padding:10px 5px 10px 5px;
    border:1px solid #777777;
    border-top:none;
    /* Gradient background */
    background:#F4F4F4;
    background: -moz-linear-gradient(top, #EEEEEE, #BBBBBB);
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EEEEEE), to(#BBBBBB));
    /* Rounded Corners */
    -moz-border-radius: 0px 5px 5px 5px;
    -webkit-border-radius: 0px 5px 5px 5px;
    border-radius: 0px 5px 5px 5px;
    }

    .dropdown_1column {width: 140px;}
    .dropdown_2columns {width: 280px;}
    .dropdown_3columns {width: 420px;}
    .dropdown_4columns {width: 560px;}
    .dropdown_5columns {width: 700px;}

    #menu li:hover .dropdown_1column,
    #menu li:hover .dropdown_2columns,
    #menu li:hover .dropdown_3columns,
    #menu li:hover .dropdown_4columns,
    #menu li:hover .dropdown_5columns {
    left:-1px;
    top:auto;
    }

    /* Columns */

    .col_1,.col_2,.col_3,.col_4,.col_5 {
    display:inline;
    float: left;
    position: relative;
    margin-left: 5px;
    margin-right: 5px;
    }
    .col_1 {width:150px;}
    .col_2 {width:270px;}
    .col_3 {width:410px;}
    .col_4 {width:550px;}
    .col_5 {width:690px;}

    .col_1 ul li {
    float:right;
    display:inline;
    }
    /* Right alignment */

    #menu .menu_right {
    float:right;
    margin-right:200px;
    }
    #menu li:hover .align_right {
    left:auto;
    right:-1px;
    top:auto;
    }

    /* Drop Down Content Stylings */

    #menu p, #menu h2, #menu h3, #menu ul li {
    font-family:Arial, Helvetica, sans-serif;
    line-height:21px;
    font-size:12px;
    text-align:left;
    /* text-shadow: 1px 1px 1px #FFFFFF; */
    }
    #menu h2 {
    font-size:21px;
    font-weight:400;
    letter-spacing:-1px;
    margin:7px 0 14px 0;
    padding-bottom:14px;
    border-bottom:1px solid #666666;
    }
    #menu h3 {
    font-size:14px;
    margin:7px 0 14px 0;
    padding-bottom:7px;
    border-bottom:1px solid #888888;
    }
    #menu p {
    line-height:18px;
    margin:0 0 10px 0;
    }

    #menu li:hover div a {
    font-size:12px;
    color:#015b86;
    }
    #menu li:hover div a:hover {
    color:#029feb;
    }
    .strong {
    font-weight:bold;
    }
    .italic {
    font-style:italic;
    }
    .imgshadow {
    background:#FFFFFF;
    padding:4px;
    border:1px solid #777777;
    margin-top:5px;
    -moz-box-shadow:0px 0px 5px #666666;
    -webkit-box-shadow:0px 0px 5px #666666;
    box-shadow:0px 0px 5px #666666;
    }
    .img_left { /* Image sticks to the left */
    width:auto;
    float:left;
    margin:5px 15px 5px 5px;
    }
    #menu li .black_box {
    background-color:#333333;
    color: #eeeeee;
    text-shadow: 1px 1px 1px #000;
    padding:4px 6px 4px 6px;

    /* Rounded Corners */
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;

    /* Shadow */
    -webkit-box-shadow:inset 0 0 3px #000000;
    -moz-box-shadow:inset 0 0 3px #000000;
    box-shadow:inset 0 0 3px #000000;
    }
    #menu li ul {
    list-style:none;
    padding:0;
    margin:0 0 12px 0;
    }
    #menu li ul li {
    font-size:12px;
    line-height:24px;
    position:relative;
    text-shadow: 1px 1px 1px #ffffff;
    padding:0;
    margin:0;
    float:none;
    text-align:left;
    width:130px;
    }
    #menu li ul li:hover {
    background:none;
    border:none;
    padding:0;
    margin:0;
    }
    #menu li .greybox li {
    background:#F4F4F4;
    border:1px solid #bbbbbb;
    margin:0px 0px 4px 0px;
    padding:4px 6px 4px 6px;
    width:116px;

    /* Rounded Corners */
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    }
    #menu li .greybox li:hover {
    background:#ffffff;
    border:1px solid #aaaaaa;
    padding:4px 6px 4px 6px;
    margin:0px 0px 4px 0px;
    }
    <div>
    <ul id="menu" style="height: 55px; z-index: 100; left: 1px;">
    <li style="text-align: left; top: -3px; left: 6px; width: 160px; ">
    <a class="drop" style="font-size: x-large"> &#9776; Menu</a>
    <div class="dropdown_5columns">
    <!-- Begin 4 columns container -->
    <div class="col_5">
    <h3 style="text-align:center">INFORMATION TECHNOLOGY</h3>
    </div>
    <div class="col_1">
    <h3>Home</h3>
    <ul>
    <li><a href="#">IT Home</a></li>
    <li><a href="#">IT Online Application</a></li>
    <li><a href="#">Silt Intranet</a></li>
    <li><a href="#">Silt.com</a></li>
    </ul>
    </div>
    <div class="col_1">
    <h3>Training Guide</h3>
    <ul>
    <li><a href="#">Email</a></li>
    <li><a href="#">Meeting Room</a></li>
    <li><a href="#">IT Orentiation Guide</a></li>
    <li><a href="#">KingSoft</a></li>
    <li><a href="#">Security Awareness</a></li>
    </ul>
    </div>
    <div class="col_1">
    <h3>Organization</h3>
    <ul>
    <li><a href="#">Organization Chart</a></li>
    <li><a href="#">*****</a></li>
    </ul>
    </div>
    <div class="col_1">
    <h3>Policies & Procedure</h3>
    <ul>
    <li><a href="#">Policies</a></li>
    <li><a href="#">Mailbox Quota</a></li>
    <li><a href="#">Escalation</a></li>
    <li><a href="#">DRP</a></li>
    </ul>
    </div>
    </div>
    </li>
    <li class="auto-style1">Welcome to IT Portal</li>
    </ul>
    </div>

    我不知道如何重新定位 <li>元素,以便它显示在下拉列中。现在我的 <li>元素显示在下拉列之外到页面中心。

    最佳答案

    只需在 #menu li ul li 类中添加 left:0 就可以了

    body, ul, li {
    font-size:14px;
    font-family:Arial, Helvetica, sans-serif;
    line-height:21px;
    text-align:left;
    margin:0;
    }

    img {
    width: auto;
    max-height: 100%;
    }

    /* Navigation Bar */

    #menu {
    list-style:none;
    margin: 50px auto auto auto;
    position: fixed; /* Set the navbar to fixed position */
    top: -50px; /* Position the navbar at the top of the page */
    width: 100%; /* Full width */

    /* Background color and gradients */
    background: #1a1a1a;
    background: -moz-linear-gradient(top, #0272a7, #013953);
    background: #1a1a1a;
    -moz-box-shadow:inset 0px 0px 1px #edf9ff;
    -webkit-box-shadow:inset 0px 0px 1px #edf9ff;
    box-shadow:inset 0px 0px 1px #edf9ff;
    }
    body {behavior: url("csshover3.htc");}

    #menu li .drop {
    background:url("img/drop.gif")
    no-repeat right 8px;
    }
    #menu li {
    border-style: none;
    border-color: inherit;
    border-width: medium;
    float:left;
    text-align:center;
    position:relative;
    padding: 4px 10px 4px 10px;
    margin-right:30px;
    margin-top:15px;
    top: -3px;
    left: 368px;
    }

    #menu li:hover {
    border: 1px solid #777777;
    padding: 4px 9px 4px 9px;

    /* Background color and gradients */

    background: #F4F4F4;
    background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));

    /* Rounded corners */

    -moz-border-radius: 5px 5px 0px 0px;
    -webkit-border-radius: 5px 5px 0px 0px;
    border-radius: 5px 5px 0px 0px;
    }

    #menu li a {
    font-family:Arial, Helvetica, sans-serif;
    font-size:14px;
    color: #EEEEEE;
    display:block;
    outline:0;
    text-decoration:none;
    text-shadow: 1px 1px 1px #000;
    }

    #menu li:hover a {
    color:#161616;
    text-shadow: 1px 1px 1px #FFFFFF;
    }
    #menu li .drop {
    padding-right:21px;
    background:url("img/drop.png") no-repeat right 8px;
    }
    #menu li:hover .drop {
    background:url("img/drop.png") no-repeat right 7px;
    }
    h1.header-line,
    h2.header-line,
    h3.header-line,
    h4.header-line,
    h5.header-line,
    h6.header-line{
    padding-bottom: 21px;
    margin-bottom: 11px;
    position:relative;
    }

    /* Drop Down */

    .dropdown_1column,
    .dropdown_2columns,
    .dropdown_3columns,
    .dropdown_4columns,
    .dropdown_5columns {
    margin:4px auto;
    float:left;
    position:absolute;
    left:-999em; /* Hides the drop down */
    text-align:left;
    padding:10px 5px 10px 5px;
    border:1px solid #777777;
    border-top:none;

    /* Gradient background */
    background:#F4F4F4;
    background: -moz-linear-gradient(top, #EEEEEE, #BBBBBB);
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EEEEEE), to(#BBBBBB));

    /* Rounded Corners */
    -moz-border-radius: 0px 5px 5px 5px;
    -webkit-border-radius: 0px 5px 5px 5px;
    border-radius: 0px 5px 5px 5px;
    }

    .dropdown_1column {width: 140px;}
    .dropdown_2columns {width: 280px;}
    .dropdown_3columns {width: 420px;}
    .dropdown_4columns {width: 560px;}
    .dropdown_5columns {width: 700px;}

    #menu li:hover .dropdown_1column,
    #menu li:hover .dropdown_2columns,
    #menu li:hover .dropdown_3columns,
    #menu li:hover .dropdown_4columns,
    #menu li:hover .dropdown_5columns {
    left:-1px;
    top:auto;
    }

    /* Columns */
    .col_1,
    .col_2,
    .col_3,
    .col_4,
    .col_5 {
    display:inline;
    float: left;
    position: relative;
    margin-left: 5px;
    margin-right: 5px;
    }
    .col_1 {width:150px;}
    .col_2 {width:270px;}
    .col_3 {width:410px;}
    .col_4 {width:550px;}
    .col_5 {width:690px;}

    .col_1 ul li {
    float:right;
    display:inline;
    }
    /* Right alignment */

    #menu .menu_right {
    float:right;
    margin-right:200px;
    }

    #menu li:hover .align_right {
    left:auto;
    right:-1px;
    top:auto;
    }

    /* Drop Down Content Stylings */

    #menu p, #menu h2, #menu h3, #menu ul li {
    font-family:Arial, Helvetica, sans-serif;
    line-height:21px;
    font-size:12px;
    text-align:left;
    /* text-shadow: 1px 1px 1px #FFFFFF; */
    }
    #menu h2 {
    font-size:21px;
    font-weight:400;
    letter-spacing:-1px;
    margin:7px 0 14px 0;
    padding-bottom:14px;
    border-bottom:1px solid #666666;
    }
    #menu h3 {
    font-size:14px;
    margin:7px 0 14px 0;
    padding-bottom:7px;
    border-bottom:1px solid #888888;
    }
    #menu p {
    line-height:18px;
    margin:0 0 10px 0;
    }

    #menu li:hover div a {
    font-size:12px;
    color:#015b86;
    }
    #menu li:hover div a:hover {
    color:#029feb;
    }
    .strong {
    font-weight:bold;
    }
    .italic {
    font-style:italic;
    }
    .imgshadow {
    background:#FFFFFF;
    padding:4px;
    border:1px solid #777777;
    margin-top:5px;
    -moz-box-shadow:0px 0px 5px #666666;
    -webkit-box-shadow:0px 0px 5px #666666;
    box-shadow:0px 0px 5px #666666;
    }
    .img_left { /* Image sticks to the left */
    width:auto;
    float:left;
    margin:5px 15px 5px 5px;
    }
    #menu li .black_box {
    background-color:#333333;
    color: #eeeeee;
    text-shadow: 1px 1px 1px #000;
    padding:4px 6px 4px 6px;

    /* Rounded Corners */
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;

    /* Shadow */
    -webkit-box-shadow:inset 0 0 3px #000000;
    -moz-box-shadow:inset 0 0 3px #000000;
    box-shadow:inset 0 0 3px #000000;
    }
    #menu li ul {
    list-style:none;
    padding:0;
    margin:0 0 12px 0;
    }
    #menu li ul li {
    font-size:12px;
    line-height:24px;
    position:relative;
    text-shadow: 1px 1px 1px #ffffff;
    padding:0;
    margin:0;
    float:none;
    text-align:left;
    width:130px;
    left:0;
    }
    #menu li ul li:hover {
    background:none;
    border:none;
    padding:0;
    margin:0;
    }
    #menu li .greybox li {
    background:#F4F4F4;
    border:1px solid #bbbbbb;
    margin:0px 0px 4px 0px;
    padding:4px 6px 4px 6px;
    width:116px;
    }

    /* Rounded Corners */
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    }
    #menu li .greybox li:hover {
    background:#ffffff;
    border:1px solid #aaaaaa;
    padding:4px 6px 4px 6px;
    margin:0px 0px 4px 0px;
    }
    <div>
    <ul id="menu" style="height: 55px; z-index: 100; left: 1px;">
    <li style="text-align: left; top: -3px; left: 6px; width: 160px; ">
    <a class="drop" style="font-size: x-large">&#9776; Menu </a>
    <div class="dropdown_5columns">
    <!-- Begin 4 columns container -->

    <div class="col_5">
    <h3 style="text-align:center">INFORMATION TECHNOLOGY</h3>
    </div>
    <div class="col_1">
    <h3>Home</h3>
    <ul>
    <li><a href="#">IT Home</a></li>
    <li><a href="#">IT Online Application</a></li>
    <li><a href="#">Silt Intranet</a></li>
    <li><a href="#">Silt.com</a></li>
    </ul>
    </div>
    <div class="col_1">
    <h3>Training Guide</h3>
    <ul>
    <li><a href="#">Email</a></li>
    <li><a href="#">Meeting Room</a></li>
    <li><a href="#">IT Orentiation Guide</a></li>
    <li><a href="#">KingSoft</a></li>
    <li><a href="#">Security Awareness</a></li>
    </ul>
    </div>
    <div class="col_1">
    <h3>Organization</h3>
    <ul>
    <li><a href="#">Organization Chart</a></li>
    <li><a href="#">*****</a></li>

    </ul>
    </div>
    <div class="col_1">
    <h3>Policies & Procedure</h3>
    <ul>
    <li><a href="#">Policies</a></li>
    <li><a href="#">Mailbox Quota</a></li>
    <li><a href="#">Escalation</a></li>
    <li><a href="#">DRP</a></li>
    </ul>
    </div>
    </div>
    </li>
    <li class="auto-style1">Welcome to IT Portal</li>
    </ul>
    </div>

    关于javascript - 如何在下拉菜单中重新定位无序列表元素 <li> 以便它显示在下拉列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43602716/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com