Crenox

Web Development Tutorial for Beginners LearnCode.academy #3

Jun 24th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>CSS Layout</title>
  5. <link href="styles/main.css" rel="stylesheet" type="text/css" />
  6. <!-- UTF-8 is a variable width Unicode format that is compatible with ASCII or plain text for the basic alphanumeric characters.
  7. By using the 'upper half' of the 8 bit ASCII set and extension codes, it can handle over a million unique characters... -->
  8. <meta charset="UTF-8">
  9. </head>
  10. <body>
  11. <header>
  12. <nav>
  13. <h1>My Page</h1>
  14. <ul>
  15. <li><a href="#">Home</a></li>
  16. <li><a href="#">Blog</a></li>
  17. <li><a href="#">About</a></li>
  18. <li><a href="#">Contact</a></li>
  19. <li><a href="#">Links</a></li>
  20. </ul>
  21. </nav>
  22. </header>
  23.  
  24. <div>
  25. <div class="col">col1</div>
  26. <div class="col">col2</div>
  27. <div class="col">col3</div>
  28. </div>
  29.  
  30. <footer>©2015 My Site</footer>
  31. </body>
  32. </html>
  33. -------------------------------------------------------------------------------------------------------------------------------
  34. body
  35. {
  36. /* by default the body has some margin */
  37. margin: 0;
  38. }
  39.  
  40. header
  41. {
  42. background: #999;
  43. color: white;
  44. padding: 15px 15px 0px 15px;
  45. }
  46.  
  47. header h1
  48. {
  49. /* by default it has margins */
  50. margin: 0;
  51. /* this is going to be inline with the nav since we put inline */
  52. display: inline;
  53. }
  54.  
  55. nav ul
  56. {
  57. /* by default it has margins */
  58. margin: 0;
  59. /* this is going to be inline with the nav since we put inline */
  60. display: inline;
  61. padding: 0 0 0 15px;
  62. }
  63.  
  64. nav ul li
  65. {
  66. /* makes the list items all next to each other, and allows you to specify the list items more */
  67. display: inline-block;
  68. list-style-type: none;
  69. background: black;
  70. color: white;
  71. /* padding spaces from the inside */
  72. padding: 5px 15px; /* you can also put: padding: 5px 15px 5px 15px */
  73. }
  74.  
  75. nav ul li a
  76. {
  77. color: white;
  78. }
  79.  
  80. /*
  81. what after (a pseudo-element) does, is make a fake element after the row, and does whatever
  82. we tell it too.
  83.  
  84. so for this example, we say that after the row, clear both.
  85. */
  86. .row:after
  87. {
  88. /* forget about the floats and wrap around */
  89. clear: both;
  90. /*
  91. these next two lines are if you have multiple other divs
  92. for the class row
  93. */
  94. content: " ";
  95. display: table;
  96. }
  97.  
  98. .col
  99. {
  100. background: #333;
  101. border-radius: 5px;
  102. /* everything within the column now floats left */
  103. float: left;
  104. width: 31%;
  105. margin: .5%;
  106. padding: 10px .5%;
  107. color: white;
  108. }
  109.  
  110. footer
  111. {
  112.  
  113. }
  114.  
  115. /*
  116. margin spaces from the outside, padding spaces from the inside
  117.  
  118. Wwen you float things, they're gonna just keep wrapping around
  119.  
  120. when you use percentage layouts, it's the best because it'll
  121. look the best on all devices
  122. */
Add Comment
Please, Sign In to add comment