1、引入:
首先写一个div标签,给它加上行内样式和内部样式:
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#box{
height: 100px;
background-color:green;
}
</style>
</head>
<body>
<div id="box" style="width:100px;color:black">111</div>
</body>
</html>
结果:
2、获取和操作行内样式
(1)获取行内样式:选择器名.style.属性名(style可读可写)