jQuery .css() method

0 votes
1,357 views
added Jul 12, 2017 in jQuery by anonymous
edited Jun 21, 2019 by LC Marshal

// Add CSS properties into .AddCssIntoThisClass
$(".AddCssIntoThisClass").css({"height": "64px", "overflow": "hidden"});

$('html, body').css({ overflow: 'hidden',height: '100%'});

9 Responses

0 votes
responded May 4, 2018 by LC Marshal Captain (25,790 points)
edited Apr 9, 2019 by LC Marshal

/*important - to overwrite important CSS*/
$( '.myclass' ).each(function () {
  this.style.setProperty( 'height', '0px', 'important' );
});
0 votes
responded May 4, 2018 by LC Marshal Captain (25,790 points)
edited Apr 9, 2019 by LC Marshal
//Add CSS attr to elements
$(document).ready(function() {
  $('#div1, #div2').attr('class','NewCSSClass');
});
0 votes
responded May 4, 2018 by LC Marshal Captain (25,790 points)
edited Apr 9, 2019 by LC Marshal
//Close div with css method, e.g toggle menu
$('.business-details__toggle').click(function() {
  $('.sidr.left').css('left', '0rem');
});
    
  $('.sidr__toggle').click(function() {
  $('.sidr.left').css('left', '-44rem');
}); 
0 votes
responded May 4, 2018 by LC Marshal Captain (25,790 points)
edited Apr 9, 2019 by LC Marshal
//Add style attributes to specific element
$("#page-content").find(".details").css( { marginLeft : "30px", marginRight : "30px" } );

//or
$("#page-content").find(".details").css( 'min-height', '128px');
0 votes
responded May 4, 2018 by LC Marshal Captain (25,790 points)
edited Apr 9, 2019 by LC Marshal
//To change only style attributes
$('.handle').attr('style','left: 300px');
0 votes
responded May 4, 2018 by LC Marshal Captain (25,790 points)
edited Apr 9, 2019 by LC Marshal
//To add style properties
$('.handle').css('left', '300px');
0 votes
responded Apr 9, 2019 by LC Marshal Captain (25,790 points)
$('#scroll-header').css({"height": "52px", "position": "fixed", "top": "0", "z-index": "2002", "width": "100%"});

 

0 votes
responded Apr 15, 2019 by LC Marshal Captain (25,790 points)
if ($('.skin-ads').length) {
  $('.new-theme').css({'top': '300px', 'margin-bottom': '300px', 'transition': 'all .5s .2s ease-in-out'});
} 

 

0 votes
responded Nov 11, 2020 by lcjr First Warrant Officer (11,990 points)
$('#block-block-5, #block-block-10, #block-block-11').css('border-top', '#fff solid 25px');

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...