【发布时间】:2015-01-28 01:13:48
【问题描述】:
更新:我修复了颜色与背景颜色的问题。谢谢!但是,代码仍然不会从 WebStorm 运行。有没有 WebStorm 专家?
我正在学习 javascript 并尝试使用 js 操作 css。这是我的代码:
document.getElementById("top-left").style.color = "blue";
body{
background-color: black;
}
.container {
text-align:center;
position: absolute;
width: 100%;
margin: 0 auto;
padding-top: 2.5%;
padding-left: 30%;
width: 31em;
}
#title {
margin-left: auto;
margin-right: auto;
text-align: center;
width: 50%;
color: green;
font-size: 4em;
}
#top-left {
width: 15em;
height: 15em;
background: red;
border-top-left-radius: 100% ;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
display: inline-block;
position: relative;
}
#top-right {
width: 15em;
height: 15em;
background: gold;
border-top-left-radius: 0 ;
border-top-right-radius: 100%;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
display: inline-block;
position: relative;
}
#bottom-right {
width: 15em;
height: 15em;
background: orangered;
border-top-left-radius: 0 ;
border-top-right-radius: 0;
border-bottom-right-radius: 100%;
border-bottom-left-radius: 0;
display: inline-block;
position: relative;
}
#bottom-left {
width: 15em;
height: 15em;
background: darkgreen;
border-top-left-radius: 0 ;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 100%;
display: inline-block;
position: relative;
}
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="jscode.js"></script>
<title>title</title>
</head>
<body>
<div id = "title">Title</div>
<div class = "container">
<div id = "top-left"></div>
<div id= "top-right"></div>
<div id = "bottom-left"></div>
<div id = "bottom-right"></div>
</div>
</body>
</html>
在小提琴 (http://jsfiddle.net/interestinall/hgo7h5v4/) 上,脚本什么也不做。在 WebStorm 上,它会抛出以下错误:ReferenceError: document is not defined。
所以我的问题是:如何定义文档?
任何帮助将不胜感激!
【问题讨论】:
-
因为这是关于 WebStorm 的,所以它应该作为一个新问题提出,有足够的标题、足够的标签以及以可重现的方式对问题进行充分的描述。
标签: javascript html css webstorm