Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. ____________________________________________
  2. | HEADER 1 |
  3. |________breaks to new line__________________|
  4. |____________________________HEADER2_________|
  5. | | ||
  6. | | ||
  7. | This is my scroller | ||
  8. | | ||
  9. | | ||
  10. | | ||
  11. |_________________________________________|_||
  12. | Some |
  13. |_____Footer_________________________________|
  14.  
  15. <div class="wrapper">
  16. <div class="header">
  17. Some<br/>
  18. Header
  19. </div>
  20. <div class="scroller">
  21. Content<br />
  22. Content<br />
  23. Content<br />
  24. Content<br />
  25. ...
  26. </div>
  27. <div class="footer">
  28. Some<br/>
  29. Footer
  30. </div>
  31. </div>
  32.  
  33. body{
  34. height:100%;
  35. }
  36. .wrapper{
  37. height:400px;
  38. border-left:1px solid red;
  39. }
  40. .header, .footer{
  41. background-color: #EEE;
  42. height:27px;
  43. }
  44. .scroller{
  45. height:calc(100% - 54px);
  46. background-color: #CCC;
  47. overflow:auto;
  48. }
  49.  
  50. <div class="wrapper">
  51. <div class="tr stretch">
  52. <div class="td">a header</div>
  53. </div>
  54. <div class="tr">
  55. <div class="td">
  56. <div class="contentWrapper">
  57. <div class="content">
  58. content 0
  59. ...............
  60. ...............
  61. ...............
  62. content 29
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="tr stretch">
  68. <div class="td stretch">a footer</div>
  69. </div>
  70. </div>
  71.  
  72. .wrapper {
  73. height : 200px;
  74. width : 200px;
  75. display : table;
  76. }
  77.  
  78. .tr { display : table-row; }
  79.  
  80. .td { display : table-cell; }
  81.  
  82. .stretch { height : 1%; }
  83.  
  84. .contentWrapper {
  85. position : relative;
  86. overflow-y : scroll;
  87. height : 100%;
  88. }
  89.  
  90. .content {
  91. position : absolute;
  92. right : 0;
  93. left : 0;
  94. }
  95.  
  96. $(document).ready(function(){
  97. $('.scroller').css("margin-top", $('.header').height());
  98.  
  99. var height = $('.wrapper').height() - ($('.footer').height() + $('.header').height());
  100.  
  101. $('.scroller').css("height", height);
  102. });
  103.  
  104. .wrapper{
  105. height:400px;
  106. border-left:1px solid red;
  107. position: relative;
  108. }
  109.  
  110. .header, .footer, .scroller {
  111. background-color: #EEE;
  112. position:absolute;
  113. width: 100%;
  114. }
  115. .footer {
  116. bottom: 0;
  117. }
  118.  
  119. .scroller{
  120. background-color: #CCC;
  121. overflow:auto;
  122. }
  123.  
  124. $(document).ready(function(){
  125. $('.scroller').css("top", $('.header').height());
  126. $('.scroller').css("bottom", $('.footer').height());
  127. });
  128.  
  129. $(document).ready(function(){
  130. $('.scroller').css("padding-top", $('.header').height());
  131. });
  132.  
  133. var CalcHeight = function() {
  134. this.init = function() {
  135. var totHeight = $('body').height();
  136. var componentsHeight = $('.headers').height() + $('.footers').height();
  137. var diff = totHeight - componentsHeight;
  138. $('.hider').css({
  139. height: diff
  140. });
  141. }
  142.  
  143. this.init();
  144. }
  145.  
  146. var calcHeight = new CalcHeight;
  147.  
  148. <div class="wrapper">
  149. <div class="header">
  150. Some<br/>
  151. Header
  152. </div>
  153. <div class="scroller">
  154. Content<br />
  155. Content<br />
  156. Content<br />
  157. Content<br />
  158. ...
  159. </div>
  160. <div class="footer">
  161. Some<br/>
  162. Footer
  163. </div>
  164. </div>
  165.  
  166. .wrapper{
  167. height:400px;
  168. border-left:1px solid red;
  169. display: grid;
  170. grid-template-columns: 1fr;
  171. grid-template-rows: [header] auto [content]1fr [footer]auto;
  172. }
  173. .header{
  174. background-color: #EEE;
  175. grid-row: header;
  176. }
  177. .footer{
  178. background-color: #EEE;
  179. grid-row: footer;
  180. }
  181. .scroller{
  182. background-color: #CCC;
  183. overflow:auto;
  184. grid-row: content
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement