您的位置:首页 > Web前端 > JavaScript

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;
}
*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  javascript