How to get CSS values from one element and apply it to other elements. Stick Footer

1

I'm using Ryan Fait's Stick Footer solution , but I wanted to leave it making it more dynamic using JavaScript, allowing the height of the footer to automatically calculate the other values of the CSS properties of the other elements. It can be included inline itself.

So far I have achieved something similar to what I want in this function in jQuery. Can someone give me some help?

Detail, I replace .wrapper of Ryan's solution with #content in my code.

$(function(){
    var footerHeight = $(".footer").height();
    $("#content").css("margin-bottom", -footerHeight);
    $(".push").css("height", footerHeight);
});
    
asked by anonymous 03.06.2014 / 16:30

2 answers

1

Ryan's solution does not say anything about colors either from the font or background

But if you want to get css from an element it makes the request like this

<script>
    var cor_texto = $('#Id_da_tag').css('color');
    var cor_background = $('#Id_da_tag').css('background');
    $('#id_destinno').css('color',cor_texto);
    $('#id_destinno').css('background',cor_background );
</script>
    
03.07.2014 / 22:09
1

You can assign the style of one element to another in the following way:

$("#destino").attr("style", $("#origem").attr("style")).addClass($("#origem").attr("class"));
    
02.08.2014 / 23:04