Javascript put<;p>;之后<;部门>;

Javascript put<;p>;之后<;部门>;,javascript,html,canvas,Javascript,Html,Canvas,我创建了一个具有DOM结构的网站,如下所示: <body> <div><canvas id="cv"></canvas> <script> ..some scripts with function and methods to make multiple canvas.. </script> </div> <p>lorem ipsum</p> </body> <html

我创建了一个具有DOM结构的网站,如下所示:

<body>
<div><canvas id="cv"></canvas>
<script>
..some scripts with function and methods to make multiple canvas..
</script>
</div>
<p>lorem ipsum</p>
</body>
<html>
<body>
<div id="layer">
<canvas id="myCanvas" width="400" height="300" style="border:2px solid #c3c3c3;position:absolute;left:5px;top:5px">Your browser does not support the canvas element.</canvas>
<script type="text/javascript">
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="#FF0000";
ctx.fillRect(0,0,150,75);
var id=document.createAttribute("id");
id.nodeValue="test";
var cs=document.createElement("canvas");
document.getElementById("layer").appendChild(cs).setAttributeNode(id);
document.getElementById("test").style.position="absolute";
document.getElementById("test").style.left="7px";
document.getElementById("test").style.top="7px";
document.getElementById("test").width="100";
document.getElementById("test").height="180";
document.getElementById("test").style.border="1px solid";
</script>
</div>
<p>dssdsdsds dsds vdok fekof efienife fienfie fkenfke fkeinf ekfine</p>
</body>
</html>

..一些脚本,具有制作多个画布的函数和方法。。
同侧眼睑

问题是“lorem ipsum”一段总是出现在画布后面 我不能让它出现在画布之后,或者至少在

在脚本中,我使用“createElement”和“appendChild”方法创建多个画布,并将新画布附加到div标记中

有没有想法让这段文字出现在下面?(在画布后面,而不是后面)

整个页面的结构大致相同,如下所示:

<body>
<div><canvas id="cv"></canvas>
<script>
..some scripts with function and methods to make multiple canvas..
</script>
</div>
<p>lorem ipsum</p>
</body>
<html>
<body>
<div id="layer">
<canvas id="myCanvas" width="400" height="300" style="border:2px solid #c3c3c3;position:absolute;left:5px;top:5px">Your browser does not support the canvas element.</canvas>
<script type="text/javascript">
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="#FF0000";
ctx.fillRect(0,0,150,75);
var id=document.createAttribute("id");
id.nodeValue="test";
var cs=document.createElement("canvas");
document.getElementById("layer").appendChild(cs).setAttributeNode(id);
document.getElementById("test").style.position="absolute";
document.getElementById("test").style.left="7px";
document.getElementById("test").style.top="7px";
document.getElementById("test").width="100";
document.getElementById("test").height="180";
document.getElementById("test").style.border="1px solid";
</script>
</div>
<p>dssdsdsds dsds vdok fekof efienife fienfie fkenfke fkeinf ekfine</p>
</body>
</html>

您的浏览器不支持画布元素。
var c=document.getElementById(“myCanvas”);
var ctx=c.getContext(“2d”);
ctx.fillStyle=“#FF0000”;
ctx.fillRect(0,0150,75);
var id=document.createAttribute(“id”);
id.nodeValue=“测试”;
var cs=document.createElement(“画布”);
document.getElementById(“层”).appendChild(cs).setAttributeNode(id);
document.getElementById(“测试”).style.position=“绝对”;
document.getElementById(“test”).style.left=“7px”;
document.getElementById(“test”).style.top=“7px”;
document.getElementById(“测试”).width=“100”;
document.getElementById(“测试”).height=“180”;
document.getElementById(“test”).style.border=“1px solid”;
dsds vdok fekof efienife FIENFIEFIE fkenfke fkeinf ekfine


如果希望其他元素围绕元素流动,请不要绝对定位元素。如果你真的需要绝对定位,那么就定位一个容器,这个容器可以容纳你想放在一起的所有东西。

画布是否应该内联显示?当直接将代码原封不动地发布到JSFIDLE上时,我得到的结果似乎很好。你的问题在别处。你检查过页面的来源了吗?可能有不属于那里或不接近的标记我已经重新检查,所有的标记都很接近,我不使用CSS,但我在画布上使用了样式属性,如左,位置:绝对。你有了它!绝对定位有这种影响。