我在fullpagejs中创建了一张幻灯片,但标题随幻灯片一起移动并不好。如何使标题继续显示在背景图像/幻灯片中而不移动幻灯片?
如果我从背景部分取出标题,它会在幻灯片移动时停留,但它会在顶部创建一个我不想要的空白区域。我试图用绝对位置和相对位置来修复它,但似乎没有任何工作需要帮助。
$(document).ready(function(){
// $('#fullpage').fullpage({
// sectionSelector: '.vertical-scrolling',
// slideSelector: '.horizontal-scrolling',
// controlArrows: false
// // more options here
// });
// variables
var $header_top = $('.header-top');
var $nav = $('nav');
// toggle menu
$header_top.find('a').on('click', function() {
$(this).parent().toggleClass('open-menu');
});
// fullpage customization
$('#fullpage').fullpage({
sectionsColor: ['firstSection'],
loopBottom: false,
afterRender: function () {
setInterval (function () {
$.fn.fullpage.moveSlideRight ();
}, 5000);
},
// sectionSelector: '.vertical-scrolling',
// slideSelector: '.horizontal-scrolling',
navigation: true,
slidesNavigation: true,
controlArrows: false,
afterLoad: function(anchorLink, index) {
$header_top.css('background', 'rgba(0, 47, 77, .3)');
$nav.css('background', 'rgba(0, 47, 77, .25)');
setInterval(function() {
$.fn.fullpage.moveSlideRight();
}, 5000);
if (index == 1) {
$('#fp-nav').hide();
}
},
});
});

#homepage {
position: relative; }
#homepage .slider {
background-size: cover !important; }
#homepage .slider .hero {
padding: 0 25px;
display: flex;
flex-direction: column;
height: calc(100vh - 10%); }
#homepage .slider .hero .header {
padding-top: 20px;
flex: 1 1 70px;
display: flex;
align-items: center;
justify-content: space-between; }
#homepage .slider .hero .header .logo img {
cursor: pointer;
image-rendering: -webkit-optimize-contrast; }
#homepage .slider .hero .header i {
color: #fff;

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://rawgit.com/alvarotrigo/fullPage.js/master/jquery.fullPage.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://rawgit.com/alvarotrigo/fullPage.js/master/jquery.fullPage.js"></script>
<div class="container">
<div id="homepage" class="main">
<div id="fullpage">
<section class="section">
<section class="slider slide" style="background: url('http://neonrobot.com/wp-content/uploads/2014/09/unsplash-1.jpg') center center;">
<div class="hero">
<div class="header">
<div class="logo"><img src="assets/img/logo.png"></div>
<i id="menu-open" class="fa fa-bars fa-lg"></i>
</div>
<div class="welcome">
<div>
<div class="hero-headings">Hello.</div>
<div class="hero-description"></div>
</div>
</div>
</div>
<div class="clients">
<div class="padding25">
<div class="clients-intro">Our Clients. <i class="fa fa-angle-right"></i><i class="fa fa-angle-right"></i></div>
<div class="clients-logos">sds</div>
</div>
</div>
</section>
<section class="slider slide" style="background: url('http://neonrobot.com/wp-content/uploads/2014/09/unsplash-1.jpg') center center;">
<div class="hero">
<div class="header">
<div class="logo"><img src="assets/img/logo.png" alt="logo"></div>
<i id="menu-open" class="fa fa-bars fa-lg"></i>
</div>
<div class="welcome">
<div>
<div class="hero-headings">Hello.</div>
<div class="hero-description"></div>
</div>
</div>
</div>
<div class="clients">
<div class="padding25">
<div class="clients-intro">Our Clients. <i class="fa fa-angle-right"></i><i class="fa fa-angle-right"></i></div>
<div class="clients-logos">sds</div>
</div>
</div>
</section>
</section>
</div>
</div>
</div>
&#13;
答案 0 :(得分:1)
来自fullpage.js main page的菜单标题怎么样?
我已经添加了这个:
<ul id="menu">
<li class="menu-active">
<a href="#" rel="noopener">
<span>Wordpress Theme</span>
</a>
</li>
<li><a href="#examples" class="show-examples">Examples</a></li>
<li>
<a rel="noopener" href="#">Docs</a>
</li>
<li id="menu-contact"><a href="#">Contact</a></li>
<li>
<a href="#" target="_blank" rel="noopener" class="twitter-share">
</a>
</li>
<li id="menu-line" style="width: 166.953px; left: 20px;"></li>
</ul>
和一些css:
#menu {
position: fixed;
top: 20px;
right: 20px;
z-index: 70;
letter-spacing: 1px;
font-size: 1.1em;
}
#menu li {
display: inline-block;
margin: 10px 0;
}
#menu a {
color: #fff;
padding: 0 1.1em 1.1em;
}
.menu-active {
font-weight: 700;
}
你可以尝试here。它看起来更简单,因为我错过了css的某些部分,但我认为你会得到这个想法。
我不确定它是否有记录的行为,但我找到了另一个更简单的选项 - 只需添加:
<div class="fp-slidesNav top" style="color:white">
Header
</div>
在<section class="section">
之后。试一试here。