Created
May 15, 2014 10:35
-
-
Save carlosrojaso/8b055bd3541452cfdc85 to your computer and use it in GitHub Desktop.
CSS, Styling, & Dimensions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setting CSS properties. | |
$( "h1" ).css( "fontSize", "100px" ); // Setting an individual property. | |
// Setting multiple properties. | |
$( "h1" ).css({ | |
fontSize: "100px", | |
color: "red" | |
}); | |
// Working with classes. | |
var h1 = $( "h1" ); | |
h1.addClass( "big" ); | |
h1.removeClass( "big" ); | |
h1.toggleClass( "big" ); | |
if ( h1.hasClass( "big" ) ) { | |
... | |
} | |
// Basic dimensions methods. | |
// Sets the width of all <h1> elements. | |
$( "h1" ).width( "50px" ); | |
// Gets the width of the first <h1> element. | |
$( "h1" ).width(); | |
// Sets the height of all <h1> elements. | |
$( "h1" ).height( "50px" ); | |
// Gets the height of the first <h1> element. | |
$( "h1" ).height(); | |
// Returns an object containing position information for | |
// the first <h1> relative to its "offset (positioned) parent". | |
$( "h1" ).position(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment