我已经做了很多研究,但是我已经空手而归,这将是最简单的任务:
如果我有一个占据整个屏幕的canvas元素并且是唯一可见的HTML,那么如何将它调整为窗口的大小,它仍然可以编辑?
如果您认为这很简单,那么您可以尝试这样做。那么,如何做到这一点的例子是什么?我有一个破碎的浏览器,它就像100%的大小一样简单,还是更复杂?
另外,如果你的答案中有一个脚本,那么请保持它只是简单的javascript没有jquery,因为我确定如果它也可以在jquery中完成,那么它可以在旧的普通javascript中完成。
答案 0 :(得分:2)
您需要从身体中删除默认的5px边距。
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If ListView1.Items.Count > 0 Then
If IsNothing(Me.ListView1.FocusedItem) Then
ListView1.TopItem.Selected = True
End If
For Each file As ListViewItem In ListView1.Items
Dim filePath As String = file.SubItems(1).Text & "\" & file.Text
If file.Selected = True Then
Process.Start(filePath)
End If
Next
Else
Dim rndm As Integer = CInt(Math.Ceiling(Rnd() * 20)) + 1
Dim rndpic As String = "PictureBox" & rndm & "_Click"
Call rndpic(Nothing, Nothing)
End If
End Sub
答案 1 :(得分:1)
尝试使用css:
<canvas style="width: 100%; height: 100%;"></canvas>
另外,请务必将所有父元素设为100%宽度和高度:
<style>
html, body {
height: 100%;
width: 100%;
}
</style>
请确保将样式标记放在<head>
和</head>
之间,您也可以单独保留canvas元素,只需将其添加到头部而不是上面的代码:
<style>
html, body {
height: 100%;
width: 100%;
}
canvas {
height: 100%;
width: 100%;
}
</style>
答案 2 :(得分:1)
修改强>
来自您的示例:ctx.fillRect(0, 0, canvas.height, canvas.width);
必须是:
ctx.fillRect(x, y, width, height);
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillRect