Changes for page Academy
Last modified by Erik Bakker on 2024/09/24 16:12
Summary
-
Objects (1 modified, 0 added, 0 removed)
Details
- XWiki.GadgetClass[1]
-
- content
-
... ... @@ -1,26 +1,20 @@ 1 1 {{html}} 2 +<!DOCTYPE html> 2 2 <html> 3 3 <head> 4 -< metaname="viewport"content="width=device-width, initial-scale=1">5 +<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> 5 5 <style> 6 6 * { 7 7 box-sizing: border-box; 8 8 } 9 9 10 -body { 11 - font-family: Arial, Helvetica, sans-serif; 12 -} 13 - 14 -/* Float four columns side by side */ 11 +/* Create two equal columns that floats next to each other */ 15 15 .column { 16 16 float: left; 17 - width: 25%;18 - padding: 010px;14 + width: 50%; 15 + padding: 10px; 19 19 } 20 20 21 -/* Remove extra left and right margins, due to padding */ 22 -.row {margin: 0 -5px;} 23 - 24 24 /* Clear floats after the columns */ 25 25 .row:after { 26 26 content: ""; ... ... @@ -27,63 +27,93 @@ 27 27 display: table; 28 28 clear: both; 29 29 } 24 +/* Style the buttons */ 25 +.btn { 26 + border: none; 27 + outline: none; 28 + padding: 12px 16px; 29 + background-color: #f1f1f1; 30 + cursor: pointer; 31 +} 30 30 31 -/* Responsive columns */ 32 -@media screen and (max-width: 600px) { 33 - .column { 34 - width: 100%; 35 - display: block; 36 - margin-bottom: 20px; 37 - } 33 +.btn:hover { 34 + background-color: #ddd; 38 38 } 39 39 40 -/* Style the counter cards */ 41 -.card { 42 - box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); 43 - padding: 16px; 44 - text-align: center; 45 - background-color: #f1f1f1; 37 +.btn.active { 38 + background-color: #666; 39 + color: white; 46 46 } 47 47 </style> 48 48 </head> 49 49 <body> 50 50 51 -<h2>Responsive Column Cards</h2> 52 -<p>Resize the browser window to see the effect.</p> 45 +<h2>List View or Grid View</h2> 53 53 47 +<p>Click on a button to choose list view or grid view.</p> 48 + 49 +<div id="btnContainer"> 50 + <button class="btn" onclick="listView()"><i class="fa fa-bars"></i> List</button> 51 + <button class="btn active" onclick="gridView()"><i class="fa fa-th-large"></i> Grid</button> 52 +</div> 53 +<br> 54 + 54 54 <div class="row"> 55 - <div class="column"> 56 - <div class="card"> 57 - <h3>Card 1</h3> 58 - <p>Some text</p> 59 - <p>Some text</p> 60 - </div> 56 + <div class="column" style="background-color:#aaa;"> 57 + <h2>Column 1</h2> 58 + <p>Some text..</p> 61 61 </div> 60 + <div class="column" style="background-color:#bbb;"> 61 + <h2>Column 2</h2> 62 + <p>Some text..</p> 63 + </div> 64 +</div> 62 62 63 - <div class="column"> 64 - <div class="card"> 65 - <h3>Card 2</h3> 66 - <p>Some text</p> 67 - <p>Some text</p> 68 - </div> 66 +<div class="row"> 67 + <div class="column" style="background-color:#ccc;"> 68 + <h2>Column 3</h2> 69 + <p>Some text..</p> 69 69 </div> 70 - 71 - <div class="column"> 72 - <div class="card"> 73 - <h3>Card 3</h3> 74 - <p>Some text</p> 75 - <p>Some text</p> 76 - </div> 71 + <div class="column" style="background-color:#ddd;"> 72 + <h2>Column 4</h2> 73 + <p>Some text..</p> 77 77 </div> 78 - 79 - <div class="column"> 80 - <div class="card"> 81 - <h3>Card 4</h3> 82 - <p>Some text</p> 83 - <p>Some text</p> 84 - </div> 85 - </div> 86 86 </div> 76 + 77 +<script> 78 +// Get the elements with class="column" 79 +var elements = document.getElementsByClassName("column"); 80 + 81 +// Declare a loop variable 82 +var i; 83 + 84 +// List View 85 +function listView() { 86 + for (i = 0; i < elements.length; i++) { 87 + elements[i].style.width = "100%"; 88 + } 89 +} 90 + 91 +// Grid View 92 +function gridView() { 93 + for (i = 0; i < elements.length; i++) { 94 + elements[i].style.width = "50%"; 95 + } 96 +} 97 + 98 +/* Optional: Add active class to the current button (highlight it) */ 99 +var container = document.getElementById("btnContainer"); 100 +var btns = container.getElementsByClassName("btn"); 101 +for (var i = 0; i < btns.length; i++) { 102 + btns[i].addEventListener("click", function() { 103 + var current = document.getElementsByClassName("active"); 104 + current[0].className = current[0].className.replace(" active", ""); 105 + this.className += " active"; 106 + }); 107 +} 108 +</script> 109 + 87 87 </body> 88 88 </html> 112 + 89 89 {{/html}}