.viewport { height: 100%; width: 95%; padding: 1px; border: 2px solid black;…
Jump to turn (6)
- 1.viewport { height: 100%; width: 95%; padding: 1px; border: 2px solid black; bac
- 2class Rect { constructor(Pos, Size) { this.pos = Pos, this.size = Size } } modul
- 3This is my html file. It runs "boot.js" another file that is called is: class Re
- 4in js; how do i get the "viewport" div thing?
- 5Uncaught TypeError: Cannot read properties of null (reading 'appendChild') at Re
- 6i WOULD use the square() function but it it only makes squares. wat about rectan
- User
.viewport { height: 100%; width: 95%; padding: 1px; border: 2px solid black; background-color: white; }
make it a square centered in the center of the screen.
- Assistant
To create a square centered in the center of the screen, you can adjust the CSS for the .viewport class as follows:
css.viewport { height: 50vh; /* 50% of the viewport height */ width: 50vh; /* Set the width equal to the height to create a square */ margin: auto; /* Center the square horizontally */ padding: 1px; border: 2px solid black; background-color: white; }By setting the height and width to 50vh (50% of the viewport height), it will create a square that is centered both vertically and horizontally on the screen. The margin: auto; property will center the square horizontally within its parent container.