现在的位置: 首页 > 综合 > 正文

JQuery判断盒子模型(W3C和IE)

2013年03月20日 ⁄ 综合 ⁄ 共 450字 ⁄ 字号 评论关闭
 1 <html>
 2 <head>
 3 <title>你用的盒子模型是?</title>
 4     <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
 5 <script type="text/javascript">
 6     $(function () {
 7         var box = $.support.boxModel == true ? "W3C盒子模型" : "IE盒子模型";
 8         document.write(box);
 9     })
10 </script>
11 </head>
12 <body>
13     <span id="tip"></span>
14 </body>
15 </html>

 

 

让IE也使用W3C的盒子模型只需要在<html>前加上如下代码就可以了:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

抱歉!评论已关闭.