gpt4 book ai didi

javascript - 轮播(图像 slider )与响应式菜单冲突

转载 作者:行者123 更新时间:2023-11-28 01:58:49 25 4
gpt4 key购买 nike

您好亲爱的开发者社区,我几天前开始编程。我开始为艺术家制作主页。

我有一个响应式菜单,当屏幕变小时,它会转换为带有按钮的下拉菜单。它还具有滚动效果。添加轮播(图像 slider )时:菜单栏变得困惑。我已经制作了屏幕截图,以明确问题:

问题 1

enter image description here

菜单栏移向右侧。它应该填满屏幕的顶部

问题2

enter image description here

当屏幕变小时,Bar 会向底部移动。

我希望有人可以帮助我解决这个问题。
这里的代码:

html, body {
margin: 0;
padding: 0;
width: 100%;
}

body {
font-family: "Helvetica Neue",sans-serif;
font-weight: lighter;
}

header {
width: 100%;
height: 100vh;
background-color: #111
background: url(bilder/acrylic/63.jpg) no-repeat 50% 50%;
background-size: cover;
}

.content {
width: 94%;
margin: 4em auto;
font-size: 20px;
line-height: 30px;
text-align: justify;
}

.logo {
line-height: 40px;
position: fixed;
float: left;
margin: 16px 46px;
color: #fff;
font-weight: bold;
font-size: 20px;
letter-spacing: 2px;
height:40px;
}

nav {
position: fixed;
width: 100%;
line-height: 60px;
}

nav ul {
line-height: 40px;
list-style: none;
background: rgba(0, 0, 0, 0);
overflow: hidden;
color: #fff;
padding: 0;
text-align: right;
margin: 0;
padding-right: 40px;
transition: 1s;
}

nav.black ul {
background: #111; opacity: 50%
}

nav ul li {
display: inline-block;
padding: 16px 40px;;
}

nav ul li a {
text-decoration: none;
color: #fff;
font-size: 16px;
text-transform: uppercase;
margin: 0 10px;
}
nav ul li a,
nav ul li a:after,
nav ul li a:before {
transition: all .5s;
}
nav ul li a:hover {
color: #555;
}


.menu-icon {
line-height: 40px;
width: 100%;
background: #111;
text-align: right;
box-sizing: border-box;
padding: 15px 24px;
cursor: pointer;
color: #fff;
display: none;
}

@media(max-width: 786px) {

.logo {
position: fixed;
top: 0;
margin-top: 16px;
}

nav ul {
max-height: 0px;
background: #111;
}

nav.black ul {
background: #111;
}

.showing {
max-height: 34em;
}

nav ul li {
box-sizing: border-box;
width: 100%;
padding: 24px;
text-align: center;
}

.menu-icon {
display: block;
}

}


nav.shift ul li a {
position:relative;
z-index: 1;
}
nav.shift ul li a:hover {
color: #777;
}
nav.shift ul li a:after {
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: 100%;
height: 1px;
content: '.';
color: transparent;
background: ;
visibility: none;
opacity: 0;
z-index: -1;
}
nav.shift ul li a:hover:after {
opacity: 1;
visibility: visible;
height: 100%;
}

.img {
min-height: 15%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Viktoria Nagel</title>
<link rel="stylesheet" href="css.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
</head>

<body>


<!-- IMAGE SLIDER -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

<div class="container">
<div class="row">
<div class="col-md-12">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">

<div class="carousel-inner">
<div class="item active">
<img src="https://imgur.com/J5AvznH" alt="First slide">
<div class="carousel-caption">
<h3>
Acrylic</h3>
<p>
Wildlife, Stillife</p>
</div>
</div>
<div class="item">
<img src="https://imgur.com/buAVgjt" alt="Second slide">
<div class="carousel-caption">
<h3>
Pencil</h3>
<p>
Portrait, Nude</p>
</div>
</div>
<div class="item">
<img src="https://imgur.com/IysG1mL" alt="Third slide">
<div class="carousel-caption">
<h3>
Pottery</h3>
<p>
Vases, Bowls</p>
</div>
</div>
</div>

</div>
<div class="main-text hidden-xs">
<div class="col-md-12 text-center">
<h1>
Viktoria Nagel</h1>
<h3>
Master of Fine Art</h3>

</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<!--END SLIDER -->

<!--MENU-->

<div class="wrapper">
<header>

<nav class="shift">

<div class="menu-icon">
<i class="fa fa-bars fa-2x"></i>
</div>

<div class="logo">
<img src="vnlogow.png" height="50px">
</div>

<div class="menu">

<ul>
<li><a href="index.html">Home</a></li>
<li><a href="index.html">About</a></li>
<li><a href="gallery.html">Gallery</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
</nav>

</header>

<!-- End MENU-->

<div class="content">

<div container>
<div class="img">
<img src="bilder/acrylic/01.jpg"
width="20%"
style="float: left; padding: 25px 10px 1000px 0px"

>
</div>


<p>

Dear viewer,
My name is Viktoria Nagel.<br> I was born in Russia in 1969, although my roots go back to Germany.
<br>
My family and I have been working in the beautiful town of Lorch in southern Germany since 1996. This is where we have found our home and we lead happy lives here.
<br>
It was only after we settled down in Lorch that my painting hobby became my pure and all-consuming passion. After a few years of practice, accumulating experience through my own experimentation, I was ready to exhibit my artwork. I was overwhelmed by the positive response and demand for my work, which has since enabled me to transform my hobby into a career. I have been working as an independent and freelance artist with "VN-Arts" since 2010.
<br>
I am enthusiastic about sharing my knowledge and skill, so I also offer painting and pottery courses.
<br><br>
In my relatively short, full-time art career, I am grateful to have met with encouraging successes, for example:
<br><br>
<b>2009</b> Finalist "International Art Competition X-Power Gallery" Beverly Hills, USA
<br><br>
<b>2010</b> Finalist "International Art Competition X-Power Gallery" Taipei/Taiwan
<br><br>
<b>2010</b> First place at "Russian Art Week" Moscow (international Exhibition and Contemporary Art Competition)
<br><br>
<b>2011</b> Art and X-Power Gallery Exhibition in New York GP DEVA USA
<br><br>
<b>2011</b> Forth Open Art 2011. Artist from Europe in Baden-Baden.
<br><br>
My specialities include acrylic painting and the photorealistic rendering of people, nature and animals.
<br>
With every work my goal is to capture, on canvas, the beauty and emotion of my subject and, in the most beautiful way possible, to serve this to the viewer.
<br>
My wish is that you would thoroughly enjoy and have fun as you view my artworks, and I greatly look forward to your feedback.
<br>
Kind regards,
V. Nagel
</p>
</div>
</div>
</div>

<!---Script Menu-->

<script type="text/javascript">

// Menu-toggle button

$(document).ready(function() {
$(".menu-icon").on("click", function() {
$("nav ul").toggleClass("showing");
});
});

// Scrolling Effect

$(window).on("scroll", function() {
if($(window).scrollTop()) {
$('nav').addClass('black');
}

else {
$('nav').removeClass('black');
}
})


</script>

</body>

</html>

非常感谢!

你好,埃迪。

最佳答案

现在请看你的问题解决了。复制并粘贴到您的 html 页面

    <!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Viktoria Nagel</title>
<link rel="stylesheet" href="css.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
}

body {
font-family: "Helvetica Neue",sans-serif;
font-weight: lighter;
}

header {
width: 100%;
height: 100vh;
background-color: #111
background: url(bilder/acrylic/63.jpg) no-repeat 50% 50%;
background-size: cover;
}

.content {
width: 94%;
margin: 4em auto;
font-size: 20px;
line-height: 30px;
text-align: justify;
}

.logo {
line-height: 40px;
position: fixed;
float: left;
margin: 16px 46px;
color: #fff;
font-weight: bold;
font-size: 20px;
letter-spacing: 2px;
height:40px;
}

nav {
position: fixed;
width: 100%;
line-height: 60px;
left: 0;
}

nav ul {
line-height: 40px;
list-style: none;
background: rgba(0, 0, 0, 0);
overflow: hidden;
color: #fff;
padding: 0;
text-align: right;
margin: 0;
padding-right: 40px;
transition: 1s;
}

nav.black ul {
background: #111; opacity: 50%
}

nav ul li {
display: inline-block;
padding: 16px 40px;;
}

nav ul li a {
text-decoration: none;
color: #fff;
font-size: 16px;
text-transform: uppercase;
margin: 0 10px;
}
nav ul li a,
nav ul li a:after,
nav ul li a:before {
transition: all .5s;
}
nav ul li a:hover {
color: #555;
}


.menu-icon {
line-height: 40px;
width: 100%;
background: #111;
text-align: right;
box-sizing: border-box;
padding: 15px 24px;
cursor: pointer;
color: #fff;
display: none;
}

@media(max-width: 786px) {

.logo {
position: fixed;
top: 0;
margin-top: 16px;
}

nav ul {
max-height: 0px;
background: #111;
}

nav.black ul {
background: #111;
}

.showing {
max-height: 34em;
}

nav ul li {
box-sizing: border-box;
width: 100%;
padding: 24px;
text-align: center;
}

.menu-icon {
display: block;
}

}


nav.shift ul li a {
position:relative;
z-index: 1;
}
nav.shift ul li a:hover {
color: #777;
}
nav.shift ul li a:after {
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: 100%;
height: 1px;
content: '.';
color: transparent;
background: ;
visibility: none;
opacity: 0;
z-index: -1;
}
nav.shift ul li a:hover:after {
opacity: 1;
visibility: visible;
height: 100%;
}

.img {
min-height: 15%;
}
</style>
</head>

<body>


<!-- IMAGE SLIDER -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

<div class="container">
<div class="row">

<div class="wrapper">
<header>

<nav class="shift">

<div class="menu-icon">
<i class="fa fa-bars fa-2x"></i>
</div>

<div class="logo">
<img src="vnlogow.png" height="50px">
</div>

<div class="menu">

<ul>
<li><a href="index.html">Home</a></li>
<li><a href="index.html">About</a></li>
<li><a href="gallery.html">Gallery</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
</nav>

</header>

<div class="content">

<div class="container">
<div class="img">
<img src="bilder/acrylic/01.jpg" width="20%" style="float: left; padding: 25px 10px 1000px 0px">
</div>


<p>

Dear viewer, My name is Viktoria Nagel.<br> I was born in Russia in 1969, although my roots go back to Germany.
<br> My family and I have been working in the beautiful town of Lorch in southern Germany since 1996. This is where we have found our home and we lead happy lives here.
<br> It was only after we settled down in Lorch that my painting hobby became my pure and all-consuming passion. After a few years of practice, accumulating experience through my own experimentation, I was ready to exhibit
my artwork. I was overwhelmed by the positive response and demand for my work, which has since enabled me to transform my hobby into a career. I have been working as an independent and freelance artist with "VN-Arts" since
2010.
<br> I am enthusiastic about sharing my knowledge and skill, so I also offer painting and pottery courses.
<br><br> In my relatively short, full-time art career, I am grateful to have met with encouraging successes, for example:
<br><br>
<b>2009</b> Finalist "International Art Competition X-Power Gallery" Beverly Hills, USA
<br><br>
<b>2010</b> Finalist "International Art Competition X-Power Gallery" Taipei/Taiwan
<br><br>
<b>2010</b> First place at "Russian Art Week" Moscow (international Exhibition and Contemporary Art Competition)
<br><br>
<b>2011</b> Art and X-Power Gallery Exhibition in New York GP DEVA USA
<br><br>
<b>2011</b> Forth Open Art 2011. Artist from Europe in Baden-Baden.
<br><br> My specialities include acrylic painting and the photorealistic rendering of people, nature and animals.
<br> With every work my goal is to capture, on canvas, the beauty and emotion of my subject and, in the most beautiful way possible, to serve this to the viewer.
<br> My wish is that you would thoroughly enjoy and have fun as you view my artworks, and I greatly look forward to your feedback.
<br> Kind regards, V. Nagel
</p>
<div class="col-md-12">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">

<div class="carousel-inner">
<div class="item active">
<img src="http://via.placeholder.com/1000x350" alt="First slide">
<div class="carousel-caption">
<h3>
Acrylic</h3>
<p>
Wildlife, Stillife</p>
</div>
</div>
<div class="item">
<img src="http://via.placeholder.com/1000x350" alt="Second slide">
<div class="carousel-caption">
<h3>
Pencil</h3>
<p>
Portrait, Nude</p>
</div>
</div>
<div class="item">
<img src="http://via.placeholder.com/1000x350" alt="Third slide">
<div class="carousel-caption">
<h3>
Pottery</h3>
<p>
Vases, Bowls</p>
</div>
</div>
</div>

</div>
<div class="main-text hidden-xs">
<div class="col-md-12 text-center">
<h1>
Viktoria Nagel</h1>
<h3>
Master of Fine Art</h3>

</div>
</div>
</div>

</div>
</div>
</div>

<!---Script Menu-->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript">
// Menu-toggle button

$(document).ready(function() {
$(".menu-icon").on("click", function() {
$("nav ul").toggleClass("showing");
});
});

// Scrolling Effect

$(window).on("scroll", function() {
if($(window).scrollTop()) {
$('nav').addClass('black');
}

else {
$('nav').removeClass('black');
}
})
</script>

</body>

</html>

关于javascript - 轮播(图像 slider )与响应式菜单冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49468992/

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