Okay so i have an element that should be positioned at the bottom of my page. The issue is that on some pages i have elements that both slide down and up depending on a click() function. When the page loads the element is naturally positioned at the bottom as the page has enough content to push it down.
It get's tricky when the user clicks an element that makes the sibling slideup and therefor makes the element slide up along with it till it reaches the next "visible" element.
What i more or less want to do is to keep it at the bottom of the screen if there isn't much content, and when there is enough visible content it will just position itself relative to it's sibling above. Hope it makes sense
This is the footer
<footer>
<div class='container'>
<span>
<h2><b>Contact</b></h2>
<b>Telephone:</b> +45 000000<br/>
<b>Email:</b> management@EXAMPLE.com
</span>
<span>
<h2><b>FAQ</b></h2>
Some text<br/>
Some other text
</span>
<span>
<h2><b>Some header</b></h2>
<?php
if(date('Y') == '2019'){
echo 'example © 2019';
} else {
echo 'example © 2019-'.date('Y');
}
?>
</span>
</div>
</footer>
--- CSS ---
.container{
width: 80%;
margin: auto;
overflow: hidden;
}
footer
{
color: #FFF;
background: #d99741;
padding: 20px;
margin-top: 20px;
}
footer span
{
float: left;
text-align: center;
width: 30%;
padding: 10px;
}
footer h2
{
position: relative;
margin-top: -10px;
}
--- Html for the sibling above ---
echo "
<section id='displayevents'>
<div class='container'>
<div class='eventCountry'>
<p>".$trim."</p>
</div>
<div class='framework''>
<div class='imageFrames'>
<img src='".$image[0]."' />
<h3>".$club[0]."</h3>
</div>
<div class='imageFrames'>
<img src='".$image[1]."' />
<h3>".$club[1]."</h3>
</div>
<div class='imageFrames'>
<img src='".$image[2]."' />
<h3>".$club[2]."</h3>
</div>
</div>
</div>
</section>
";
--- javascript that slides up and down ---
<script type='text/javascript'>
$(document).ready(function(){
//Hides all .framework and then shows the first
var getamount = $('.framework');
for(var x=0;x<=getamount.length;x++){
$(getamount[x]).hide();
}
$('.framework').first().show();
//Creates a function that will handle the display of each .framework. Only
one at a time.
function openSection(element){
var display = element.css('display');
var find = $('.framework');
var getAttr;
if(display != 'none'){
$(element).slideUp(500);
} else{
for(var x=0;x<=find.length;x++){
getAttr = $(find[x]).css('display');
if(getAttr != 'none'){
$(find[x]).slideUp(500);
}
}
$(element).slideDown(500);
}
}
//Create clickfunction to .eventCountry and call function to hide/show
content
$('.eventCountry').click(function(){
openSection($(this).next());
});
});
</script>