1
How do i make a rectangle in CSS to cover the width of the screen?
AzureScripts (130)

I want to have a rectangle to go from the left side of the screen, to the right side of the screen.

You are viewing a single comment. View All
1
heyitsmarcus (280)

@AzureScripts if you use CSS Grid, you can easily center text within any other container. First, apply a display: grid to the parent container (in this case the div element). Then, apply display: grid to the p element and use CSS like so:

p {
  display: grid;
  justify-self: center;
  align-self: center;

/* any other styles as well */
}

justify-self will horizontally align the element and align-self will vertically align the element. If you set those to center, it will position the p exactly in the center of the div.

Here's a jsfiddle of it in action: https://jsfiddle.net/b4v2apsy/1/