如何在两个或多个DOM元素上附加图像?
我正在完成我的战舰项目,并想添加船舶图像。在玩家将船放在某个坐标的情况下之前,我只是将Divs的颜色更改为放置船的颜色。现在,我想动态放置(附加)图像。
<div class="gameBoard">
<div class="grid"></div>
<div class="grid"></div>
<div class="grid"></div>
<div class="grid"></div>
<div class="grid"></div>
<div class="grid"></div>
</div>
上面的DIV游戏板代表我在DOM中的董事会。每个divs代表玩家将相互攻击的每个单独的框。因此,我该如何在对或更多divs上添加一个图像,以使图像跨越这些divs。
I'm finishing up my battleship project and want to add ship images. Before if a player places a ship at a certain coordinate, I just change the color of the divs as an indication of ship being placed. Now I want to place ( append ) images dynamically.
<div class="gameBoard">
<div class="grid"></div>
<div class="grid"></div>
<div class="grid"></div>
<div class="grid"></div>
<div class="grid"></div>
<div class="grid"></div>
</div>
The div gameboard above represents my board in the dom. And each divs represent each individual boxs where the players will attack each other. So how can I add one images on lets say to or more divs, so that the image span across those divs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西吗?
Something like this?