Ok, amateur question here but im really bumping my head.
Using the jQuery below, i would like to add margin-top:-100px; to the height value.
Please help! Thanks
You can just add the css.
$('#home').css('margin-top','-100px');
If I understand correctly this should do it:
$(function () {
function HomePageSize() {
var winHeight = $(window).height(); // store height in variable
var myMargin = winHeight - 100; // deduct 100 from height
$('#home').css({
width: $(window).width(),
height: winHeight,
marginTop: myMargin // assign calculated value to margin-top
});
}
$(window).resize(function () {
HomePageSize();
});
HomePageSize();
});
If you already have margin-top of -100px assigned to some element like #home, then You can try this
$(function () {
function HomePageSize() {
$('#home').css({
width: $(window).width(),
height: $(window).height() + parseInt($("#home").css("margin-top"))
});
}
$(window).resize(function () {
HomePageSize();
});
HomePageSize();
});
Here code:
$(function () {
function HomePageSize() {
$('#home').css({
width: $(window).width(),
height: $(window).height()
});
}
$(window).resize(function () {
HomePageSize();
});
addMargin();
function addMargin() {
$('#home').css({'margin-top':'-100px'});
}
});