我在前端真的很新,遇到了问题。我想制作带有徽标和菜单的导航容器,其中有幻灯片背景。我做到了,它有效。但正如我所见,我的下一个内容直接显示在导航容器之外,而不是在幻灯片容器之后。我尝试将margin-top,并下拉文本文本文本内容,但在响应式设计中,例如手机,它在幻灯片放映,计算机上显示 - 幻灯片放映等等,所以margin-top是不是我想的解决方案。看来,文本内容看不到幻灯片容器结束的位置。
我正在添加一张图片来说明这个问题(在导航显示之后还添加了另一张照片,它直接显示在导航容器旁边。)
你有任何想法,如何解决这个问题?
$(function() {
if ($.browser.msie && $.browser.version.substr(0,1)<7)
{
$('li').has('ul').mouseover(function(){
$(this).children('ul').css('visibility','visible');
}).mouseout(function(){
$(this).children('ul').css('visibility','hidden');
})
}
});
/* MOBILE RESPONSIVE */
$('#menu-wrap').prepend('<div id="menu-trigger">Menu</div>');
$("menu-trigger").on("click", function(){
$("#menu").slideToggle();
});
/* IPAD RESPONSIVE */
var isiPad = navigator.userAgent.match(/iPad/i) != null;
if (isiPad) $('#menu ul').addClass('no-transition');
});
html, body {
height: 100%;
width: 100%;
}
img, video {
max-width: 100%;
}
/* HEADER START */ /* logo and menu */
.foreground-container {
width: 100%;
position: relative;
/*top: 0;*/
z-index: 99;
}
#logo-bg {
background-color: rgba(000,000,000,.7);
margin-top: 50px;
}
/* DROPDOWN MENU START */
.menu-right { /* floats menu to right */
display: flex;
justify-content: flex-end;
}
.row-eq-height {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
align-items: center;
flex-wrap: wrap;
}
#menu, #menu ul {
/*margin-top: auto;*/
/*margin: 130px 0 0 0;*/
/*margin-right: -30px;*/
padding: 0;
list-style: none;
}
#menu {
max-width: 100%; /*662*/
border: 1px solid #222;
background-color: #111;
background-image: -moz-linear-gradient(#444, #111);
background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#111));
background-image: -webkit-linear-gradient(#444, #111);
background-image: -o-linear-gradient(#444, #111);
background-image: linear-gradient(#444, #111);
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
-o-border-radius: 6px;
border-radius: 6px;
-moz-box-shadow: 0 1px 1px #777, 0 1px 0 #666 inset;
-webkit-box-shadow: 0 1px 1px #777, 0 1px 0 #666 inset;
-o-box-shadow: 0 1px 1px #777, 0 1px 0 #666 inset;
box-shadow: 0 1px 1px #777, 0 1px 0 #666 inset;
}
#menu:before,
#menu:after {
content: "";
display: table;
}
#menu: after {
clear: both;
}
#menu {
zoom: 1;
}
#menu li {
display: inline-flex;
border-right: 1px solid #222; /* Išskyrus kontaktai iš dešinės! */
-moz-box-shadow: 1px 0 0 #444;
-webkit-box-shadow: 1px 0 0 #444;
-o-box-shadow: 1px 0 0 #444;
box-shadow: 1px 0 0 #444;
position: relative;
}
#menu li:last-child {
border-right: 0px solid #222 !important;
box-shadow: 0px 0 0 #444 !important;
}
#menu a {
display: flex;
padding: 12px 30px;
color: #999;
/*text-transform: uppercase;*/
font: bold 12px Arial, Helvetica;
text-decoration: none;
text-shadow: 0 1px 0 #000;
}
#menu li:hover > a {
color: #fafafa;
}
*html #menu li a:hover {
color: #fafafa; /* IE6 only*/
}
#menu ul {
margin: 20px 0 0 0;
_margin: 0; /* IE6 only*/
opacity: 0;
visibility: hidden;
position: absolute;
top: 38px;
left: 0;
z-index: 1;
background: #444;
background: -moz-linear-gradient(#444, #111);
background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#111));
background: -webkit-linear-gradient(#444, #111);
background: -o-linear-gradient(#444, #111);
background: -ms-linear-gradient(#444, #111);
background: linear-gradient(#444, #111);
-moz-box-shadow: 0 -1px rgba(225,225,225,.3);
-webkit-box-shadow: 0 -1px 0 rgba(225,225,225,.3);
-o-box-shadow: 0 -1px 0 rgba(225,225,225,.3);
box-shadow: 0 -1px 0 rgba(225,225,225,.3);
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
border-radius: 3px;
-moz-transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
-ms-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}
#menu li:hover > ul {
opacity: 1;
visibility: visible;
margin: 0;
}
#menu ul ul {
top: 0;
left: 150px;
margin: 0 0 0 20px;
_margin: 0; /* IE6 only*/
-moz-box-shadow: -1px 0 0 rgba(255,255,255,.3);
-webkit-box-shadow: -1px 0 0 rgba(255,255,255,.3);
-o-box-shadow: -1px 0 0 rgba(255,255,255,.3);
box-shadow: -1px 0 0 rgba(255,255,255,.3);
}
#menu ul li {
/* float: none; */
display: block;
border: 0;
_line-height: 0; /* IE6 only */
-moz-box-shadow: 0 1px 0 #111, 0 2px 0 #666;
-webkit-box-shadow: 0 1px 0 #111, 0 2px 0 #666;
-o-box-shadow: 0 1px 0 #111, 0 2px 0 #666;
box-shadow: 0 1px 0 #111, 0 2px 0 #666;
}
#menu ul li:last-child {
-moz-box-shadow: none;
-webkit-box-shadow: none;
-o-box-shadow: none;
box-shadow: none;
}
#menu ul a {
padding: 10px;
/* max-width: 130px; */ /* išsiskleidžiančios lentelės plotis */
_height: 10px; /* IE6 only */
display: block;
/* ? */
/* float: none; */
text-align: center;
}
#menu ul a:hover {
background-color: #0186ba;
background-image: -moz-linear-gradient(#04acec, #0186ba);
background-image: -webkit-gradient(linear, left top, left bottom, from(#04acec), to(#0186ba));
background-image: -webkit-linear-gradient(#04acec, #0186ba);
background-image: -o-linear-gradient(#04acec, #0186ba);
background-image: -ms-linear-gradient(#04acec, #0186ba);
background-image: linear-gradient(#04acec, #0186ba);
}
#menu ul li:first-child > a {
-moz-border-radius: 3px 3px 0 0;
-webkit-border-radius: 3px 3px 0 0;
-o-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0;
}
#menu ul li:first-child > a:after {
content: '';
position: absolute;
left: 40px; /* trikampiukas nuo kairio krašto */
top: -6px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #444;
}
#menu ul ul li:first-child a:after {
left: -6px;
top: 50px;
margin-top: -6px;
border-left: 0;
border-bottom: 6px solid transparent;
border-top: 6px solid transparent;
border-right: 6px solid #3b3b3b;
}
#menu ul li:first-child a:hover:after {
border-bottom-color: #04acec;
}
#menu ul ul li:first-child a:hover:after {
border-right-color: #0299d3;
border-bottom-color: transparent;
}
#menu ul li:last-child > a {
-moz-border-radius: 0 0 3px 3px;
-webkit-border-radius: 0 0 3px 3px;
-o-border-radius: 0 0 3px 3px;
border-radius: 0 0 3px 3px;
}
/* DROPDOWN MENU END */
/* BACKGROUND MENU START */
.background-container { /* slider */
height: 100%;
width: 100%;
background-repeat: no-repeat;
position: relative;
/* background-size: cover; */
}
.slideshow-container {
position: absolute;
top: 0;
height: 100%;
width: 100%;
z-index: 0;
}
.fadein img {
-webkit-animation-name: fade; /* For Safari 5.1 to 6.0 */
-webkit-animation-duration: 40s;
-o-animation-name: fade; /* For Opera 11.1 to 12.0 */
-o-animation-duration: 40s;
-moz-animation-name: fade; /* For Firefox 3.6 to 15 */
-moz-animation-duration: 40s;
opacity: 0;
animation-name: fade;
animation-duration: 40s;
animation-iteration-count: infinite;
position: absolute; /* fixed */
}
.fadein img:nth-child(1) { animation-delay: 0s; }
.fadein img:nth-child(2) { animation-delay: 8s; }
.fadein img:nth-child(3) { animation-delay: 16s; }
.fadein img:nth-child(4) { animation-delay: 24s; }
.fadein img:nth-child(5) { animation-delay: 32s; }
@-webkit-keyframes fade {
0% {opacity: 0;}
5% {opacity: 1;}
22.5% {opacity: 1;}
27.5% {opacity: 0;}
100% {opacity: 0;}
}
@keyframes fade {
0% {opacity: 0;}
5% {opacity: 1;}
22.5% {opacity: 1;}
27.5% {opacity: 0;}
100% {opacity: 0;}
}
/* BACKGROUND MENU END */
.destymas {
position: relative;
text-align: center;
z-index: 100;
}
<!DOCTYPE html>
<html lang="lt">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="Cloud architektai">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.css">
<title>Cloud architektai</title>
</head>
<body>
<header> <!-- header start -->
<div class="foreground-container"> <!-- foreground-container start -->
<div class="nav-header"> <!-- nav-header start -->
<div class="background-container"> <!-- background-container start -->
<div class="slideshow-container"> <!-- slideshow-container start -->
<div class="fadein"> <!-- fadein start -->
<img src="images/bg-01.jpg" style="width: 100%" />
<img src="images/bg-02.jpg" style="width: 100%" />
<img src="images/bg-03.jpg" style="width: 100%" />
<img src="images/bg-04.jpg" style="width: 100%" />
<img src="images/bg-05.jpg" style="width: 100%" />
<br> <!-- not required -->
</div> <!-- fadein end -->
</div> <!-- slideshow-container end -->
</div> <!-- background-container end -->
<div class="nav-header-container container"> <!-- nav-header-container start -->
<div class="row row-eq-height"> <!-- row start -->
<div class="col-xl-4 col-lg-4 col-md-4 col-sm-4 col-xs-4">
<a href="index.html"><img id="logo-bg" src="images/logo.png" alt="logo" width="250" height="auto" /></a>
</div>
<div class="menu-right col-xl-8 col-lg-8 col-md-8 col-sm-8 col-xs-8">
<ul id="menu"> <!-- menu start -->
<li><a href="#">PROJEKTAI</a></li>
<li>
<a href="#">PASLAUGOS</a>
<ul>
<li><a href="#">PROJEKTAVIMAS</a></li>
<li><a href="#">TERITORIJŲ PLANAVIMAS</a></li>
<li><a href="#">INTERJERO DIZAINAS</a></li>
<li><a href="#">BIM</a></li>
<li><a href="#">INDIVIDUALIOS KONSULTACIJOS</a></li>
</ul>
</li>
<li><a href="#">NAUJIENOS</a></li>
<li>
<a href="#">APIE MUS</a>
<ul>
<li><a href="#">MISIJA IR VIZIJA</a></li>
<li><a href="#">KOMANDA</a></li>
<li><a href="#">STUDIJA</a></li>
<li><a href="#">APDOVANOJIMAI</a></li>
<li><a href="#">SPAUDA</a></li>
</ul>
</li>
<li><a href="#">KONTAKTAI</a></li>
</ul> <!-- menu end -->
</div>
<div class="clear:both;"></div>
</div> <!-- row end -->
</div> <!-- nav-header-container end -->
</div> <!-- nav-header end -->
</div> <!-- foreground-container end -->
<br>
</header> <!-- header end -->
<main>
<div class="destymas container">
<img src="images/bg-02.jpg" style="width: 100%" />
<h3>Text text text.</h3>
</div>
</main>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/custom.js"></script>
<script src="bootstrap-3.3.7-dist/js/bootstrap.js"></script>
</body>
</html>
答案 0 :(得分:0)
您有z-index问题。给那些应该位于position: relative; z-index: abignumbergoeshere
之上的东西。这样可以确保它始终位于其他一切之上。