我只想将这4个锚定标签li
放在此ul
内部。
是否有办法将这四个包装到一个容器中,然后用CSS
将其移到左侧?我只希望这4个项目显示在该ul的中心。
这是我在说什么的照片
下面是我在HTML
中的总标题。 CSS
太多了,所以我不知道该把人们链接到什么,但是我会把我一直在玩的东西放在下面。
<!-- Header -->
<header class="header header-fixed header-fixed-on-mobile header-transparent" data-bkg-threshold="100">
<div class="header-inner">
<div class="row nav-bar">
<div class="column width-12 nav-bar-inner">
<div class="logo">
<div>
<a href="tel:1-530-680-8255" style="color:grey; display:inline-block">1-530-680-
8255</a>
<a href="tel:1-530-680-8255"><i class="fas fa-phone" style="display:inline-block">
</i>1-530-680-8255</a>
</div>
</div>
<nav class="navigation nav-block secondary-navigation nav-right">
<ul>
<li class="aux-navigation hide">
<!-- Aux Navigation -->
<a href="#" class="navigation-show side-nav-show nav-icon">
<span class="icon-menu"></span>
</a>
</li>
</ul>
</nav>
<nav class="navigation nav-block primary-navigation nav-center">
<ul>
<li class="current"><a href="index.html">Home <i class="fas fa-home"></i></a></li>
<li class="current"><a href="index.html">About <i class="fas fa-at"></i></a></li>
<li class="current"><a href="index.html">Services <i class="fas fa-wrench"></i> </a></li>
<li class="current"><a href="index.html">Contact <i class="fas fa-phone"></i> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
</header>
<!-- Header End -->
---CSS---
nav ul li {
display: inline-block;
text-align: center;
width: 100px;
margin: 00px;
padding: 0px;
}
答案 0 :(得分:1)
我可以通过添加此CSS(而不是您显示的CSS)来做到这一点:
<style>
.logo {
max-width: 300px;
width: 30%;
float; left;
display: block;
}
.navigation {
display: block;
clear: both;
max-width: 70%;
float: right;
width: 700px;
}
.navigation ul {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.navigation ul li {
text-align: center;
width: 100px;
margin: 0;
padding: 0;
display: block;
}
</style>
因此,您只需将所有代码添加到网站的<head>
部分中,然后它就可以正常工作。
答案 1 :(得分:0)
莎拉或其他人:
所提供的解决方案以它为中心,但是电话号码现在已切断。
我包括我认为与CSS相关的所有内容。我希望这不是太多筛选,我只是不知道是什么原因造成的。
[4. Header Styling]
*/
/* Initial Position */
.header-bottom{
bottom: 0.1rem;
}
/* Intial Height */
.header .logo,
.header .header-inner .navigation > ul > li,
.header .header-inner .navigation > ul > li > a:not(.button),
.header .header-inner .dropdown > .nav-icon{
height: 8rem;
line-height: 8rem;
}
/* Compacted Height */
.header-compact .logo,
.header-compact .header-inner .navigation > ul > li,
.header-compact .header-inner .navigation > ul > li > a:not(.button),
.header-compact .header-inner .dropdown > .nav-icon{
height: 6rem;
line-height: 6rem;
}
/* Header Initial Styling */
.header .header-inner{
background-color: #fff;
border-bottom: none;
border-bottom: 1px solid #eee;
}
.header .header-inner > .nav-bar{
/*border-bottom: 1px solid #eee;*/
}
/* Transparent Header Initial & Active Nav Colors */
.header-transparent .header-inner{
background-color: transparent;
border-bottom: 1px solid transparent;
}
.header-transparent .header-inner > .nav-bar{
border-bottom: 1px solid rgba(255,255,255, 0.2);
}
/* Background Header - On Scroll! */
.header-background .header-inner{
background-color: #fff;
border-color: #eee;
}
.header-background .header-inner > .nav-bar{
border-bottom: none;
}
/* Header Inner Top */
.header .header-inner-top{
height: 4rem;
background: #232323;
color: #fff;
}
/* Mobile Header Styles & Breakpoints */
.mobile .header .header-inner{
background-color: #fff;
border-top: none;
}
.mobile .header .header-inner{
border-bottom: 1px solid #eee;
}
.mobile .header + .content{
padding-top: 0;
}
@media only screen and (max-width: 960px){
.header .header,
.header .header-inner,
.header.header-transparent .header-inner{
background-color: #fff;
}
.header .header-inner{
border-bottom: 1px solid #eee;
}
.header .header-inner > .nav-bar{
padding: 0;
}
}
/*------------------------------------------------------------------
[5. Header Logo]
*/
/* Initial Logo Width */
.header .logo{
width: 12.5rem;
top: 30px;
left: 0px;
position: absolute;
}
/* Compacted Header Logo Width */
.header-compact .logo{
width: 12.5rem;
}
/* Initial Logo Styling */
.header .logo a{
display: block !important;
position: absolute;
top: 0;
}
.header-in .logo a,
.header-out .logo a{
-webkit-transition-duration: 0ms;
transition-duration: 0ms;
}
.header .logo a:first-child{
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0);
}
.header .logo a + a{
display: none !important;
}
/* Transparent Header Show Light Logo */
.header-transparent .logo a:first-child{
opacity: 0;
-webkit-transform: translateY(5rem);
transform: translateY(5rem)
}
.header-transparent .logo a + a{
display: block !important;
-webkit-transform: translateY(0);
transform: translateY(0);
}
/* Header Background Logo Swap to Dark Logo - On Scroll! */
.header-background .logo a:first-child{
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0);
}
.header-background .logo a + a{
display: block !important;
opacity: 0;
-webkit-transform: translateY(-5rem);
transform: translateY(-5rem);
}
/* Logo Nav Dark */
.nav-dark .logo a:first-child{
display: block !important;
top: 0;
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0);
}
.nav-dark .logo a:last-child{
display: none !important;
}
/* Logo Mobile Header & Breakpoints */
.mobile .header .logo a:first-child{
display: block !important;
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0);
}
@media only screen and (max-width: 960px){
.header .logo-inner{
display: table-cell;
vertical-align: middle;
}
.header .logo a{
position: relative;
}
.header .logo a:first-child{
opacity: 1;
top: 0;
-webkit-transform: translateX(0) !important;
transform: translateX(0) !important;
}
.header .logo a:last-child{
display: none !important;
}
}
/*------------------------------------------------------------------
[6. Header Navigation]
*/
/* Padding & Margins */
<style>
.navigation {
width: 100%;
display: block;
clear: both;
}
.navigation ul {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 100%;
}
.navigation ul li {
text-align: center;
width: 100px;
margin: 0;
padding: 0;
display: block;
}
</style>
.header .logo-center ~ .navigation.nav-center{
padding-top: 0.5rem;
}
.header .logo-center ~ .navigation.nav-center > ul > li > a{
padding-bottom: 2rem;
}
.header .navigation > ul > li > a{
margin: 0 1.5rem;
padding-left: 0;
padding-right: 0;
font-size: 1.1rem;
text-transform: uppercase;
font-weight: 500;
letter-spacing: 0;
}
/* Header Initial & Active Nav Colors */
.header .navigation > ul > li > a{
color: #999;
opacity: 1;
}
.header .navigation > ul > li.current > a,
.header .navigation > ul > li > a:hover{
color: #000;
opacity: 1;
}
.header .navigation > ul > li.current > a:hover{
color: #000;
}
/* Transparent Header Initial, Hover & Current Nav Colors */
.header-transparent .navigation > ul > li > a{
color: #fff;
opacity: 0.6;
}
.header-transparent .navigation > ul > li > a:hover{
color: #fff;
opacity: 1;
}
.header-transparent .navigation > ul > li.current > a,
.header-transparent .navigation > ul > li.current > a:hover{
color: #fff;
opacity: 1;
}
/* Nav Dark Initial, Hover & Current Colors */
.header-transparent.nav-dark .navigation > ul > li > a{
color: #000;
opacity: 0.5;
}
.nav-dark .navigation > ul > li.current > a,
.nav-dark .navigation > ul > li.current > a:hover{
color: #000;
opacity: 1;
}
/* Header Background Initial, Hover & Current Nav Colors - On Scroll! */
.header-background .navigation > ul > li > a{
color: #999;
}
.header-background .navigation > ul > li.current > a{
color: #000;
border-bottom: none;
}
.header-background .navigation > ul > li.current > a:hover{
color: #000;
}
.header-background .navigation > ul > li > a:hover{
color: #000;
opacity: 1;
}
/* Sub Menus, Mega Menus, Dropdown List Initial Colors */
.navigation .sub-menu li,
.navigation .dropdown-list li{
border-bottom: none;
}
.navigation .sub-menu li a,
.navigation .mega-sub-menu ul li a,
.navigation .dropdown-list li a{
line-height: 1.6;
font-weight: 400;
font-size: 1.2rem;
color: #888;
}
.navigation .sub-menu:not(.custom-content) li a,
.navigation .dropdown-list:not(.custom-content) li a{
padding: 1rem 1.5rem;
}
.navigation .mega-sub-menu > li > a{
font-size: 1.3rem;
}
.navigation .sub-menu:not(.custom-content) a,
.navigation .sub-menu.custom-content,
.navigation .mega-sub-menu,
.navigation .dropdown-list{
background-color: #111;
}
/* Menu Nav Cart Intial Colors */
.navigation .cart .badge{
top: -0.4rem;
left: 1.2rem;
background-color: #9a9484;
}
.navigation .cart-overview .product-title{
color: #fff;
}
.navigation .cart-overview .product-price,
.navigation .cart-overview .product-quantity{
color: #999;
}
.navigation .cart-overview a.product-remove{
background-color: #444;
color: #999;
}
.navigation .cart-overview .cart-subtotal{
color: #fff;
}
.navigation .cart-overview .cart-actions{
border-color: #444;
}
.navigation .cart-overview .checkout.button{
background-color: #9a9484;
border-color: transparent;
color: #fff;
}
.navigation .cart-overview .checkout.button:hover{
background-color: #666;
border-color: transparent;
color: #fff;
}
/* Sub Menus, Mega Menus, Dropdown List Hover Colors */
.navigation .sub-menu:not(.custom-content) li:hover > a,
.navigation .mega-sub-menu:not(.custom-content) ul li:hover > a,
.navigation .dropdown-list:not(.custom-content) li:hover a{
background-color: #000;
}
.navigation .sub-menu li > a:not(.button):hover,
.navigation .mega-sub-menu ul li > a:not(.button):hover,
.navigation .dropdown-list li > a:not(.button):hover,
.navigation .cart-overview .product-title:hover,
.navigation .cart-overview .product-remove:hover{
color: #fff;
}
.navigation .sub-menu li.current > a:not(.button),
.navigation .dropdown-list li.current > a:not(.button),
.navigation .mega-sub-menu ul li.current > a:not(.button){
color: #fff;
}
/* Mega Menu Position */
.navigation .mega-sub-menu{
left: 0;
right: 0;
}
/* Labels Sub Menu */
.sub-menu li .label,
.mega-menu li .label,
.dropdown li .label{
margin-left: 0.5rem;
padding: 0.1rem 0.4rem;
font-size: 1rem;
text-transform: uppercase;
background-color: #9a9484;
border-color: #9a9484;
color: #fff;
}