JQUERY-CSS processing

Source: Internet
Author: User

jquery CSS processing, including CSS, location, size, etc.

One: CSS

Use Description Example
CSS (NAME|PRO|[,VAL|FN]) To access the style properties of a matching element
$("p").css("color");
$("p").css("color","red");

Two: Location

Use Description Example
  • offset ([coordinates])

Gets the relative offset of the matching element at the current viewport

The returned object contains two integer properties: Top and left, measured in pixels

$("p:last").offset({ top: 10, left: 30 });


Offset (). Left specifies the coordinates of the label in HTML
Offset (). Top specifies the coordinates of the label in HTML

 
  • Position ()

Gets the offset of the matching element relative to the parent element

The returned object contains two integer properties: Top and left

Specifies the coordinates of the label relative to the parent label (relative) label
  • ScrollTop ([Val])
Gets the offset of the top of a matching element relative to the scrollbar
var p = $("p:first");$("p:last").text( "scrollTop:" + p.scrollTop() );

$ (window). scrolltop () get
$ (window). scrolltop (0) settings

  • ScrollLeft ([Val])
Gets the offset to the left of the matching element relative to the scrollbar
var p = $("p:first");$("p:last").text( "scrollLeft:" + p.scrollLeft() );
$("div.demo").scrollLeft(300);

Three: Size

  • Use
Description Example
  • Height ([val|fn])
Gets the height value (px) of the currently calculated match element
$("p").height();
$("p").height(20);
  • Width ([VAL|FN])
Gets the current calculated width value (px) of the first matching element
$("p").width();
$("p").width(20);
  • Innerheight ()

Gets the inner area height of the first matching element

(including padding, excluding borders)

var p = $("p:first");$("p:last").text( "innerHeight:" + p.innerHeight() );
  • Innerwidth ()
Gets the inner area width of the first matched element (including padding, excluding borders).
var p = $("p:first");$("p:last").text( "innerWidth:" + p.innerWidth() );
  • Outerheight ([soptions])

Gets the outer height of the first matching element (including padding and borders by default)

When set to True, the margin is calculated

  • Outerwidth ([options])

Gets the outer width of the first matching element (including padding and borders by default)

When set to True, the margin is calculated

JQUERY-CSS processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.