position |
DOM |
DOM |
src/dom/dom.js |
<p>Sets the element's position.</p>
<p>The first two parameters, <code>x</code> and <code>y</code>, set the element's position relative
to the top-left corner of the web page.</p>
<p>The third parameter, <code>positionType</code>, is optional. It sets the element's
<a target="_blank" href=" https://developer.mozilla.org/en-US/docs/Web/CSS/position/">positioning scheme</a>.
<code>positionType</code> is a string that can be either <code>'static'</code>, <code>'fixed'</code>,
<code>'relative'</code>, <code>'sticky'</code>, <code>'initial'</code>, or <code>'inherit'</code>.</p>
<p>If no arguments passed, as in <code>myElement.position()</code>, the method returns
the element's position in an object, as in <code>{ x: 0, y: 0 }</code>.</p>
|
2962 |
false |
method |
<div>
<code class='norender'>
function setup() {
let cnv = createCanvas(100, 100);
background(200);
// Positions the canvas 50px to the right and 100px
// below the top-left corner of the window.
cnv.position(50, 100);
describe('A gray square that is 50 pixels to the right and 100 pixels down from the top-left corner of the web page.');
}
</code>
</div>
<div>
<code class='norender'>
function setup() {
let cnv = createCanvas(100, 100);
background(200);
// Positions the canvas at the top-left corner
// of the window with a 'fixed' position type.
cnv.position(0, 0, 'fixed');
describe('A gray square in the top-left corner of the web page.');
}
</code>
</div> |
|
p5.Element |
description |
type |
object of form `{ x: 0, y: 0 }` containing the element's position. |
Object |
|
line |
params |
return |
2962 |
|
description |
type |
object of form `{ x: 0, y: 0 }` containing the element's position. |
Object |
|
|
line |
params |
chainable |
3013 |
name |
description |
type |
optional |
x |
<p>x-position relative to top-left of window (optional)</p>
|
Number |
true |
|
name |
description |
type |
optional |
y |
<p>y-position relative to top-left of window (optional)</p>
|
Number |
true |
|
name |
description |
type |
optional |
positionType |
<p>it can be static, fixed, relative, sticky, initial or inherit (optional)</p>
|
String |
true |
|
|
1 |
|
|
false |