[英]move text inside canvas element and make it centered
I am trying to move my div
s with the texts hallo1
and hallo2
to my canvas
element and make it centered. 我正在尝试将带有文本hallo1
和hallo2
div
移动到我的canvas
元素上并使其居中。
Does anyone have and idea on how to achieve this? 是否有人对如何实现这一目标有想法?
Below is code: 下面是代码:
<canvas id="canvas1">hi</canvas>
<div>
hallo1
</div>
<div>
hallo2
</div>
<canvas id="canvas2"></canvas>
<div>
hallo1
</div>
<div>
hallo2
</div>
<canvas id="canvas3"></canvas>
<div>
hallo1
</div>
<div>
hallo2
</div>
<canvas id="canvas4"></canvas>
<div>
hallo1
</div>
<div>
hallo2
</div>
One posibility without modifying your layout is simply adjusting the position: 一种可能的情况是,无需修改布局即可简单地调整位置:
div {
position: relative;
left: 80px;
top: -125px;
}
A version that adjusts to different text widths is to use 13ruce1337 answer and adjust it vertically 适应不同文本宽度的版本是使用13ruce1337答案并垂直调整
#everything {
text-align:center;
float:left;
position: static;
}
div {
position: relative;
top: -125px;
}
I have to redefine everything position, because the style to the text div would modify it 我必须重新定义所有位置,因为文本div的样式会对其进行修改
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.