<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport"…
- Usercode
<script src="script.js"></script>codehandleEvent(layoutType) { this.presenter.setLayout(layoutType); }}
class Presenter { constructor(containerId) { this.container = document.getElementById(containerId); this.divs = this.container.querySelectorAll('.inner-div'); }
codesetLayout(layoutType) { this.divs.forEach(div => { div.style.display = 'none'; div.style.removeProperty('left'); div.style.removeProperty('top'); div.style.removeProperty('right'); div.style.removeProperty('bottom'); div.textContent = ''; }); switch (layoutType) { case 'A': this.divs[0].style.display = 'block'; this.divs[0].style.left = '0'; this.divs[0].style.top = '0'; this.divs[0].textContent = 'Michal'; this.divs[1].style.display = 'block'; this.divs[1].style.left = '45%'; this.divs[1].style.top = '45%'; this.divs[1].textContent = 'Zwolinski'; this.divs[2].style.display = 'block'; this.divs[2].style.right = '0'; this.divs[2].style.bottom = '0'; this.divs[2].textContent = '3'; break; case 'B': this.divs.forEach((div, index) => { if (index < 3) { div.style.display = 'block'; div.style.left = `${index * 40}%`; div.style.top = '45%'; div.textContent = index === 0 ? 'Michal' : (index === 1 ? 'Zwolinski' : ''); this.divs[0].style.left = '12%'; this.divs[2].style.right = '60%'; this.divs[1].style.left = '46%'; this.divs[2].textContent = '3'; } else { div.style.display = 'none'; } }); break; case 'C': this.divs[0].style.display = 'block'; this.divs[0].style.left = '0'; this.divs[0].style.top = '0'; this.divs[1].style.display = 'block'; this.divs[1].style.left = '10%'; this.divs[1].style.top = '0'; this.divs[2].style.display = 'block'; this.divs[2].style.right = '0'; this.divs[2].style.bottom = '0'; this.divs[0].textContent = 'Michal'; this.divs[1].textContent = 'Zwolinski'; this.divs[2].textContent = '4'; this.divs[3].style.display = 'block'; this.divs[3].style.right = '10%'; this.divs[3].style.bottom = '0'; this.divs[3].textContent = '3'; break; } } - Assistant
To make the text centered within each of the boxes, you can apply CSS to these elements to align the text both horizontally and vertically. You mentioned that the CSS already configures the property for the with , along with and . This setup should already center the text properly.
- User
napisz mi caly kod bo musze wkleic
- Assistant