我是javascript的新手,想要编写一个html网站的标题.JS:当窗口宽度小于1215px时 - >左边部分变为100%宽度; 标题的右侧部分为0
我总是得到"无法读取属性'setAttribute'的null"错误!
请帮忙!码:
if (window.innerWidth < 1215) {
document.getElementById("#headerLeft").setAttribute("style", "width:100%");
document.getElementById("#headerRight").setAttribute("style", "width:0%");
} else {
document.getElementById("#headerLeft").setAttribute("style", "width:50%");
document.getElementById("#headerRight").setAttribute("style", "width:50%");
}Run Code Online (Sandbox Code Playgroud)
body {
margin:0;
}
header{
height:100px;
width:100%;
}
#headerLeft {
background-color:#FF7043;
height:100px;
float:left;
}
#headerRight {
background-color:#FFFFFF;
height:100px;
float:right;
}
.headerTitle {
font-family:'Roboto', sans-serif;
margin:15px;
font-size:70px;
}
#headerRight .headerTitle {
text-align:left;
color:#FF7043;
font-weight:300;
}
#headerLeft .headerTitle {
text-align:center;
color:#FFFFFF;
font-weight:900;
}Run Code Online (Sandbox Code Playgroud)
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>example</title>
<!-- css -->
<link type="text/css" rel="stylesheet" href="style.css">
<!-- fonts …Run Code Online (Sandbox Code Playgroud)我目前正在做一个项目,刚刚开始使用 ReactJs。(所以还是菜鸟)
我在问自己:使用 React 开发工具的用户可以看到你所有的 props 和 state。我怎样才能防止用户看到例如 ID 和更多“私人”的东西?
提前致谢