gpt4 book ai didi

html - 对齐导航栏/缩小下拉菜单框

转载 作者:行者123 更新时间:2023-11-28 01:14:00 26 4
gpt4 key购买 nike

除了我需要最后两个导航栏元素最右对齐之外,我已经获得了以下代码以使其看起来像我想要的那样。

我可以用 ul {text-align: right;宽度:100%; background-color: #48C2C5;,但是当我这样做时,它会改变我的下拉菜单的大小。

我附上了一些图片和代码。

我在 Springshare Libguides 中这样做。

没有最右边的导航栏 2 右对齐:

Nav bar without far right 2 aligned right

截断下拉菜单:

Cut off dropdown menu

  <style>
.s-lib-box {border-color: none; border-width: 0; box-shadow: none; background-color: none;}
.s-lib-box .s-lib-box-title {display: none;}
.s-lib-box .s-lg-box-footer {display: none;}
body {padding-left: 0; padding-right: 0;}
#s-lib-public-main a {color: #17365D;}
#s-lib-public-main a:visited {color: #2293c0;}



/*ABC Header*/
#header-abc {background-color: #ffffff; width: auto; }
#banner-abc {height: 110px; width: 1200px; margin-left: auto; margin-right: auto;}
#logo-abc {float: left; margin-left: 12px; margin-top: 10px;}
#search-cat {margin-top: 15px; padding: 0px 0px; text-align: right;}
#translate {padding: 2px 0px;}
#google_translate_element {width: 160px; margin: 15px 0;}

/*Menu*/

.caret{solid #ffffff;}
#menu-abc .navbar .nav > li > a, .navbar .nav > li > a:first-letter,
.navbar .nav > li.current-menu-item > a,
.navbar .nav > li.current-menu-ancestor > a {
}


#menu-abc .navbar .nav > li > a, .navbar .nav > li > a:first-letter {
color: white;
text-shadow: none;
}

#menu-abc .navbar .nav > li > a:hover, .navbar .nav > li > a:hover:first-letter {
color:#006699;
text-shadow: none;
}

#menu-abc .navbar .nav > li > a:active, .navbar .nav > li > a:active:first-letter,
.navbar .nav > li.current-menu-item > a,
.navbar .nav > li.current-menu-ancestor > a,
.navbar .nav > li.current-menu-item > a:first-letter,
.navbar .nav > li.current-menu-ancestor > a:first-letter {
color:#0099CC;
text-shadow: none;
}
#menu-abc .dropdown-menu > li > a {
color: #48C2C5;
background: white;
}

.dropdown ul li {
color:#0099CC;
}

#menu-abc .dropdown ul ul li a {
font-size:14px;
color:#0099CC;
}
#menu-abc .navbar .nav > li.current-menu-item > a, .navbar .nav > li.current-menu-ancestor > a,
.navbar .nav > li > a:hover, .navbar .nav > li > a:focus {
color: #red;
}

#menu-abc {background-color: #48C2C5; border-bottom: none;box-shadow: 3px 3px 10px 1px #green;}
#menu-abc .container-fluid {padding: 20;}
#menu-abc .navbar { min-height: 15px; background-color: #48C2C5;}
#menu-abc a {padding-right: 0px; font-family: Perpetua; font-size: 18px; font-weight: bold;}
#menu-abc a:hover {color: #red;}
.dropdown:hover .dropdown-menu {font-size: 14px; display: inline; }
.dropdown-menu > li > a {
background: #48C2C5;
border-bottom: none; }


#menu-abc {background-color: #48C2C5; border-bottom: none;box-shadow: 3px 3px 10px 1px #white;}
#menu-abc .container-fluid {padding: 0;}
#menu-abc .navbar { min-height: 15px; background-color: #48C2C5;}
#menu-abc a {padding-right: 25px; font-family: Perpetua; font-size: 18px; font-weight: bold;}
#menu-abc a:hover {color: #red;}
#menu-abc .dropdown:hover .dropdown-menu {display: block;}
.dropdown-content {
min-width: 160px;}
#menu-abc .navbar-default .navbar-collapse, #menu-abc .navbar-default .navbar-form {background-color: #48C2C5;}
#menu-abc .navbar-default {width: auto; margin-left: auto; margin-right: auto; border: none;}
#menu-abc .dropdown-menu a {color:#0099CC;}
#menu-abc .dropdown-menu a:hover {background-color: #yellow;}
#menu-abc .dropdown-menu .divider {background-color: #48C2C5;}
#menu-abc .navbar-default .navbar-nav > .open > a {color: #48C2C5; background-color: #yellow;}
#menu-abc .navbar-default .navbar-nav > li.open > a {color: #yellow; background-color: #48C2C5;}
#menu-abc .navbar-nav .dropdown:hover > a[data-toggle=dropdown] + .dropdown-menu {display: block;}
#menu-abc .navbar-nav .dropdown.open > a[data-toggle=dropdown] + .dropdown-menu {display: block;}
/*Main Content Area*/
#s-lib-public-main .row {margin-bottom: 30px; margin-left: 5px;}

<title></title>
</head>
<body class="s-lg-guide-body">
<!-- BEGIN: Page Header -->
<meta content="97a72cc605382e45-5c9ddd9618eb904f-gad80e90ba61d526a-e" name="google-translate-customization">
<div id="header-abc">
<div class="container-fluid" id="banner-abc">
<div class="row">
<div class="col-sm-6 center" id="col1">
<div class="row">
<div class="col-md-6" id="logo-abc">
<a href="http://a.m.state.sbu/sites/gis/ips/LIB/default.aspx"><img height="100" src="https://libapps.s3.amazonaws.com/accounts/27400/images/bunche_new_logo.jpg"></a>
</div><!--/logo-abc=-->
</div><!--/row-->
</div><!--/col1-->
<div class="col-sm-6" id="col0">
<div class="row">
<div class="col-md-7" id="search-cat">
<br>
</div><!--/row-->
</div><!--/col2-->
</div>
</div><!--/banner-abc-->
</div><!-- Menu -->
<div id="menu-abc">
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button class="navbar-toggle" data-target="#abc-navbar-collapse-1" data-toggle="collapse" type="button"><span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span></button>
</div><!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="abc-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<a href="#">My Account</a>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Find<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="#">Catalog</a>
</li>
<li>
<a href="#">Library Map</a>
</li>
<li class='sub'>
<a href="#">Databases</a>
<ul>
<li>
<a href="#">Current Trials</a>
</li>
</ul>
<ul>
<li>
<a href="#">Direct Access Resources</a>
</li>
</ul>
</li>
<li>
<a href="#">Find a Journal</a>
</li>
<li>
<a href="#">Ebooks</a>
</li>
<li>
<a href="#">Virtual Periodical Reading Room</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Get Help<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="#">Research & Instruction Services</a>
</li>
<li>
<a href="#">Ebook Virtual Library</a>
</li>
<li>
<a href="#">Virtual Libraries</a>
</li>
<li>
<a href="#">A - Z Journal List</a>
</li>
<li>
<a href="#">Bibliographies</a>
<ul>
<li>
<a href="#">Foreign Affairs Professional Reading List</a>
</li>
</ul>
</li>
<li>
<a>Briefing Videos</a>
</li>
<li>
<a href="#">Copyright</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Library Services<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="#">My Library Account</a>
<ul>
<li>
<a href="#">How to Create an Account</a>
</li>
</ul>
</li>
<li>
<a href="#">Acquisitions and Procurement</a>
<ul>
<li>
<a href="#">DS-2092</a>
</li>
</ul>
</li>
<li>
<a href="#">Interlibrary Loan</a>
</li>
<li>
<a href="#">Map Services</a>
</li>
<li>
<a href="#">Instruction</a>
</li>
<li>
<a href="#">Donations</a>
</li>
<li>
<a href="#">Booking the Rare Book Room</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">About Us<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="#">Mission and Vision</a>
</li>
<li>
<a href="#">Library Staff</a>
</li>
<li>
<a href="#">Policies</a>
<ul>
<li>
<a href="#">Circulation</a>
</li>
</ul>
<ul>
<li>
<a href="#">Collection Development</a>
</li>
</ul>
</li>
<li>
<a href="#">Who was Ralph Bunche?</a>
</li>
<li>
<a href="#">Rare Book Collection</a>
</li>
<li>
<a href="#">5 FAM 1400</a>
</li>
<li class="divider"></li>
<li>
<a href="#">Office of Information Programs and Services</a>
</li>
</ul>
</li>
<li style="float:right;">
<a href="#</a>
</li>
<li style="float:right;">
<a href="#">A/GIS/IPS</a>
</li>
</ul><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</div>
</nav>
</div><!-- END: Page Header Without Encore -->
<!-- END: Page Header -->
</div>
</body>
</html>

最佳答案

我知道 LibGuides 使用 Bootstrap 3,所以我放置了一个 pull-right 类,而不是最后两个列表项上的 float right。我还将 UL 元素设置为拉伸(stretch)到 100%。下面的答案只包括 HTML,不包括 CSS,但请尝试一下:

    <div id="header-abc">
<div class="container-fluid" id="banner-abc">
<div class="row">
<div class="col-sm-6 center" id="col1">
<div class="row">
<div class="col-md-6" id="logo-abc">
<a href="http://a.m.state.sbu/sites/gis/ips/LIB/default.aspx"><img height="100" src="https://libapps.s3.amazonaws.com/accounts/27400/images/bunche_new_logo.jpg"></a>
</div><!--/logo-abc=-->
</div><!--/row-->
</div><!--/col1-->
<div class="col-sm-6" id="col0">
<div class="row">
<div class="col-md-7" id="search-cat">
<br>
</div><!--/row-->
</div><!--/col2-->
</div>
</div><!--/banner-abc-->
</div><!-- Menu -->
<div id="menu-abc">
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button class="navbar-toggle" data-target="#abc-navbar-collapse-1" data-toggle="collapse" type="button"><span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span></button>
</div><!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="abc-navbar-collapse-1">
<ul class="nav navbar-nav" style="width:100%;">
<li>
<a href="#">My Account</a>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Find<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="#">Catalog</a>
</li>
<li>
<a href="#">Library Map</a>
</li>
<li class='sub'>
<a href="#">Databases</a>
<ul>
<li>
<a href="#">Current Trials</a>
</li>
</ul>
<ul>
<li>
<a href="#">Direct Access Resources</a>
</li>
</ul>
</li>
<li>
<a href="#">Find a Journal</a>
</li>
<li>
<a href="#">Ebooks</a>
</li>
<li>
<a href="#">Virtual Periodical Reading Room</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Get Help<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="#">Research & Instruction Services</a>
</li>
<li>
<a href="#">Ebook Virtual Library</a>
</li>
<li>
<a href="#">Virtual Libraries</a>
</li>
<li>
<a href="#">A - Z Journal List</a>
</li>
<li>
<a href="#">Bibliographies</a>
<ul>
<li>
<a href="#">Foreign Affairs Professional Reading List</a>
</li>
</ul>
</li>
<li>
<a>Briefing Videos</a>
</li>
<li>
<a href="#">Copyright</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Library Services<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="#">My Library Account</a>
<ul>
<li>
<a href="#">How to Create an Account</a>
</li>
</ul>
</li>
<li>
<a href="#">Acquisitions and Procurement</a>
<ul>
<li>
<a href="#">DS-2092</a>
</li>
</ul>
</li>
<li>
<a href="#">Interlibrary Loan</a>
</li>
<li>
<a href="#">Map Services</a>
</li>
<li>
<a href="#">Instruction</a>
</li>
<li>
<a href="#">Donations</a>
</li>
<li>
<a href="#">Booking the Rare Book Room</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">About Us<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="#">Mission and Vision</a>
</li>
<li>
<a href="#">Library Staff</a>
</li>
<li>
<a href="#">Policies</a>
<ul>
<li>
<a href="#">Circulation</a>
</li>
</ul>
<ul>
<li>
<a href="#">Collection Development</a>
</li>
</ul>
</li>
<li>
<a href="#">Who was Ralph Bunche?</a>
</li>
<li>
<a href="#">Rare Book Collection</a>
</li>
<li>
<a href="#">5 FAM 1400</a>
</li>
<li class="divider"></li>
<li>
<a href="#">Office of Information Programs and Services</a>
</li>
</ul>
</li>
<li class="pull-right">
<a href="#">Knowledge Portal</a>
</li>
<li class="pull-right">
<a href="#">A/GIS/IPS</a>
</li>
</ul><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</div>
</nav>
</div><!-- END: Page Header Without Encore -->
<!-- END: Page Header -->
</div>

关于html - 对齐导航栏/缩小下拉菜单框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51957885/

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