Way to specify the width of an element as percentage pixels


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /*
  2.  
  3. Based on Stu Nicols demo at http://www.cssplay.co.uk/boxes/outside.html
  4.  
  5. Set the percentage width on the out element and the extra pixels-based width extension on the inner using negative margins
  6.  
  7. */
  8.  
  9. .outside {
  10. position: relative;
  11. width: 25%;
  12. background: #9caf9c;
  13. color: #fff;
  14. margin: 1em auto;
  15. }
  16. .inside {
  17. display: block;
  18. position: relative;
  19. color: #000;
  20. margin: 0 -50px;
  21. background: #c4c4c4;
  22. color: #000;
  23. }
  24.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.