前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布

伪类

作者头像
贵哥的编程之路
发布2020-10-28 10:28:57
6870
发布2020-10-28 10:28:57
举报
文章被收录于专栏:用户7873631的专栏
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<style type="text/css">
		*{padding: 0px;margin: 0px;}
		#div1
		{
			width: 200px;height: 200px;background: red;position: absolute;left: 50%;top: 50%;margin: -100px  0 0 -100px;box-shadow: 0 -100px 0 pink;
		}
		#div1:after
		{
			width: 100%;height: 100%;background: black;position: absolute;left: -100%;content: "666";box-shadow: 0 200px 0 yellow;color: white;
		}
		#div1:before
		{
			width: 100%;height: 100%;background: green;position: absolute;left: 100%;content: "777";box-shadow: 0  200px 0 blue;color: white;
		}
	</style>
</head>
<body>
	<div id="div1"></div>
	<script type="text/javascript">
		function getStyle(obj,style)
		{
			if(obj.currentStyle)
			{
				return obj.currentStyle[style];
			}
			else
			{
				return getComputedStyle(obj)[style];
			}
		}
		console.log(getComputedStyle(div1,":after")['width']);
		var json={"height":"200px"}
		alert(json["height"]);
		//alert(div1.currentStyle.height);//ie系列低的浏览器用
		alert(getComputedStyle(div1)["height"]);//都兼容
	</script>
</body>
</html>
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	<video id="video"></video>
	<script type="text/javascript">
		video.src="http://images.sohu.com/ytv/SH/Coke/64036020120714021103.mp4?t="+Math.random();
		video.addEventListener("progress",function()
			{
				console.log(video.buffered.end(0));//缓冲
			});
	</script>
</body>
</html>
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<style type="text/css">
		*{margin: 0;padding: 0;list-style: none;}
div{width: 200px;height: 200px;background: black;position: absolute;left: 50%;top: 50%;margin: -100px 0 0 -100px;
	transition:0.5s;
}

	</style>
</head>
<body>
	<div id="div1"></div>
	<script type="text/javascript">
		div1.onclick=function()
		{
			this.style.transform="rotate(90deg)";
		}
		div1.addEventListener("transitionend",function()
			{
				if(div1.style.background=="red")
				{
					div1.style.transform="rotate(0deg)";
					div1.style.background="black";
				}
				else
				{
					div1.style.background="red";
				}
			});
	</script>
</body>
</html>
代码语言:javascript
复制
<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title></title> 
</head>
<body>
<script type="text/javascript">
	
	
	setInterval = alert;
	setInterval(1)
	//可以简写为:
	setInterval(function()
		{
			alert(1);
		},这里是系统默认的事件);
</script>
</body>
</html>
代码语言:javascript
复制
<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title></title>
    <style type="text/css">
*{margin: 0;padding: 0;}
#div1{width: 200px;height: 200px;background: black;}
#div1:after{
	width: 314px;height: 200px;
	background: red;
	content: '';
	position: absolute;
	left: 200px;
}


#div2{height: 200px;background: green;}

    </style> 
</head>

<body>
<div id='div1'></div>
<script type="text/javascript">
	/*
	function getStyle(obj,style){
		if(obj.currentStyle){//ie
			return obj.currentStyle[style];
		}
		else{//非ie
			return getComputedStyle(obj)[style]
		}
	}
	*/
	console.log(getComputedStyle(div1,':after')['width']);
	/*
	var json = {
		'height':'200px'
	}
	*/
	//alert(json['height']);
	//alert(div1.currentStyle.height)
//	alert(getComputedStyle(div1)['height'])


</script>
</body>
</html>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/10/02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档