asimryu

20150922코딩연습2

Sep 22nd, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.90 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>HTML5</title>
  6. <style>
  7. header {
  8. width:100%;
  9. height:300px;
  10. background-image:url(images/main.jpg);
  11. background-position: center;
  12. }
  13. nav {
  14.     width:100%;
  15.     height: 50px;
  16.     background-color:rgb(0,0,0);
  17. }
  18. nav a {
  19.     padding:0 10px;
  20.     height:50px;
  21.     color:white;
  22.     font-size: 1.7em;
  23.     line-height:50px;
  24.     display:inline-block;
  25.     text-decoration:none;
  26. }
  27. nav a:hover {
  28.     background-color:#f00;
  29. }
  30. body { margin:0; }
  31. .wrap {
  32.     width:1000px;
  33.     margin:0 auto;
  34. }
  35. .hmenu { display: none;}
  36. @media screen and (max-width: 1000px) {
  37.     .wrap { width: 100%; }
  38.     header { background-size:cover; }
  39. }
  40. @media screen and (max-width: 768px) {
  41.     header { height:200px; }
  42.     nav { height:30px; }
  43.     nav a {
  44.         height:30px;
  45.         line-height: 30px;
  46.         font-size: 1.3em;
  47.     }
  48. }
  49. @media screen and (max-width: 320px) {
  50.     header { height:100px; }
  51.     .hmenu {
  52.         height: 30px;
  53.         width: 100%;
  54.         display: block;
  55.         background-color: black;
  56.         color: white;
  57.         line-height: 30px;
  58.         cursor:pointer;
  59.         border-bottom:1px solid white;
  60.     }
  61.     nav { height:auto; display:none;}
  62.     nav a {
  63.         height:30px;
  64.         line-height: 30px;
  65.         font-size: 0.8em;
  66.         display: block;
  67.         width: 100%;
  68.         border-bottom:1px solid white;
  69.     }
  70. }
  71. </style>
  72. </head>
  73. <body>
  74. <div class="wrap">
  75. <header id="hdr"></header>
  76. <div class="hmenu">MENU...</div>
  77. <nav>
  78. <a href="#" class="menu" onmouseover="bg('food')">HOME</a>
  79. <a href="#" class="menu" onmouseover="bg('cats')">JavaScript</a>
  80. <a href="#" class="menu" onmouseover="bg('sports')">CSS</a>
  81. <a href="#" class="menu" onmouseover="bg('transport')">PHP&amp;MySql</a>
  82. </nav>
  83. </div>
  84. <script src="http://code.jquery.com/jquery-latest.js"></script>
  85. <script>
  86. function bg(c) {
  87.     var src = "images/" + c + ".jpg";
  88.     var url = "url(" + src + ")";
  89.     $("#hdr").css("background-image",url);
  90. }
  91. $(".hmenu").click(function(){
  92.     $("nav").toggle();
  93. });
  94. </script>
  95. </body>
  96. </html>
Advertisement
Add Comment
Please, Sign In to add comment