Issue
Please help! When the screen resolution decreases, the header moves out, even though I have width: 100%; I was looking for answers and didn't find it anywhere!
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
max-width: 1140px;
margin: 0 auto;
}
header {
width: 100%;
background-color: darkblue;
}
<header>
<div class="container">
ghjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjhjhh jhhhjkhnkj
</div>
</header>
<section>hgjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj</section>
Solution
There is nothing wrong with the width:100%, you just made overflow by setting the child element width to greater than the parent element.
A possible solution, use overflow:hidden or overflow:scroll (determined by which effect you want)
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
max-width: 1140px;
margin: 0 auto;
}
header {
width: 100%;
background-color: darkblue;
overflow:scroll;
}
<header>
<div class="container">
ghjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjhjhhjhhhjkhnkj
</div>
</header>
<section>hgjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj</section>
overflow-wrap: break-word to let overflowed content automactially go to next line
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
max-width: 1140px;
margin: 0 auto;
}
header {
overflow-wrap: break-word;;
width: 100%;
background-color: darkblue;
}
<header>
<div class="container">
ghjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjhjhh jhhhjkhnkj
</div>
</header>
<section>hgjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj</section>
Answered By - James
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.