Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add width, height attrs to canvas element #32801

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,28 @@ Loops are all about doing the same thing over and over again. Often, the code wi
Suppose we wanted to draw 100 random circles on a {{htmlelement("canvas")}} element (press the _Update_ button to run the example again and again to see different random sets):

```html hidden
<button>Update</button> <canvas></canvas>
<button>Update</button> <canvas width="680" height="380"></canvas>
```

```css hidden
html {
width: 100%;
height: inherit;
background: #ddd;
}

canvas {
display: block;
}

body {
margin: 0;
padding: 0;
text-align: center;
}
canvas {
border: 2px solid cornflowerblue;
border-radius: 5px;
}

button {
position: absolute;
top: 5px;
left: 5px;
top: 20px;
left: 40px;
}
```

{{ EmbedLiveSample('Looping_code_example', '100%', 400) }}
{{EmbedLiveSample('Looping_code_example', '', '400')}}

Here's the JavaScript code that implements this example:

Expand Down