Advertisement
Guest User

04. Sections

a guest
Feb 18th, 2018
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Sections</title>
  6.     <style>
  7.         #content {
  8.             width: 1000px;
  9.         }
  10.  
  11.         #content div {
  12.             float: left;
  13.             width: 300px;
  14.             height: 300px;
  15.             margin: 2em;
  16.             background: #5555ff;
  17.             text-align: center;
  18.         }
  19.  
  20.         #content div p {
  21.             color: white;
  22.             margin: 6em 3em 6em 3em;
  23.         }
  24.     </style>
  25. </head>
  26. <div id="content">
  27. </div>
  28. <body onload="create(['Section 1', 'Section 2', 'Section 3', 'Section 4']);">
  29. <script>
  30.     function create(words) {
  31.         for (let word of words) {
  32.             let div = document.createElement('div');
  33.             let paragraph = document.createElement('p');
  34.             paragraph.textContent = word;
  35.             div.appendChild(paragraph);
  36.  
  37.             let contentDiv = document.getElementById('content');
  38.             contentDiv.appendChild(div);
  39.         }
  40.     }
  41. </script>
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement