Advertisement
Guest User

sections

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