Fixed/scrolling nav on fullpage.js section page - html

I'm trying to get the fixed navigation in the example below to work with fullpage.js
http://turnwall.com/demos/webdev_part11/index.html
http://www.turnwall.com/articles/adding-single-page-scrolling-navigation-to-your-site/
The issue I'm having is the active state isn't showing depending on which anchor has passed/clicked. The only thing I've differed is not using section ID's as the reference/anchor ID (need same class for sections in order for fullpage.js to work).
Also aware fullpage.js has it's own built-in nav, however, I need the flexibility of one active 'anchor' referring to/being active on a few sections, and not just displaying every single section in the nav.
Would appreciate any advice!
<script type="text/javascript" src="js/scrolloverflow.js"></script>
<script type="text/javascript" src="js/jquery.fullPage.js"></script>
<script type="text/javascript" src="js/jquery.combinedScroll.js"></script>
</head>
<div id="fullpage">
<nav class="site-navigation page-navigation">
<ul div="menu">
<li class="">Top</li>
<li class="current">One</li>
<li class="">Two</li>
</ul>
</nav>
<div class="section" data-color="red">
<div id="right"><img id="sweets" src="work/hav-2.png"/></div>
</div>
<div class="section" data-color="indigo">
</div>
</div>
<div class="section" data-color="grey">
<div id="next">NEXT PROJECT ↓</div>
</div>
</div>

I need the flexibility of one active 'anchor' referring to/being
active on a few sections, and not just displaying every single section
in the nav.
Just create your own menu as detailed in this answer.
No need to use the menu option in that case. As you want a much more custom menu that will activate the same element for multiple sections.

Related

How to add border for li for active link in html on scroll

Designing a single page application in reactjs.I have a fixed navbar on the top of the page and i have 4 section .on click of link in navabr it jumps to that particular section.But i want to highlight that li with small border below.if user scrolls to any section without clicking link in navbar,the link must be highlighted with border.
// header.js
<ul className="col-2 flex-row flex-justify-align-center ">
<li className="navigation__link">Problem</li>
<li className="navigation__link">Solution</li>
<li className="navigation__link">Footprint</li>
<li className="navigation__link">Services</li>
<li className="navigation__link">Contact</li>
</ul>
function App() {
return (
<div className="App">
<div id="problem"></div>
<Header></Header>
<div id="solution">
<Solution></Solution>
</div>
<div id="footprint">
<Footprint></Footprint>
</div>
<div id="contact">
<Contactus></Contactus>
<Footer></Footer>
</div>
</div>
);
}
Question is unclear because I didn't get how to frame question for this requirement.
You need to use scroll spy. Visit this git repository React-scrollspy.
relavent question: How to implement a scrollspy with React

Bootstrap one page website themev formatting problems

My website: zarwanhashem.com
I'm using the landing-page theme and the scrolling-nav css, which can be found here:
http://startbootstrap.com/template-overviews/landing-page/
http://startbootstrap.com/template-overviews/scrolling-nav/
2 problems:
When I navigate to different pages using the navbar the next "page" creeps up from the bottom because the page I actually navigated to doesn't fill up the entire screen. How can make it so that the extra space is just filled in with the background colour?
When I navigate to different sections the scrolling stops too late. As in, the spacing between the images and the navbar is non-existent. There should be 50px padding there to make a space equal to the size of the navbar. I tried adding padding to the divs but the padding goes into the previous section, which has a different background colour, so it doesn't fit in properly.
Also, a random bug, but there's an equal sign between two of the sections and I can't find out why.
I would appreciate any help.
Here's some of my code. All of it is public on the website so it's visible if you want to look at it. I took away the 50px padding now because of the colour issue.
Code for the robot section (The other project sections have the same structure):
<div id="robotAI" class="content-section-b">
<div class="container">
<div class="row">
<div class="col-lg-5 col-sm-6">
<hr class="section-heading-spacer">
<div class="clearfix"></div>
<h2 class="section-heading">Fighter Robot AI</h2>
<p class="lead">An object oriented robot programmed in Java. It fought robots
created by other students in an environment created by a third party. I also created other robots
and tested them against each other to determine the best strategy. A brief report summarizing how the robot's intelligence
works can be found here.</p>
</div>
<div class="col-lg-5 col-lg-offset-2 col-sm-6">
<img class="img-responsive" src="img/robotAI.png" alt="">
</div>
</div>
</div>
<!-- /.container -->
</div>
Code for the about section (The resume section has almost the same structure):
<div id="about" class="content-section-a">
<div class="container">
<div class="row">
<h2 class="section-heading" style="text-align:center">About Me</h2>
<p class="lead">I'm a passionate student who loves coding. In high school I took 3 computer science
courses, which introduced me to the world of programming. I try to make free time
in my schedule for coding so that I can fiddle around with different languages and problems. I've worked with Turing, Python, and Java. I also have a basic understanding
of HTML and CSS.
<br><br>
My other interests include martial arts and chocolate. I trained in mixed martial arts for 10 years, and currently
hold a 2nd degree black belt. The focus of my training was karate, but I also worked with tae kwon do and jujutsu.
<br><br>
I am currently seeking a software development internship/co-op position from May-August 2015. You can find more information
about me on my LinkedIn page.</p>
</div>
</div>
<!-- /.container -->
</div>
These are the only changes I've made to landing-page css (Not sure if these actually are changes, I might've reverted them back to what they were originally):
.content-section-a {
background-color: #f8f8f8;
}
.content-section-b {
border-top: 1px solid #e7e7e7;
border-bottom: 1px solid #e7e7e7;
}
Navigation bar code:
<!-- Navigation -->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand page-scroll" href="#page-top">Zarwan Hashem</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<!-- Hidden li included to remove active class from about link when scrolled up past about section -->
<li class="hidden">
<a class="page-scroll" href="#page-top"></a>
</li>
<li>About Me</li>
<li class="dropdown">
Projects <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li><a class = "page-scroll" href="#robotAI">Fighter Robot AI</a></li>
<li><a class = "page-scroll" href="#spaceInvaders">Space Invaders</a></li>
<li><a class = "page-scroll" href="#snake">Snake</a></li>
</ul>
</li>
<li>
<a class="page-scroll" href="#resume">Resume</a>
</li>
</ul>
<a class="navbar-brand pull-right">zarwan#zarwanhashem.com</a>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
Note that I'm not actually using the sections in the scrolling-nav code. I'm only using the navbar section. Also I'm very new to CSS and HTML so please dumb down your explanations a little.
if you want to make each section fill up the whole space you will have a problem that each user have different screen height, I don't know if there is a way to do it with css but I have this solution using jQuery:
<script type="text/javascript">
$(window).ready(function(){
$('div[class^="content-section"]').css('min-height', $(window).height());
})
</script>
if you already have jQuery just add this script to the bottom of the body.
as for the second problem you that's because your navigation bar is set to fixed, and the javascript handling the scrolling put the div at the top of the window, to fix that you either have to change the javascript handling the scrolling or just increase the padding-top for each section.
edit: to fix the scrolling problem you can edit the file scrolling-nav.js and change the click event handler by subtracting 50 form the offset().top:
//jQuery for page scrolling feature - requires jQuery Easing plugin
$(function() {
$('a.page-scroll').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top - 50
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});

Fit default icons into header button in jQuery Mobile

I'm trying to add a menu-style drop down button to the header of a mobile app created via jQuery Mobile, but I cannot find a way to fit the default 'gear' icon to the button. The following is the HTML page.
<div data-role="header">
<div data-role="popup" id="cfgMenu" data-theme="a">
<ul data-role="listview" data-inset="true" style="min-width: 210px;" data-theme="a">
<li data-role="divider" data-theme="a">Configura</li>
<li>Lingua
</li>
<li>Sci club
</li>
<li>Preferenze
</li>
</ul>
</div>
<h1>Title</h1>
</div>
</div>
With this HTML the result is the following:
If I add style="height:100%" to the <a> the result is the following:
What can I do to fit the icon into the image?
Just found that adding text everything is OK. But space in the header is limited, so I'd like to avoid this solution
For jQM 1.4 you use button classes instead of the data attributes:
DEMO

How to show/hide divs

I am trying to figure out how to do this... I have 4 divs that I am looking to show and hide one at a time. The link to the divs are in a separate nested div. Here's my code:
<div id="container">
<div class="roundbox">
<ul>
<li class="t">
Main
</li>
<li class="e">
News
</li>
<li class="t">
History
</li>
<li class="e">
Contact
</li>
</ul>
</div>
<div class="inceptioncontent">
<div class="content">
<div class="contentnest">
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>
<div id="4"></div>
</div>
</div>
</div>
</div>
I want the Main, News, Contact, and History links to show/hide the corresponding divs in the contentnest div. Any ideas? Thanks!
JQuery is great at doing his sort of thing. This looks like a good place to start: http://papermashup.com/simple-jquery-showhide-div/
It seems your looking for a drop down menu. You can achieve this:
Coding it in Javascript + css ( with a framework like jQuery it will be easier)
; With Css
; Downloading A plugin
I think the "Css only" is the best way, jQuery is cool and download a plugin it's the easiest way, but you need the js of the user's explorer to be on.
You can check how to do it only with css here:
https://www.grc.com/menudemo.htm

jQuery: How to make header and footer not scroll?

I have a header and footer plus a listview in the main html5 body but the issue that I am having is that when the listView is large, it scrolls the whole page including the header.
what I am trying to achieve is to just make the listview scrollable and nothing else so that the header and footer is always visible.
Is this possible in html5/jquery?
edit:
Here is what I have tried.
<link href="src/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css" />
<script src="src/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="src/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<body>
<div data-role="page" id="page">
<div data-role="header" data-position="fixed">
Back
<h1>Claim Items</h1>
</div>
<div data-role="content">
<h3 style="margin-left:1em">The Demo Title</h3>
<ul data-role="listview" id="itemList" data-inset="true" data-scroll="true">
<li>1: demo</li>
<li>2: demo</li>
<li>3: demo</li>
</ul>
</div>
<div data-role="footer" data-position="fixed" class="ui-bar">
<div data-role="navbar">
<ul>
<li>Add an Item</li>
<li> Remove an Item</li>
<li>Add comment</li>
</ul>
</div>
</div>
</div>
</body>
I think that you are asking for a fixed toolbar:
In browsers that support CSS position: fixed (most desktop browsers, iOS5+, Android 2.2+, BlackBerry 6, and others), toolbars that use the "fixedtoolbar" plugin will be fixed to the top or bottom of the viewport, while the page content scrolls freely in between. In browsers that don't support fixed positioning, the toolbars will remain positioned in flow, at the top or bottom of the page.
To enable this behavior on a header or footer, add the data-position="fixed" attribute to a jQuery Mobile header or footer element.
Fixed header markup example:
<div data-role="header" data-position="fixed">
<h1>Fixed Header!</h1>
</div>
Fixed footer markup example:
<div data-role="footer" data-position="fixed">
<h1>Fixed Footer!</h1>
</div>
Working demo here.
<div data-role="header" data-position="fixed" data-id="header1" data-tap-toggle="false" style="border-bottom:4px solid #f57122;">
<h1>Header</h1>
</div>
In my experience you need also to set data-tap-toggle to false, because you dont want the header to disappear if they click anywhere on the page. Also you need this data-id, if you have multiple pages you need the header on each page to have the same data-id so the jquery mobile will not replace current header of the active page.
EDIT:
If you experience blinking during page transitions on the actual device you have to add this to your index html also
<meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />