There is a site that is displayed absolutely fine on my PC, but on a laptop or screen a scroll bar appears at the bottom, I tried to apply different styles to the wrapper, but if the site began to display normally, then problems began when the resolution was reduced.
Display on laptop when changing resolution:
The site structure looks something like this:
<div class="wrapper">
<section class="section">
<div class="container">
<div class="main__content">
<h1>Content</h1>
<p>Content</p>
<p>Content</p>
</div>
</div>
</section>
</div>
Bounding box styles:
.container {
width: 100%;
padding-left: 40px;
padding-right: 40px;
margin: 0 auto;
}
.wrapper {
min-width: 1720px;
}
Changes made:
Added the following styles:
.container {
width: 100%;
margin: 0 auto;
}
If you add a background, it looks like this:
But I need it to shrink adaptively when the resolution decreases, and so that the navigation in the site header does not run into each other.
3
Answers
Your issue is making your wrapper have the set width of:
min-width: 1720px;
setting this min-width you are telling the element it has to be that large, which will look odd on mobile as those screens are not that large.There are many fixes for this that are easy, but a quick example which simplifies your code slightly and gives the responsiveness you want is here:
And the HTML
You noted in the comments that you have a "white" area that shows around the divs. To fix items like this and keep a background color consistent you need to style the area holding the page (i.e.
body
) to have the look you want.For example, adding this to your body element will make the whole background blue:
The
wrapper
class has the propertymin-width
set to1720px
which indicates that your content can’t go lower that that width, which makes the horizontal scrollbar appear in lower resolution screens.You probably want to choose a lower value for
min-width
The problem has to do with your min-width attribute. If you change it to a max-width attribute with the same value, the scroll bar disappears.
You can still try a few things after that, like adding the min-width attribute as well, but with a lower value.
But that still works on PCs only and not on all screens. That’s why you need to make your website responsive. The easiest way to do it is with media queries, where you define different CSS codes you want to run on 2 or 3 different screen sizes.
I’m not sure how you want your website to look in the end, therefore I suggest you watch a video or two on YouTube on Responsive Design. This should help you with your endeavors.