code_junkie

How do I align spans or divs horizontally?

Nov 11th, 2011
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. .floatybox {
  2. display: inline-block;
  3. width: 123px;
  4. }
  5.  
  6. <style>
  7. #whatever div {
  8. display: inline
  9. margin: 0 1em 0 1em
  10. width: 30%
  11. }
  12. </style>
  13.  
  14. <div id="whatever">
  15. <div>content</div>
  16. <div>content</div>
  17. <div>content</div>
  18. </div>
  19.  
  20. <div style="float: left;"></div>
  21.  
  22. <div style="display: inline;"></div>
  23.  
  24. <style>
  25. html, body{
  26. margin: 0;
  27. padding: 0;
  28. }
  29.  
  30. .content{
  31. float: left;
  32. width: 30%;
  33. border:none;
  34. }
  35.  
  36. .rightcontent{
  37. float: right;
  38. width: 30%;
  39. border:none
  40. }
  41.  
  42. .hspacer{
  43. width:5%;
  44. float:left;
  45. }
  46.  
  47. .clear{
  48. clear:both;
  49. }
  50. </style>
  51.  
  52. <div class="content">content</div>
  53. <div class="hspacer">&nbsp;</div>
  54. <div class="content">content</div>
  55. <div class="hspacer">&nbsp;</div>
  56. <div class="rightcontent">content</div>
  57. <div class="clear"></div>
Add Comment
Please, Sign In to add comment