Advertisement
Guest User

Untitled

a guest
Jul 20th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. <!Doctype html>
  2. <head>
  3.  
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.  
  7.  
  8. <style type="text/css">
  9. body{
  10. margin: 0;
  11. padding: 0;
  12. background-color: red;
  13. }
  14.  
  15. #header{
  16. width: 100%;
  17. height: 200px;
  18. background-color: orange;
  19. }
  20.  
  21. #navigation{
  22. position: absolute;
  23. top: 200px;
  24. width: 100%;
  25. height: 45px;
  26. background-color: green;
  27. }
  28.  
  29. #navigation.fixed{
  30. top: 0;
  31. position: fixed;
  32. width: 100%;
  33. height: 45px;
  34. background-color: green;
  35. }
  36.  
  37.  
  38.  
  39. #nav-wrapper{
  40. width: 1200px;
  41. margin: 0 auto;
  42. background-color:blue;
  43. height: 45px;
  44. }
  45.  
  46.  
  47. #hiddenObject {
  48. display: none;
  49. }
  50.  
  51.  
  52. #Farbe1{
  53. margin: 0; /* 46px - Höhe der Nav + Höhe Header 250px = 296px */
  54. width: 100%;
  55. background-color:white;
  56. height: 140px;
  57. }
  58.  
  59. #Farbe1.fixed{
  60. position: fixed;
  61. top: 46px; /* 46 px - Höhe Nav leiste */
  62. width: 100%;
  63. background-color:white;
  64. height: 140px;
  65. }
  66.  
  67. #tablenav{
  68. position:relative;
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. .arrow{
  79. display:none;
  80. }
  81.  
  82. #desk1{
  83. background-color: white;
  84. }
  85.  
  86. #arrow2{
  87. margin:0;
  88. padding: 0;
  89.  
  90. }
  91.  
  92.  
  93.  
  94. @media screen and (max-width:1200px){
  95. #nav-wrapper{
  96. width: 950px;
  97. margin: 0 auto;
  98. }
  99.  
  100. @media screen and (max-width:1100px){
  101. #nav-wrapper{
  102. width: 900px;
  103. margin: 0 auto;
  104. }
  105.  
  106. @media screen and (max-width:900px){
  107. #nav-wrapper{
  108. width: 700px;
  109. margin: 0 auto;
  110. }
  111.  
  112. @media screen and (max-width:700px){
  113. #nav-wrapper{
  114. width: 100%;
  115. margin: 0 auto;
  116. }
  117.  
  118. .arrow{
  119. display:inline;
  120. }
  121.  
  122. #tablenav{
  123. display:none;
  124. }
  125.  
  126.  
  127.  
  128. @media screen and (max-width:500px){
  129. #nav-wrapper{
  130. width: 100%;
  131. margin: 0 auto;
  132. }
  133.  
  134. #tablenav{
  135. display:none;
  136. }
  137. }
  138.  
  139.  
  140. </style>
  141.  
  142.  
  143. <script src="http://code.jquery.com/jquery-latest.js"></script>
  144. <script>
  145. $(document).on('click', '#handler', function(e) {
  146. e.preventDefault();
  147. if (!$(this).hasClass('active')) {
  148. $('#hiddenObject').show();
  149. } else {
  150. $('#hiddenObject').hide();
  151. }
  152.  
  153. $(this).toggleClass('active');
  154. });
  155. </script>
  156.  
  157.  
  158.  
  159.  
  160. </head>
  161.  
  162.  
  163. <body>
  164. <div id="header">
  165. Hallo!
  166. </div>
  167.  
  168. <div id="navigation">
  169. <div id="nav-wrapper">
  170.  
  171.  
  172.  
  173.  
  174.  
  175. <table id="tablenav" width="100%" height="45px">
  176. <tr id="rownav">
  177.  
  178. <td id="desk1">
  179. <a href="http://google.com"><center>Hallo</center></a>
  180. </td>
  181.  
  182. <td id="desk2d" width="1px">
  183. <a href="http://facebook.com"><img id="handler" src="arrow.png"></a>
  184. </td>
  185.  
  186. <td id="desk3">
  187. <center>Hallo</center>
  188. </td>
  189.  
  190. <td id="desk4d" width="1px">
  191. <img id="arrow2" src="arrow.png">
  192. </td>
  193.  
  194. <td id="desk5">
  195. <center>Hallo</center>
  196. </td>
  197.  
  198. <td id="desk6d" width="1px">
  199. <img id="arrow2" src="arrow.png">
  200. </td>
  201.  
  202. <td id="desk7">
  203. <center>Hallo</center>
  204. </td>
  205.  
  206. <td id="desk8d" width="1px">
  207. <img id="arrow2" src="arrow.png">
  208. </td>
  209.  
  210. <td id="desk9">
  211. <center>Hallo</center>
  212. </td>
  213.  
  214. <td id="desk10d" width="1px">
  215. <img id="arrow2" src="arrow.png">
  216. </td>
  217.  
  218. </tr>
  219.  
  220. <table>
  221.  
  222. </div>
  223. </div>
  224.  
  225.  
  226. <div id="hiddenObject">
  227. <div id="Farbe1">
  228. <a href="http://Facebook.com">Email-Seite</a>
  229. </div>
  230. </div>
  231.  
  232.  
  233.  
  234.  
  235.  
  236. <div id="bodyspan">
  237. <br><br><br><br><br>
  238. WILLKOMMEN!!!
  239.  
  240.  
  241. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
  242. Dicta, natus nostrum enim laboriosam, placeat inventore vitae
  243. in libero dolore quas Lorem ipsum dolor sit amet, consectetur
  244. adipisicing elit. Officiis, aut. Distinctio vel, saepe ipsam
  245. sapiente magnam consequatur quibusdam, porro ad inventore qui.
  246. Distinctio hic placeat debitis quibusdam porro, ipsum aliquam?
  247. tempore accusamus! Ad unde incidunt architecto vero beatae earum sequi.
  248. Lorem ipsum dolor sit amet, consectetur adipisicing elit.
  249. Assumenda totam quisquam, tenetur nobis incidunt adipisci
  250. pariatur architecto, sit temporibus veritatis, cum voluptates.
  251. Quaerat cum quam possimus perspiciatis non temporibus laboriosam!
  252. Lorem ipsum dolor sit amet, consectetur adipisicing elit.
  253. Vitae numquam amet consectetur labore optio corrupti porro magnam,
  254. veniam corporis, aperiam blanditiis eum odio quia laborum at reprehenderit
  255. accusamus facere autem!</p>
  256.  
  257. <br><br><br><br><br><br><br><br><br><br><br><br><br>
  258. <br><br><br><br><br><br><br><br><br><br><br><br><br>
  259. <br><br><br><br><br><br><br><br><br><br><br><br><br>
  260.  
  261. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
  262. Dicta, natus nostrum enim laboriosam, placeat inventore vitae
  263. in libero dolore quas tempore accusamus! Ad unde incidunt architecto
  264. vero beatae earum sequi.</p>
  265.  
  266.  
  267. </div>
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274. <script type="text/javascript">
  275. var navi = document.getElementById("navigation");
  276. var farbe = document.getElementById("Farbe1");
  277. var naviPosY = navi.offsetTop;
  278. var farbePosY = farbe.offsetTop;
  279.  
  280. document.addEventListener("scroll", function(e) {
  281. if (window.scrollY >= naviPosY){
  282. navi.className ="fixed";
  283. farbe.className ="fixed";
  284. } else {
  285. navi.className ="absolute";
  286. farbe.className ="absolute";
  287. }
  288. });
  289. </script>
  290.  
  291. </body>
  292.  
  293.  
  294. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement