Advertisement
asimryu

20150922코딩연습1

Sep 22nd, 2015
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.25 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. @media screen and (max-width: 1000px) {
  36.     .wrap { width: 100%; }
  37.     header { background-size:cover; }
  38. }
  39. @media screen and (max-width: 768px) {
  40.     header { height:200px; }
  41. }
  42. @media screen and (max-width: 320px) {
  43.     header { height:100px; }
  44. }
  45. </style>
  46. </head>
  47. <body>
  48. <div class="wrap">
  49. <header id="hdr"></header>
  50. <nav>
  51. <a href="#" onmouseover="bg('food')">HOME</a>
  52. <a href="#" onmouseover="bg('cats')">JavaScript</a>
  53. <a href="#" onmouseover="bg('sports')">CSS</a>
  54. <a href="#" onmouseover="bg('transport')">PHP&amp;MySql</a>
  55. </nav>
  56. </div>
  57. <script>
  58. function bg(c) {
  59.     var src = "images/" + c + ".jpg";
  60.     var h = document.getElementById("hdr");
  61.     var url = "url(" + src + ")";
  62.     h.style.backgroundImage = url;
  63. }
  64. </script>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement