CSS width:100% with margin

Due to box model, If I set

   .background {
      width: 100%;
      margin: 8px 0;
     }

The width of backfground would go beyond 100%, and make the scroll bar visible.

Found a better approach seting streching style background:

    .background {
      left: 0;
      right: 0;
      margin: 8px 0;
      }

Perfectly solved.

comments powered by Disqus