绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
jquery学习手记(6)CSS, Styling, & Dimensions
2020-01-07 18:05:00

Css方法

复制代码
// Getting CSS properties
$("h1").css("fontSize"); // returns a string such as "19px"
$("h1").css("font-size"); // also works

// Setting CSS properties
$("h1").css( "fontSize", "100px" ); // setting an individual property

// setting multiple properties
$("h1").css({
  fontSize: "100px",
  color: "red"
});
复制代码

Styling方法

// Working with classes
var $h1 = $("h1");
$h1.addClass("big");
$h1.removeClass("big");
$h1.toggleClass("big");
if ( $h1.hasClass("big") ) { ... }

Dimensions

复制代码
// Basic dimensions methods
// sets the width of all H1 elements
$("h1").width("50px");
// gets the width of the first H1
$("h1").width();
// sets the height of all H1 elements
$("h1").height("50px");
// gets the height of the first H1
$("h1").height();
// returns an object containing position
// information for the first H1 relative to
// its "offset (positioned) parent"
$("h1").position();
复制代码
分享好友

分享这个小栈给你的朋友们,一起进步吧。

JAVA玩具小屋
创建时间:2019-08-16 16:54:49
分享程序开发方面的小经验,思考一些比较简单易懂的技术问题
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

栈主、嘉宾

查看更多
  • Yios5092
    栈主

小栈成员

查看更多
  • 栈栈
  • coyan
  • 25minutes
  • ?
戳我,来吐槽~