Minus a few pixels from jQuery height()

后端 未结 4 1394
旧时难觅i
旧时难觅i 2021-01-29 15:35

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

4条回答
  •  天命终不由人
    2021-01-29 16:24

    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'});
      }
    
    });
    

提交回复
热议问题