level 1
潜水都不让吗
楼主
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
function Food(){
this.x = 0;
this.y = 0;
this.width = 20;
this.height = 20;
this.color ='green';
}
var pos='absolute'
Food.prototype.render = function (map){
var div = document.createElement('div');
map.appendChild(div);
div.style.Position= pos;
div.style.left= this.x+'px';
div.style.top= this.y+'px';
div.style.width= this.width+'px';
div.style.height= this.height+'px';
div.style.backgroundcolor=this.color;
}
var map = document.getElementById('map');
var food =new Food();
food.render(map);
</script>
<link rel="stylesheet" type="text/css" href="css/new_file.css"/>
</head>
<body>
<div id="map">
</div>
</body>
</html>
css文件
#map{
background-color:lavender;
width: 1000px;
height: 1000px;
position:relative ;
}
那个小的div为啥不出来啊 有大佬会吗
2019年07月18日 09点07分
1
<html lang="en" >
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
function Food(){
this.x = 0;
this.y = 0;
this.width = 20;
this.height = 20;
this.color ='green';
}
var pos='absolute'
Food.prototype.render = function (map){
var div = document.createElement('div');
map.appendChild(div);
div.style.Position= pos;
div.style.left= this.x+'px';
div.style.top= this.y+'px';
div.style.width= this.width+'px';
div.style.height= this.height+'px';
div.style.backgroundcolor=this.color;
}
var map = document.getElementById('map');
var food =new Food();
food.render(map);
</script>
<link rel="stylesheet" type="text/css" href="css/new_file.css"/>
</head>
<body>
<div id="map">
</div>
</body>
</html>
css文件
#map{
background-color:lavender;
width: 1000px;
height: 1000px;
position:relative ;
}
那个小的div为啥不出来啊 有大佬会吗