Posted By

johnloy on 04/23/09


Tagged

css textmate tricks


Versions (?)

Way to specify the width of an element as percentage pixels


 / Published in: Other
 

  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  

You need to login to post a comment.