質問編集履歴
3
コードを追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -25,7 +25,56 @@
|
|
25
25
|
$("#monitor").animate({height:heidis+'px', top:topto+'px'});
|
26
26
|
}
|
27
27
|
```
|
28
|
-
|
28
|
+
以下問題とは関係のない部分を取り去った最小限の追記HTMLコードになります。
|
29
|
+
```HTML
|
30
|
+
<!DOCTYPE HTML>
|
31
|
+
<html>
|
32
|
+
<head>
|
33
|
+
<title>Title</title>
|
34
|
+
<link rel="stylesheet" type="text/css" href="truth.css">
|
35
|
+
<script type="text/javascript" src="jquery-3.2.1.min.js"></script>
|
36
|
+
<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
|
37
|
+
</head>
|
38
|
+
<body>
|
39
|
+
<div id="ofallparent" style="position:relative">
|
40
|
+
<canvas id="allparent"></canvas>
|
41
|
+
</div>
|
42
|
+
<script type="text/javascript">
|
43
|
+
window.onload = function(){
|
44
|
+
var stage = new createjs.Stage('allparent');
|
45
|
+
var canvas = document.getElementById('allparent');
|
46
|
+
var wid = stage.canvas.width = screen.availWidth;
|
47
|
+
var hei = stage.canvas.height = screen.availHeight;
|
48
|
+
if (canvas && canvas.getContext) {
|
49
|
+
var ctx = canvas.getContext('2d');
|
50
|
+
ctx.beginPath();
|
51
|
+
ctx.fillStyle = 'rgb(0, 0, 0)';
|
52
|
+
ctx.fillRect(0, 0, wid, hei);
|
53
|
+
ma();
|
54
|
+
}
|
55
|
+
function ma() {
|
56
|
+
var topzahyo = (hei*13)/14;
|
57
|
+
var leftzahyo = (wid/2) - (wid/11);
|
58
|
+
var widdis = wid/7;
|
59
|
+
var heidis = hei/7;
|
60
|
+
var topto = (hei*11)/14;
|
61
|
+
$("#ofallparent").append('<div id="monitor"></div>');
|
62
|
+
$("#monitor").css({'top':topzahyo+'px','left':leftzahyo+'px', 'width"':widdis+'px', 'height':'0px', 'background-color':'#ffffff', 'position':'absolute'});
|
63
|
+
$("#monitor").animate({height:heidis+'px', top:topto+'px'});
|
64
|
+
}
|
65
|
+
}
|
66
|
+
</script>
|
67
|
+
</body>
|
68
|
+
</html>
|
69
|
+
```
|
70
|
+
```css
|
71
|
+
body {
|
72
|
+
margin-left:0px;
|
73
|
+
margin-top:0px;
|
74
|
+
margin-right:0px;
|
75
|
+
margin-bottom:0px;
|
76
|
+
}
|
77
|
+
```
|
29
78
|
###試したこと
|
30
79
|
```javascript
|
31
80
|
var area = document.getElementById("ofallparent");
|
2
タイトルを簡潔にしました
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
canvasにdivを重ねたいのですが、うまくいきません
|
body
CHANGED
File without changes
|
1
文の修正。
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
<canvas id="allparent"></canvas>
|
11
11
|
</div>
|
12
12
|
```
|
13
|
-
|
13
|
+
|
14
14
|
```javascript
|
15
15
|
function monitorappear() {
|
16
16
|
var topzahyo = (hei*13)/14;
|
@@ -37,4 +37,5 @@
|
|
37
37
|
|
38
38
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
39
39
|
使用しているjquery:jquery-3.2.1.min.js
|
40
|
-
position:relativeにすると、重ならず、下に表示されます。
|
40
|
+
position:relativeにすると、重ならず、下に表示されます。
|
41
|
+
monitorappear()は別の関数から呼ばれるようになっています。
|