absolute的破壞性
任務(wù)
老師視頻里的不同布局寫法,不是習(xí)題??!不是習(xí)題!??!
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>absolute的破壞性</title>
<style>
.box {
padding: 10px;
background-color: #f0f0f0;
}
input {
position: absolute; top: 234px;
width: 160px; height: 32px;
font-size: 100%;
}
</style>
</head>
<body>
<div class="box"><img id="image" src="http://img1.sycdn.imooc.com//54447b06000171a002560191.jpg" width="256" height="191"></div>
<input id="button" type="button" value="圖片absolute化">
<script>
var eleImg = document.getElementById("image"), eleBtn = document.getElementById("button");
if (eleImg != null && eleBtn != null) {
eleBtn.onclick = function() {
if (this.absolute) {
eleImg.style.position = "";
this.value = "圖片absolute化";
this.absolute = false;
} else {
eleImg.style.position = "absolute";
this.value = "圖片去absolute";
this.absolute = true;
}
};
}
</script>
</body>
</html>
請驗證,完成請求
由于請求次數(shù)過多,請先驗證,完成再次請求