我试图让我的子菜单在主菜单下方打开全角。然而,它的行为很奇怪,只向右侧打开全角,而不向左侧打开。此外,当我向下滚动网页时,子菜单与我的粘性导航重叠。
旁注: 我试图像这样打开它网站
这是我的html代码:
<header class="header">
<video autoplay loop muted plays-inline class="back-video">
<source src="videos/Screen Print Halftones Portraits _ a look into Unfinished Legacy.mp4" type="video/mp4">
</video>
<div class="background-blur"></div>
<div class="nav type-a">
<nav class="left">
<ul class="nav-interior">
<li class="nav-item"><a href="#">Mens</a>
<!-- Sub-menu -->
<ul class="sub-menu">
<h9>Shop Mens</h9>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
</li>
<li class="nav-item"><a href="#">Womens</a>
</li>
<li class="nav-item"><a href="#">Accesories</a>
</li>
</ul>
</nav>
<!-- <img src="images/dist.png" alt="Garment Dist." class="logo"> -->
<h1 class="logo">Garment Dist.</h1>
<nav class="right">
<ul class="nav-interior">
<li class="nav-item"><a href="#">Search</a></li>
<li class="nav-item"><a href="#">Bag</a></li>
</ul>
</nav>
</div>
<div class="content">
<p>Act I</p>
<!-- <a id="content-link" href="#">Discover</a> -->
</div>
</header>
这是我的CSS:
* {
margin: 0;
padding: 0;
color: white;
box-sizing: border-box;
outline: none;
}
body {
color: black;
font-family: 'HelveticaNeueLTPro-Cn', arial, sans-serif;
font-size: 11px;
text-transform: uppercase;
line-height: 1.5;
letter-spacing: 0.1em;
}
div,
a {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}
/* NAV CSS */
.header {
width: 100%;
height: 100vh;
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.nav {
width: 100%;
height: 4.53125vw;
position: fixed;
top: 0;
left: 0;
padding-left: 40px;
padding-right: 40px;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 1;
/* overflow: hidden; */
}
.type-a {
font-size: 12px;
line-height: 1.5em;
letter-spacing: .15em;
font-weight: 500;
}
.sticky {
background-color: white;
position: fixed;
transition: 400ms ease-in-out;
}
.sticky ul a,
.sticky h1 {
color: black;
}
.header .logo {
font-family: inherit;
font-size: 1.5vw;
font-weight: 600;
height: auto;
display: flex;
min-width: 90px;
min-height: 15px;
}
.left .nav-interior .nav-item {
margin-right: 1.875vw;
position: relative;
}
.right .nav-interior .nav-item {
margin-left: 20px;
position: 3;
}
.back-video {
position: absolute;
right: 0;
bottom: 0;
z-index: -1;
}
@media (min-aspect-ratio: 16/9) {
.back-video {
width: 100%;
height: auto;
}
}
@media (max-aspect-ratio: 16/9) {
.back-video {
width: auto;
height: 100%;
}
}
.content {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
text-align: center;
}
.content p {
font-size: 5.9375vw;
color: white;
font-weight: 200;
margin: 0;
display: flex;
letter-spacing: -.02em;
font-family: Optima, Optima, sans-serif;
}
#content-link {
margin: 0;
padding: 0;
border: 0;
display: inline-block;
border-bottom: 1px solid white;
color: white;
text-decoration: none;
font-size: 0.90vw;
}
h1.logo {
margin-bottom: 0px;
}
/* Footer CSS */
footer {
margin-top: 30px;
padding-top: 10px;
padding-bottom: 10px;
}
.footer-content {
padding: 50px;
display: block;
display: flex;
justify-content: space-between;
align-items: center;
height: 80px;
width: auto;
}
.nav-footer {
margin: 0;
padding: 0;
border: 0;
height: 100%;
font: inherit;
font-size: 0.72vw;
vertical-align: baseline;
display: flex;
justify-content: flex-end;
}
.nav-footer-item a {
margin-right: 0;
margin-left: 1.875vw;
list-style: none;
color: black;
text-decoration: none;
}
.newsletter {
width: inherit;
height: inherit;
}
.newsletter img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
/* Main Section CSS */
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 20px;
padding: 20px;
}
figure {
margin: 0;
padding: 0;
position: relative;
text-align: center;
font-family: Optima, Optima, sans-serif;
}
img {
max-width: 100%;
height: auto;
}
figcaption {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
text-align: center;
flex-direction: column;
justify-content: center;
font-size: 4vw;
display: flex;
font-family: inherit;
}
.left {
width: 40%;
height: 100%;
}
.right {
width: 40%;
height: 100%;
}
.nav-interior {
display: flex;
height: 100%;
justify-content: flex-start;
line-height: 1.5em;
position: relative;
}
.right .nav-interior {
justify-content: flex-end;
}
nav {
display: block;
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
}
nav ul,
nav ol,
nav li {
margin: 0;
padding: 0;
list-style: none;
}
.nav .nav-interior {
height: 100%;
display: flex;
align-items: center;
padding: 0.52083vw 0;
}
nav a {
text-decoration: none;
color: inherit;
font-family: 'HelveticaPro';
}
/* .nav .nav-interior .nav-item a {
position: relative;
display: block;
} */
/* Hover Effects CSS */
.nav-interior .nav-item>a:hover,
.nav-footer-item a:hover {
color: black;
text-decoration: none;
border-bottom: 1px solid;
transition: opacity .2s ease;
}
.sub-menu {
display: none;
position: absolute;
background-color: #555;
width: 50vw;
left: 0;
}
/* Display sub-menu when hovering over main menu item */
.nav-interior li:hover .sub-menu {
display: block;
}
.sub-menu li a {
color: #fff;
display: block;
padding: 10px 10px;
text-decoration: none;
left: 0;
}