code_junkie

Centering a div block without the width

Nov 12th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <style>
  2. .product_container {
  3. text-align: center;
  4. height: 150px;
  5. }
  6.  
  7. .products {
  8. height: 140px;
  9. text-align: center;
  10. margin: 0 auto;
  11. clear: ccc both;
  12. }
  13. .price {
  14. margin: 6px 2px;
  15. width: 137px;
  16. color: #666;
  17. font-size: 14pt;
  18. font-style: normal;
  19. border: 1px solid #CCC;
  20. background-color: #EFEFEF;
  21. }
  22. </style>
  23.  
  24. <div class="product_container">
  25. <div class="products" id="products">
  26. <div id="product_15">
  27. <img src="/images/ecommerce/card_default.png">
  28. <div class="price">R$ 0,01</div>
  29. </div>
  30.  
  31. <div id="product_15">
  32. <img src="/images/ecommerce/card_default.png">
  33. <div class="price">R$ 0,01</div>
  34. </div>
  35.  
  36. <div id="product_15">
  37. <img src="/images/ecommerce/card_default.png">
  38. <div class="price">R$ 0,01</div>
  39. </div>
  40. </div>
  41. </div>
  42.  
  43. <div class="product_container">
  44. <div class="outer-center">
  45. <div class="product inner-center">
  46. </div>
  47. </div>
  48. <div class="clear"></div>
  49. </div>
  50.  
  51. .outer-center {
  52. float: right;
  53. right: 50%;
  54. position: relative;
  55. }
  56. .inner-center {
  57. float: right;
  58. right: -50%;
  59. position: relative;
  60. }
  61. .clear {
  62. clear: both;
  63. }
  64.  
  65. div.outer{
  66. display:inline-block;
  67. position:relative;
  68. left:50%;
  69. }
  70.  
  71. div.inner{
  72. position:relative;
  73. left:-50%;
  74. }
  75.  
  76. margin: 0px auto;
  77. padding: 0px;
  78. border:0;
  79. width: 700px;
  80.  
  81. #mainContent {
  82. position:absolute;
  83. width:600px;
  84. background:#FFFF99;
  85. }
  86.  
  87. #sidebar {
  88. float:left;
  89. margin-left:610px;
  90. max-width:300;
  91. background:#FFCCCC;
  92. }
  93. #sidebar{
  94.  
  95.  
  96. text-align:center;
  97. }
  98.  
  99. <center>
  100. <table border="0" cellspacing="0">
  101. <tr>
  102. <td>
  103. <div id="mainContent">
  104. 1<br/>
  105. <br/>
  106. 123<br/>
  107. 123<br/>
  108. 123<br/>
  109. </div><div id="sidebar"><br/>
  110. </div></td>
  111. </tr>
  112. </table>
  113. </center>
Add Comment
Please, Sign In to add comment