Ik probeer een responsive webdesign te maken waarbij bij een klik op een menu item de site scrolled.
De menubar word fixed wanneer deze de top bereikt en om de volgende div de resterende ruimte te laten vullen gebruik ik een ghost div, deze maakt het onmogelijk de andere divs de juist hoogte te geven.
Kan iemand mij verder helpen?
html
css
jquery
De menubar word fixed wanneer deze de top bereikt en om de volgende div de resterende ruimte te laten vullen gebruik ik een ghost div, deze maakt het onmogelijk de andere divs de juist hoogte te geven.
Kan iemand mij verder helpen?
html
Code:
[HTML]
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv='Content-Type' content='Type=text/html; charset=utf-8'>
<title>test</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="iecss.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="date/jquery.datetimepicker.css"/>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel='stylesheet' media='screen and (min-width: 768px) and (max-width: 1030px)' href='css/1024.css' />
<link rel='stylesheet' media='screen and (min-width: 1190px) and (max-width: 1290px)' href='css/medium.css' />
<link rel='stylesheet' media='screen and (min-width: 1300px) and (max-width: 1400px)' href='css/big.css' />
<link rel='stylesheet' media='screen and (min-width: 1050px) and (max-width: 1205px)' href='css/1220.css' />
<link rel='stylesheet' media='screen and (min-width: 1360px) and (max-width: 1370px)' href='css/1366.css' />
<link rel='stylesheet' media='screen and (min-device-width: 768px) and (max-device-height: 1024px) and (orientation: portrait) and (-webkit-min-device-pixel-ratio: 1)' href='css/ipad.css' />
<link href='http://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<div id="header"></div>
<div class="menubar">
<div class="linksmenu"></div>
<div class="rechtsmenu">
<div class="menu">
<li><a href="#header">test1</li>
<li><a href="#first">test2</li>
<li><a href="#second">test3</a></li>
<li><a href="#derde">test4</a></li>
<li><a href="#vierde">test5</a></li>
<li><a href="#vijfde">test6</a></li>
<li><a href="#zesde">test7</a></li>
</div>
</div>
</div>
<div class="ghost"></div>
<div id="first"></div>
<div id="second"></div>
<div id="derde"></div>
<div id="vierde"></div>
<div id="vijfde"></div>
<div id="zesde"></div>
</body>
</html>
css
Code:
html, body{
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
}
.holder{
background-color: #ffffff;
width: 100%;
height: 2500px;
}
#header{
background-color: #ffffff;
width: 100%;
height: 400px;
}
/* Menubar */
.menubar, .ghost{
background-color: #000000;
width: 100%;
height: 100px;
position: absolute;
}
.ghost{
background-color: #000000;
z-index: 10;
}
.menubar{
background-color: #000000;
z-index: 1000;
}
.linksmenu{
width: 20%;
height: 100px;
float: left;
}
.logo{}
.rechtsmenu{
width: 80%;
height: 100px;
float: left;
}
.menu{
width: 80%;
height: 20px;
padding-top: 39px;
padding-left: 100px;
border: 0px none;
}
@font-face {
font-family: 'Roboto-Regular-webfont';
src: url('../fonts/Roboto-Regular-webfont.eot'),
url('../fonts/Roboto-Regular-webfont.woff') format('woff'), /* Pretty Modern Browsers */
url('../fonts/Roboto-Regular-webfont.ttf') format('truetype'); /* Pretty Modern Browsers */
}
.menu li {
float: left;
padding-left: 20px;
font-family: 'Roboto-Regular-webfont';
font-size: 20px;
display: block;
list-style-type: none;
color: #ffffff;
outline-width: 0;
}
.menu li a:link{
float: left;
font-family: 'Roboto-Regular-webfont';
font-size: 20px;
display: block;
text-decoration: none;
list-style-type: none;
color: #ffffff;
outline-width: 0;
}
.menu li a:visited{
float: left;
font-family: 'Roboto-Regular-webfont';
font-size: 20px;
display: block;
text-decoration: none;
list-style-type: none;
color: #ffffff;
outline-width: 0;
}
.menu li a:hover{
float: left;
font-family: 'Roboto-Regular-webfont';
font-size: 20px;
display: block;
text-decoration: none;
list-style-type: none;
color: #FF8000;
outline-width: 0;
}
/* Einde menubar */
.fixed {
clear: both;
position: fixed;
top:0; left:0;
width: 100%; }
#first{
background-color: #FE9A2E;
width: 100%;
font-size: 12px;
color: #ffff00;
}
#second{
background-color: #ffffff;
width: 100%;
font-size: 12px;
color: #ffff00;
}
.one{
background-color: #FE9A2E;
width: 100%;
}
.two{
background-color: #81BEF7;
width: 100%;
}
#derde{
background-color: #81BEF7;
width: 100%;
font-size: 12px;
color: #ffff00;
}
#vierde{
background-color: #ffffff;
width: 100%;
font-size: 12px;
color: #ffff00;
}
#vijfde{
background-color: #74DF00;
width: 100%;
font-size: 12px;
color: #ffff00;
}
#zesde{
background-color: #ffffff;
width: 100%;
font-size: 12px;
color: #ffff00;
}
jquery
Code:
$(window).scroll(function(){
var menubar = $('.menubar'),
scroll = $(window).scrollTop();
if (scroll >= 400) menubar.addClass('fixed');
else menubar.removeClass('fixed');
});
$(document).ready(function() {
function setHeight() {
windowHeight = $(window).height();
$('#first').css('min-height', windowHeight);
};
setHeight();
$(window).resize(function() {
setHeight();
});
});
$(document).ready(function() {
function setHeight() {
var windowHeight = $(window).height();
$('#second').css('min-height', windowHeight);
};
setHeight();
$(window).resize(function() {
setHeight();
});
});
$(document).ready(function() {
var divHeight = $('.first').height()/2;
$('.one').css('min-height', divHeight );
});
$(document).ready(function() {
var divHeight = $('.first').height()/2;
$('.two').css('min-height', divHeight );
});
$(document).ready(function() {
function setHeight() {
var windowHeight = $(window).height();
$('#derde').css('height', windowHeight - 100);
};
setHeight();
$(window).resize(function() {
setHeight();
});
});
$(document).ready(function(){
function setHeight() {
var windowHeight = $(window).height();
$('#vierde').css('min-height', windowHeight - 100);
};
setHeight();
$(window).resize(function() {
setHeight();
});
});
$(document).ready(function(){
function setHeight() {
var windowHeight = $(window).height();
$('#vijfde').css('min-height', windowHeight);
$('#vijfde').css('paddingTop', 100);
};
setHeight();
$(window).resize(function() {
setHeight();
});
});
$(document).ready(function() {
function setHeight() {
var windowHeight = $(window).height();
$('#zesde').css('min-height', windowHeight);
$('#zesde').css('paddingTop', 100);
};
setHeight();
$(window).resize(function() {
setHeight();
});
});
$(document).ready(function(){
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash;
var $target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 100, 'swing', function () {
window.location.hash = target;
});
});
});