码迷,mamicode.com
首页 > Web开发 > 详细

jQuery CSS-jQuery盒子模型

时间:2015-09-26 00:26:16      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

bootstrap.min.css跟平时的盒子模型不同,bootstrap: width里面包含了border 和 padding

1. css

$(document).ready(function(){
// $("div").css("width","100px");
// $("div").css("height","100px");
// $("div").css("background-color","red");
/* $("div").css({
width: "200px",
height: "200px",
backgroundColor: "red", //backgroundColor, you can not use ;
});*/
$("div").addClass("style1");
$("div").click(function(){
//$(this).addClass("style2");
$(this).removeClass("style1");
$(this).toggleClass("style2");
});
});

2. 盒子模型

<style>
#div{
width: 100px;
height: 100px;
margin: 50px;
padding: 100px;
border: 2px solid black;
background-color: red;
}
</style>

/* height() innerHeight() outHeight() */
$(document).ready(function(){
alert($("#div").height());
alert($("#div").innerHeight());
alert($("#div").outerHeight());
alert($("#div").outerHeight(true));
});

jQuery CSS-jQuery盒子模型

标签:

原文地址:http://www.cnblogs.com/htmlphp/p/4839760.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!