js html/body/div tag test
2016-03-29 13:17
405 查看
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="renderer" content="webkit" /> <meta http-equiv="X-UA-Compatible" content="IE=8,9,10"> <title>H0</title> <meta charset="utf-8" /> <link href="../Content/StyleSheet0.css" rel="stylesheet" /> <script src="../Scripts/JavaScript0.js"></script> </head> <body> </body> </html>
js
window.onload = function()
{
Init();
}
function Init()
{
//alert(window.innerWidth);//获取在当前显示器当前浏览器,无滚动条时html页面的宽度和高度
//alert(window.innerHeight);
//var html = document.getElementsByTagName("html")[0];//获取html标签dom对象
//html.setAttribute("style", "width:" + (window.innerWidth - 2) + "px;");// + "height:" + (window.innerHeight - 2) + "px;");
var body = document.getElementsByTagName("body")[0];//获取body标签dom对象,或者document.body
//body.setAttribute("style", "width:" + (window.innerWidth - 2 * body.clientLeft) + "px;" + "height:" + (window.innerHeight - 0 * body.clientTop) + "px;");
alert(window.innerWidth-body.offsetWidth);
//alert(div.offsetLeft);
//alert(div.offsetWidth);
//div.style.height = window.innerHeight - 2 * body.clientTop - 2 * div.clientTop + "px";
//alert(html.clientWidth); //1366
//alert(html.clientHeight); //639
/*
var main = document.getElementById("main");
var point = document.createElement("div");
point.className = "point";
main.insertBefore(point, main.childNodes[0]);
point.style.color = "#fff";
point.style.backgroundColor = "#307ff6";
point.innerHTML = "<i></i>" + "请选择本地照片、相册、拍照,进行截取头像";
var pointI = point.getElementsByTagName("i")[0];
pointI.style.backgroundPosition = "0 0";
alert(point.style["WebkitTransform"]);
*/
}
css
body {
margin:0;
border:16px solid #b6ff00;
/*overflow-y:scroll;*/
background-color:blueviolet;
height:2000px;
}
/*
div {
border-radius: 100px;
position: absolute;
top: 220px;
left: 583px;
border: 1px dashed black;
width: 100px;
height: 100px;
cursor: pointer;
background-image: url('../Images/d.jpg');
background-size: cover;
}
#main .point {
width:100%;
line-height:35px;
font-size:12px;
position:absolute;
z-index:200;
filter:alpha(opacity=70);
opacity:0.7;
}
.point i {
display:inline-block;
height:16px;
width:15px;
float:left;
margin:10px 10px 0 20px;
background:url(../Images/bg_repno.png) no-repeat;
}
*/
相关文章推荐
- JQuery1——基础($对象,选择器,对象转换)
- Android学习笔记(二九):嵌入浏览器
- Android java 与 javascript互访(相互调用)的方法例子
- JavaScript演示排序算法
- javascript实现10进制转为N进制数
- 最后一次说说闭包
- Ajax
- 2019年开发人员应该学习的8个JavaScript框架
- HTML中的script标签研究
- 对一个分号引发的错误研究
- 异步流程控制:7 行代码学会 co 模块
- ES6 走马观花(ECMAScript2015 新特性)
- JavaScript拆分字符串时产生空字符的原因
- Canvas 在高清屏下绘制图片变模糊的解决方法
- Redux系列02:一个炒鸡简单的react+redux例子
- JavaScript 各种遍历方式详解
- call/apply/bind 的理解与实例分享