Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

jQuery .css() method

0 votes
99 views
added Jul 12, 2017 in jQuery by birdygeek Sergeant (2,060 points)
edited Jun 22 by LC Marshal

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

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

8 Responses

0 votes
responded May 4, 2018 by LC Marshal Captain (23,940 points)
edited Apr 9 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 (23,940 points)
edited Apr 9 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 (23,940 points)
edited Apr 9 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 (23,940 points)
edited Apr 9 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 (23,940 points)
edited Apr 9 by LC Marshal
//To change only style attributes
$('.handle').attr('style','left: 300px');
0 votes
responded May 4, 2018 by LC Marshal Captain (23,940 points)
edited Apr 9 by LC Marshal
//To add style properties
$('.handle').css('left', '300px');
0 votes
responded Apr 9 by LC Marshal Captain (23,940 points)
$('#scroll-header').css({"height": "52px", "position": "fixed", "top": "0", "z-index": "2002", "width": "100%"});

 

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

 

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