HTML/CSS - How do I fix width:100% cutting off when the content creates a horizontal scroll bar? -


i've looked solution , have never found one. maybe didn't hard enough, i've tried doesn't work. problem has bothered me forever , i've never been able fix it.

my problem occurs when trying make div or other element take 100% of width of page. container of content on page 960px. when in fullscreen browser there no problem, when adjust browser window size smaller width of content create horizontal scroll bad , 100% elements not retain 100% width, creating cutoff.

here example page: http://www.yenrac.net/

does know how fix this? element in case red header banner @ top of website.

html (actually little php wordpress):

  <body> <div class="header">   <div class="clearfix" id="header">     <h1><?php bloginfo('name'); ?></h1>     <h3>a spooky site</h3>    </div> </div> 

css:

body {   margin: 0px; }  .header {   height: 100px;   width: 100%;   background: #8f2525;   color: #fff; }  .clearfix {   width: 960px;   height: 100px;   margin: 0 auto; }  .clearfix h1 {   margin: 0px;   padding: 15px 0px 0px 10px;   color: #fff; }  .clearfix h3 {   margin: 0px;   padding: 0px 10px; } 

this effect happens when zooming in far enough make content exceed border of browser window/viewport.

first, don't use clearfix class that. has specific common use , you'll confuse , others later.

your clearfix width 960px. parent, header, set 100% width. header size page. clearfix 960px regardless of page or parent width how set it.

depending on want, there several solutions:

  1. set width:100% on clearfix, rather width:960px
  2. set max-width:100% on clearfix
  3. remove width:960px clearfix

based on other comments, want option 2.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -