.output-container {
background: #333;
color: #fff;
padding: 1rem 1;
width: 100%;
top: 0;
z-index: 1000;
text-align: center;
}
The class is just added into the ; however, I want the grey section behind the text to extend to the edges of the screen, but I can’t just increase the value of width as the text and box are connected to one another, so doing that increases how far right the text goes.
I tried increasing the value of width in the class; however, this just resulted in both the text and background being extended over to the right leaving, the text displayed incorrectly, and the left side of the grey background unmoved.
3
Answers
Try adjusting margin-left and margin-right values.
if you want to set the container to max screen resolution, you have to think about the end user in this regard because what their settings may be(and probably are) different. 1920×1080 is the most common resolution. so put in an auto adjust fix also to accomodate the max-width with the container/flexbox. Also, it would help if you included the container html example and any other pertinent information. If you just want to resize the width of the element then designate a value for it and also an auto adjust fix for different users.
reference: https://developer.mozilla.org/en-US/docs/Web/CSS/width#accessibility_concerns
-also you are using z-index, so are you using flexbox as well?
I just added a width parameter to resize the width as you have asked. hope this helps.
**edit- looks like this was answered in another post. says the answer was:
"You can use the :before pseudo element with absolute positioning and negative z-index to extend the background color of a contained div the entire way to the edge of the page."
however, i’m not sure if the pseudo element is needed here. depends on your own markup. hope this helps!
Use the width: 100%; property to make the grey background span the entire width of the screen and use max-width and margin: 0 auto; to limit the width of the text container and center it