Technológie internetuInternet Technologies / Týždeň 4Week 4

BootstrapBootstrap

Minulý týždeň si písal vlastné CSS. Dnes ten istý web prerobíš na Bootstrap: namiesto vlastných pravidiel použiješ hotové triedy (class). Na konci bude tvoj web vyzerať dobre na počítači aj na mobile. Ukážky sú z webu lezeckej steny, ty pokračuješ vo svojej téme z cv02. Nové pojmy sú v tabuľke (table) pojmov.

Last week you wrote your own CSS. Today you rebuild the same website with Bootstrap: instead of your own rules you use ready-made classes. At the end your website will look good on a computer and on a phone. The examples come from a climbing wall website; you continue with your own topic from cv02. New terms are in the table of terms.

TeóriaTheory

Čo je Bootstrap

Bootstrap je hotový súbor CSS, v ktorom sú pripravené stovky class. Vzhľad nepíšeš ako pravidlo do style.css. Prvku (Element) pridáš v HTML class a Bootstrap ho oštýluje. Takému súboru hotových riešení sa hovorí framework. Class sa často píšu po dvoch: prvá hovorí, čo element je (btn, tlačidlo (button)), druhá, ako vyzerá (btn-primary, hlavná farba).

<button class="btn btn-primary">Zapísať prelez</button>

Takto to vyzerá v prehliadači.

Viac: W3Schools: Bootstrap 5 Get Started

Ako Bootstrap pripojiť

Bootstrap sa nesťahuje. Pripája sa odkazom (link) z CDN, to je server, ktorý súbor rozdáva všetkým. Do <head> patrí <link> na Bootstrap a až za ním tvoj css/style.css. Pred </body> patrí <script>. Potrebuje ho menu, ktoré sa na mobile rozbaľuje. V <head> musí zostať <meta name="viewport">, inak sa stránka na mobile nezobrazí správne. Celá kostra je v Ukážke 1.

Container: štruktúra stránky

Zvonku dovnútra. Bootstrap stavia stránku ako škatule v škatuli. Vonkajšia škatuľa je okno prehliadača. V ňom je container: drží obsah v strede, obmedzí jeho šírku a nechá po stranách okraje, aby text nelepil na kraj okna. Minulý týždeň si to isté robil cez max-width a margin: 0 auto. Šírka kontajnera (container) nie je pevná: na širokom monitore je 1320 px, na notebooku 960 px, na mobile celá šírka okna mínus okraje. Class container-fluid ide od okraja po okraj.

Kam container dať. Stránka má tri časti pod sebou: menu, obsah a pätičku (footer). Každá dostane vlastný container, takže všetky tri majú rovnaký ľavý a pravý okraj a sú zarovnané pod sebou.

<nav class="navbar navbar-expand-md bg-dark navbar-dark">
  <div class="container"> ... menu ... </div>
</nav>

<main class="container">
  <section id="routes"> ... </section>
  <section id="about"> ... </section>
</main>

<footer class="bg-light">
  <div class="container"> ... footer ... </div>
</footer>

Pri nav a footer je container vnútri: pozadie ide cez celú šírku okna, obsah je zarovnaný s hlavnou časťou. main je container sám, lebo nemá vlastné pozadie.

Sekcie (Section) v obsahu. Obsah v main delíš na section, jedna section je jedna téma: cesty, o stene, kontakt. Každá section má nadpis (heading) h2 a id, aby sa na ňu dalo odkázať z menu (href="#routes"). Zoznam vecí rovnakého druhu (cesty) je row so stĺpcami (columns) vnútri section; row a columns sú vysvetlené nižšie.

Koľko containers. Bežná stránka má tri: v nav, v main a vo footer. Nie je to limit. Pravidlo je jednoduché: každý pás, ktorý má vlastné pozadie cez celú šírku okna (menu, farebná hlavička (header), footer), dostane container dovnútra, aby obsah v ňom bol zarovnaný s ostatnými. Pásy bez vlastného pozadia dáš všetky do jedného container main. Container do container sa nevkladá: vnútorný by dostal druhé okraje a obsah by bol užší ako zvyšok stránky.

Reťaz škatúľ. Container má pod sebou section, section má pod sebou rows, row má vedľa seba columns, v column je obsah, najčastejšie karta (card). Každá úroveň sa môže opakovať: viac sections v container, viac rows v section, viac columns v row. Section aj card majú rovnakú stavbu ako celá stránka: header (h2, card-header), obsah (rows, card-body) a footer (poznámka, card-footer). Header a footer sú nepovinné. Každá škatuľa je uzavretý celok: dá sa presunúť, skopírovať alebo zmazať bez toho, aby sa pokazil zvyšok stránky.

<main class="container">                       <!-- container: okraje stránky -->

  <section id="routes" class="mb-5">            <!-- section: jedna téma -->
    <h2>Cesty</h2>                             <!-- header section -->

    <div class="row g-3">                      <!-- riadok: 12 dielov -->
      <div class="col-md-4">                   <!-- column: 4 diely -->
        <div class="card h-100">               <!-- card: jedna cesta -->
          <div class="card-header">Línia 7</div>
          <div class="card-body">
            <h5 class="card-title">Modrý previs</h5>
            <p class="card-text">Previs s dobrými chytmi.</p>
          </div>
          <div class="card-footer text-muted">Postavená 21. 9. 2026</div>
        </div>
      </div>
      <div class="col-md-4"> ... ďalšia card ... </div>
      <div class="col-md-4"> ... ďalšia card ... </div>
    </div>

    <div class="row">                          <!-- druhý riadok tej istej section -->
      <div class="col">
        <p>Obťažnosť je uvedená francúzskou stupnicou, v zátvorke UIAA.</p>
      </div>
    </div>

    <p class="text-muted">Aktualizované 5. 10. 2026</p>   <!-- footer section -->
  </section>

  <section id="about" class="mb-5">          <!-- ďalšia section -->
    <h2>O stene</h2>
    <div class="row">
      <div class="col"> ... text ... </div>
    </div>
  </section>

</main>

Prečo nie všetko do div. Značky (Tag) header, nav, main, section, footer hovoria, čo ktorá časť stránky je. Prehliadač podľa nich vie, čo je hlavný obsah a čo menu. Čítačka obrazovky pre nevidiacich podľa nich ponúkne skok rovno na obsah alebo do menu. Vyhľadávač podľa nich vie, čo je na stránke dôležité. div nehovorí nič, je to len obal. Použi ho tam, kde Bootstrap potrebuje obal: na container, row alebo column.

Takto do seba zapadajú škatule. Popis na rámiku hovorí, aký element a akú class rámik znázorňuje. String je vždy container → section → row → col. Zúž okno: container sa zúži, columns padnú pod seba.

okno prehliadača
nav → div.containermenu
main.container
section#routes
h2Cesty
div.row
div.col → card
div.col → card
div.col → card
div.row
div.col → text
p.text-mutedfooter section
section#abouttext o stene
footer → div.containerfooter

Viac: W3Schools: Bootstrap 5 Containers, W3Schools: HTML Semantic Elements

Farby

Farby majú osem názvov. Používajú sa všade rovnako: text-primary je farba textu, bg-primary farba pozadia, btn-primary button, alert-primary oznam.

Názov Farba Na čo
primary modrá hlavná akcia
secondary sivá vedľajšia akcia
success zelená podarilo sa
danger červená chyba, mazanie
warning žltá upozornenie
info tyrkysová informácia
light svetlá svetlé pozadie
dark tmavá tmavé pozadie
<span class="badge text-bg-primary">primary</span>
<span class="badge text-bg-success">success</span>
<span class="badge text-bg-danger">danger</span>

Takto to vyzerá v prehliadači.

primary secondary success danger warning info light dark

Viac: W3Schools: Bootstrap 5 Colors

Riadok (row) a stĺpce (column): grid

Vnútri container je row. Row má vždy 12 rovnakých dielov. Do row dávaš columns col a každému povieš, koľko dielov z 12 zaberie: col-4 sú štyri diely, teda tretina row. Tri také columns dajú spolu 12 a row je plný. Keď dáš dokopy viac ako 12, posledný column spadne do nového row. Column col bez čísla si vezme rovnaký diel ako ostatné columns bez čísla. Class g-3 na row urobí medzery medzi columns.

Poradie je vždy container → row → col. Row smie byť len v container a column len v row.

<div class="container">
  <div class="row g-3">
    <div class="col-4"> Žltá hrana </div>
    <div class="col-4"> Modrý previs </div>
    <div class="col-4"> Červená platňa </div>
  </div>
</div>

Takto to vyzerá v prehliadači. Tri columns po štyroch dieloch zaplnia row.

Žltá hrana
Modrý previs
Červená platňa

Tieto columns sú vedľa seba aj na mobile, lebo nemajú povedané, kedy sa majú preskladať. Ako ich na úzkej obrazovke dať pod seba, je v časti Breakpoint.

Viac: W3Schools: Bootstrap 5 Grid Basic

Pomocné class: odstupy a ako čítať názvy

Pomocná class (utility) nastaví jednu vlastnosť (property) CSS: odstup, zarovnanie, farbu pozadia. Najčastejšie sú odstupy.

Písmeno m je margin (vonkajší odstup), p je padding (vnútorný odstup). Za písmenom môže byť strana. Bez strany platí odstup zo všetkých strán.

Písmeno strany Strana
t hore (top)
b dole (bottom)
s vľavo (start)
e vpravo (end)
x vľavo aj vpravo
y hore aj dole
Stupeň Veľkosť
0 0
1 4 px
2 8 px
3 16 px
4 24 px
5 48 px
auto zvyšok miesta; mx-auto dá element na stred
<div class="p-1">p-1</div>
<div class="p-3">p-3</div>
<div class="p-5">p-5</div>
<div class="mt-4 p-3">mt-4 a p-3</div>
<div class="mx-auto w-50 p-3">mx-auto a w-50: polovičná šírka, na stred</div>

Takto to vyzerá v prehliadači. Farebná plocha je element aj s paddingom. Medzera nad štvrtým element je margin.

p-1
p-3
p-5
mt-4 a p-3
mx-auto a w-50: polovičná šírka, na stred

Ako čítať názvy class

Názvy class majú systém. Keď ho poznáš, class vieš prečítať, aj keď ju vidíš prvýkrát.

Komponent. Class hovorí, čo element je.

<table class="table"> ... </table>

Komponent a variant. Prvá class hovorí, čo to je. Druhá hovorí, ako to vyzerá. Píšu sa obe.

<button class="btn btn-primary">Zapísať prelez</button>
<table class="table table-striped"> ... </table>

Komponent a jeho časť. Class pre časti vo vnútri komponentu.

<div class="card">
  <div class="card-body">
    <h5 class="card-title">Modrý previs</h5>
    <p class="card-text">Línia 7, modré chyty.</p>
  </div>
</div>

Property a hodnota. Jedna class nastaví jednu property CSS.

<h1 class="text-center">Lezecká stena</h1>
<div class="bg-light"> ... </div>

Odstup: písmeno, strana, stupeň. Písmeno m je margin, p je padding.

<div class="p-4 mb-5"> ... </div>
<div class="px-3 py-2"> ... </div>

Prvý riadok čítaš: padding stupeň 4 zo všetkých strán, margin dole stupeň 5. Druhý riadok čítaš: padding vľavo a vpravo stupeň 3, hore a dole stupeň 2.

Viac: W3Schools: Bootstrap 5 Utilities

Card

Card je rámček s obrázkom (image), heading a textom. Hodí sa na zoznam vecí rovnakého druhu, u nás na cesty. Kód je v Ukážke 3.

Viac: W3Schools: Bootstrap 5 Cards

Breakpoint: kedy sa columns preskladajú

Breakpoint je šírka okna, pri ktorej sa rozloženie zmení. Skratka v class znamená „od tejto šírky vyššie”.

Skratka Od šírky Typické zariadenie
(žiadna) 0 mobil
sm 576 px mobil naležato
md 768 px tablet
lg 992 px notebook
xl 1200 px veľký monitor

Jeden element môže mať viac class pre rôzne šírky. Platí tá s najväčším breakpointom, na ktorý je okno dosť široké:

<div class="row g-2">
  <div class="col-12 col-md-6 col-lg-4 col-xl-3"> Žltá hrana </div>
  <div class="col-12 col-md-6 col-lg-4 col-xl-3"> Modrý previs </div>
  <div class="col-12 col-md-6 col-lg-4 col-xl-3"> Červená platňa </div>
  <div class="col-12 col-md-6 col-lg-4 col-xl-3"> Zelený kút </div>
</div>
Šírka okna Platí class Koľko dielov z 12 Columns v riadku
mobil col-12 12 1
tablet (od 768 px) col-md-6 6 2
notebook (od 992 px) col-lg-4 4 3
veľký monitor (od 1200 px) col-xl-3 3 4

Takto to vyzerá v prehliadači. Zužuj a rozširuj okno prehliadača a sleduj, koľko columns je v row.

Žltá hrana
Modrý previs
Červená platňa
Zelený kút

Breakpoint nie je len pre columns. Môže byť v ktorejkoľvek class, vždy uprostred názvu:

<div class="col-md-4"> ... </div>
<p class="d-none d-md-block">Tento text na mobile nevidno.</p>

Prvý riadok čítaš: column, od šírky md vyššie, 4 diely z 12. Druhý riadok čítaš: neukazuj (d-none), od šírky md vyššie ukáž ako blok (d-md-block).

Navbar je hotové menu. Na širokej obrazovke sú položky vedľa seba. Na úzkej obrazovke sa schovajú pod button s tromi čiarkami. Class navbar-expand-md hovorí, od ktorej šírky je menu rozbalené. Class active označí stránku, na ktorej práve si. Class fixed-top pripne menu na vrch okna, minulý týždeň si to robil cez position: fixed. Kód je v Ukážke 2.

Viac: W3Schools: Bootstrap 5 Navbar

Text

<p class="display-4">Lezecká stena</p>
<p class="lead">Úvodný paragraph je o niečo väčší.</p>
<p class="text-center">Text na stred.</p>
<p class="fw-bold">Tučný text.</p>
<p class="text-muted">Menej dôležitý text.</p>

Takto to vyzerá v prehliadači.

Lezecká stena

Úvodný paragraph je o niečo väčší.

Text na stred.

Tučný text.

Menej dôležitý text.

Viac: W3Schools: Bootstrap 5 Typography

Table

Table dostane class table a k nej varianty: table-striped (pruhy), table-hover (row sa zvýrazní pod myšou), table-bordered (rámiky). Obal table-responsive pridá na mobile vodorovné posúvanie, table potom nepretečie mimo stránku.

<div class="table-responsive">
  <table class="table table-striped table-hover">
    <thead>
      <tr><th>Cesta</th><th>Línia</th><th>Chyty</th><th>Obťažnosť</th><th>Postavená</th></tr>
    </thead>
    <tbody>
      <tr><td>Žltá hrana</td><td>3</td><td>žlté</td><td>5a (V)</td><td>14. 9. 2026</td></tr>
      <tr><td>Modrý previs</td><td>7</td><td>modré</td><td>6a (VI+)</td><td>21. 9. 2026</td></tr>
      <tr><td>Červená platňa</td><td>9</td><td>červené</td><td>6b (VII)</td><td>5. 10. 2026</td></tr>
    </tbody>
  </table>
</div>

Takto to vyzerá v prehliadači. Prejdi myšou cez riadky.

Cesta Línia Chyty Obťažnosť Postavená
Žltá hrana 3 žlté 5a (V) 14. 9. 2026
Modrý previs 7 modré 6a (VI+) 21. 9. 2026
Červená platňa 9 červené 6b (VII) 5. 10. 2026

Viac: W3Schools: Bootstrap 5 Tables

Images

Class img-fluid zmenší image tak, aby nepretiekol mimo stránku. Minulý týždeň si to robil cez max-width: 100%. Class rounded zaoblí rohy.

<img src="img/stena.jpg" class="img-fluid rounded" alt="Pohľad na lezeckú stenu">

Takto to vyzerá v prehliadači. Zúž okno, image sa zmenší s ním.

Pohľad na lezeckú stenu

Viac: W3Schools: Bootstrap 5 Images

Alert a badge

Alert je farebný oznam. Badge je malý štítok, u nás obťažnosť pri názve cesty.

<div class="alert alert-success">Registrácia je uložená.</div>
<p>Modrý previs <span class="badge text-bg-warning">6a (VI+)</span></p>

Takto to vyzerá v prehliadači.

Registrácia je uložená.

Modrý previs 6a (VI+)

Viac: W3Schools: Bootstrap 5 Alerts, W3Schools: Bootstrap 5 Badges

Buttons

Button má vždy class btn a k nej variant. Ako button môže vyzerať aj link <a>.

<button type="button" class="btn btn-primary">Zapísať prelez</button>
<button type="button" class="btn btn-outline-primary">Zobraziť cesty</button>
<button type="button" class="btn btn-danger btn-sm">Zmazať</button>
<a href="form.html" class="btn btn-success">Registrácia</a>

Takto to vyzerá v prehliadači.

Registrácia

Viac: W3Schools: Bootstrap 5 Buttons

Komponenty, ktoré sa hýbu

Rozbaľovacie menu alebo accordion (rozbaľovacie odseky (paragraphs)) fungujú bez toho, aby si písal JavaScript. Ovládajú sa atribútmi (attributes) data-bs-… v HTML. Attribute data-bs-target ukazuje na id element, ktorý sa má rozbaliť. Potrebujú <script> z Ukážky 1.

<div class="accordion" id="faq">
  <div class="accordion-item">
    <h2 class="accordion-header">
      <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#otazka1">
        Čo si priniesť
      </button>
    </h2>
    <div id="otazka1" class="accordion-collapse collapse show" data-bs-parent="#faq">
      <div class="accordion-body">Pohodlné oblečenie a čistú obuv. Lezečky a sedák si požičiaš.</div>
    </div>
  </div>
  <div class="accordion-item">
    <h2 class="accordion-header">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#otazka2">
        Ako čítať obťažnosť
      </button>
    </h2>
    <div id="otazka2" class="accordion-collapse collapse" data-bs-parent="#faq">
      <div class="accordion-body">Číslo a písmeno, napríklad 6a. Čím vyššie číslo a písmeno, tým ťažšia cesta.</div>
    </div>
  </div>
</div>

Takto to vyzerá v prehliadači. Klikni na otázku.

Pohodlné oblečenie a čistú obuv. Lezečky a sedák si požičiaš.
Číslo a písmeno, napríklad 6a. Čím vyššie číslo a písmeno, tým ťažšia cesta.

Viac: W3Schools: Bootstrap 5 Collapse

Formulár (Form)

Každé pole (field) dostane class. Attributes name, id a for zostávajú presne ako minulý týždeň. Bootstrap mení len vzhľad.

Element Class
<label> form-label
<input>, <textarea> form-control
<select> form-select
obal jedného radio alebo checkbox form-check
<input type="radio">, <input type="checkbox"> form-check-input
<label> pri radio alebo checkbox form-check-label
<legend> skupiny fs-6 (bežná veľkosť písma)
obal jedného field s odstupom dole mb-3

Celý form je v Ukážke 4.

Viac: W3Schools: Bootstrap 5 Forms

Čo z form odíde

Form o pár týždňov spracuje PHP. PHP dostane dvojice name=hodnota. Preto musíš vedieť, čo je pri ktorom field hodnota.

Field Čo odíde
text, e-mail, číslo, dátum, textarea to, čo používateľ napísal
select value vybranej možnosti, nie text, ktorý vidí človek
radio value jedinej vybranej možnosti v skupine
skupina checkbox (name končí []) value každého zaškrtnutého; keď nie je zaškrtnutý žiadny, neodíde nič
jeden checkbox jeho value, keď je zaškrtnutý; inak neodíde nič

Z toho vyplývajú pravidlá, ktoré platia pre každý form v tomto predmete:

  • Každé field má name. Píše sa malými písmenami, bez diakritiky a bez medzier, slová spája podčiarkovník: since.
  • Každá option, každé radio a každý checkbox má value. Hodnota je krátka, bez diakritiky a bez medzier.
  • Prvá možnosť v select má prázdne value="". Podľa nej sa dá zistiť, že používateľ nič nevybral.
  • Skupina checkboxov, z ktorých sa dá vybrať viac, má name s hranatými zátvorkami: interest[]. PHP tak dostane všetky zaškrtnuté hodnoty naraz ako field (array).

Viac: W3Schools: HTML Form Attributes

Bootstrap a tvoje vlastné CSS

Keď na ten istý element platia dve rovnako silné pravidlá, vyhrá to, ktoré je v poradí neskôr. Preto je style.css pripojený až za Bootstrap. V style.css nechaj len to, čo Bootstrap nemá: svoje farby, class .highlight, :hover. Čo Bootstrap rieši sám (centrovanie obsahu, menu, vzhľad form), zo style.css zmaž. V F12 uvidíš, ktoré pravidlo prehralo: je prečiarknuté (Ukážka 5).

Skúšanie na mobile

Stlač F12. Vľavo hore v paneli, ktorý sa otvoril, je ikona mobilu a tabletu. Klikni na ňu, alebo stlač Ctrl + Shift + M. Stránka sa zobrazí v úzkom okne. Ťahaním okraja meníš šírku a vidíš, kedy sa rozloženie zmení. Zobrazenie mobilu zavrieš tou istou ikonou, F12 zavrieš klávesom F12.

Otvorené F12, vľavo hore v paneli zvýraznená ikona mobilu a tabletu
Ikona mobilu a tabletu je vľavo hore v paneli F12.

Najčastejšie chyby a čo znamenajú

Čo vidíš Príčina Riešenie
stránka vyzerá ako bez štýlov preklep v <link> na Bootstrap, alebo <link> chýba porovnaj s Ukážkou 1
menu sa na mobile nerozbalí chýba <script> pred </body> doplň ho z Ukážky 1
menu sa nerozbalí, hoci <script> je na mieste data-bs-target neukazuje na id menu v button data-bs-target="#menu", v menu id="menu"
columns sú pod sebou aj na širokej obrazovke col nie je priamo v row poradie je container, row, col
posledný column spadol do ďalšieho row columns dávajú spolu viac ako 12 prepočítaj čísla v classes col-md-…
tvoje farby zmizli style.css je pripojený pred Bootstrap vymeň poradie <link>
obsah je schovaný pod menu fixed-top bez odsadenia obsahu v style.css: body { padding-top: 70px; }
na mobile je stránka maličká chýba <meta name="viewport"> doplň ho z Ukážky 1
test hlási, že option nemá value AI nechala možnosť bez hodnoty doplň value každej možnosti okrem textu „– vyber –“, tá má value=""

What Bootstrap is

Bootstrap is a ready-made CSS file with hundreds of prepared classes. You do not write the look as a rule in style.css. You add a class to the element in the HTML and Bootstrap styles it. Such a set of ready-made solutions is called a framework. Classes often come in pairs: the first says what the element is (btn, a button), the second how it looks (btn-primary, the main colour).

<button class="btn btn-primary">Log an ascent</button>

This is what it looks like in the browser.

More: W3Schools: Bootstrap 5 Get Started

How to attach Bootstrap

You do not download Bootstrap. You attach it with a link to a CDN, a server that hands the file out to everyone. The <head> gets a <link> to Bootstrap and only after it your css/style.css. A <script> goes before </body>. The menu that unfolds on a phone needs it. The <meta name="viewport"> must stay in the head, otherwise the page is not displayed correctly on a phone. The whole skeleton is in Example 1.

Container: the structure of a page

From the outside in. Bootstrap builds a page like boxes inside boxes. The outer box is the browser window. Inside it is the container: it keeps the content centred, limits its width and leaves margins on both sides so that the text does not touch the edge of the window. Last week you did the same with max-width and margin: 0 auto. The width of the container is not fixed: on a wide monitor it is 1320 px, on a laptop 960 px, on a phone the full window width minus the margins. The container-fluid class spans the window from edge to edge.

Where to put the container. A page has three parts below each other: the menu, the content and the footer. Each gets its own container, so all three have the same left and right margin and line up below each other.

<nav class="navbar navbar-expand-md bg-dark navbar-dark">
  <div class="container"> ... menu ... </div>
</nav>

<main class="container">
  <section id="routes"> ... </section>
  <section id="about"> ... </section>
</main>

<footer class="bg-light">
  <div class="container"> ... footer ... </div>
</footer>

In nav and footer the container is inside: the background spans the whole window width, the content lines up with the main part. main is the container itself, because it has no background of its own.

Sections in the content. You divide the content in main into sections, one section per topic: routes, about the wall, contact. Every section has an h2 heading and an id, so that the menu can link to it (href="#routes"). A list of things of the same kind (the routes) is a row with columns inside the section; rows and columns are explained below.

How many containers. A typical page has three: in nav, in main and in footer. That is not a limit. The rule is simple: every band that has its own background across the whole window width (the menu, a coloured header, the footer) gets a container inside, so that its content lines up with the rest. Bands without their own background all go into the single main container. A container is never placed inside a container: the inner one would get a second set of margins and its content would be narrower than the rest of the page.

The chain of boxes. A container holds sections below each other, a section holds rows below each other, a row holds columns side by side, and a column holds content, most often a card. Every level can repeat: several sections in a container, several rows in a section, several columns in a row. A section and a card have the same structure as the whole page: a header (h2, card-header), content (rows, card-body) and a footer (a note, card-footer). The header and the footer are optional. Every box is a closed unit: it can be moved, copied or deleted without breaking the rest of the page.

<main class="container">                       <!-- container: page margins -->

  <section id="routes" class="mb-5">            <!-- section: one topic -->
    <h2>Routes</h2>                            <!-- section header -->

    <div class="row g-3">                      <!-- row: 12 parts -->
      <div class="col-md-4">                   <!-- column: 4 parts -->
        <div class="card h-100">               <!-- card: one route -->
          <div class="card-header">Line 7</div>
          <div class="card-body">
            <h5 class="card-title">Blue Overhang</h5>
            <p class="card-text">An overhang with good holds.</p>
          </div>
          <div class="card-footer text-muted">Set on 21 Sep 2026</div>
        </div>
      </div>
      <div class="col-md-4"> ... another card ... </div>
      <div class="col-md-4"> ... another card ... </div>
    </div>

    <div class="row">                          <!-- second row of the same section -->
      <div class="col">
        <p>Grades use the French scale, with UIAA in brackets.</p>
      </div>
    </div>

    <p class="text-muted">Updated 5 Oct 2026</p>   <!-- section footer -->
  </section>

  <section id="about" class="mb-5">          <!-- another section -->
    <h2>About the wall</h2>
    <div class="row">
      <div class="col"> ... text ... </div>
    </div>
  </section>

</main>

Why not put everything in div. The tags header, nav, main, section and footer say what each part of the page is. The browser uses them to know what the main content is and what the menu is. A screen reader for blind users offers a jump straight to the content or to the menu. A search engine uses them to know what matters on the page. A div says nothing, it is just a wrapper. Use it where Bootstrap needs a wrapper: for a container, a row or a column.

This is how the boxes fit together. The label on a frame says which element and class the frame stands for. The chain is always container → section → row → col. Make the window narrower: the container shrinks, the columns drop below each other.

browser window
nav → div.containermenu
main.container
section#routes
h2Routes
div.row
div.col → card
div.col → card
div.col → card
div.row
div.col → text
p.text-mutedsection footer
section#abouttext about the wall
footer → div.containerfooter

More: W3Schools: Bootstrap 5 Containers, W3Schools: HTML Semantic Elements

Colours

Colours have eight names. They are used the same way everywhere: text-primary is text colour, bg-primary background colour, btn-primary a button, alert-primary an alert.

Name Colour Used for
primary blue the main action
secondary grey a secondary action
success green it worked
danger red an error, deleting
warning yellow a warning
info turquoise information
light light a light background
dark dark a dark background
<span class="badge text-bg-primary">primary</span>
<span class="badge text-bg-success">success</span>
<span class="badge text-bg-danger">danger</span>

This is what it looks like in the browser.

primary secondary success danger warning info light dark

More: W3Schools: Bootstrap 5 Colors

Rows and columns (grid)

Inside the container is a row. A row always has 12 equal parts. You put col columns into the row and tell each one how many of the 12 parts it takes: col-4 is four parts, a third of the row. Three such columns add up to 12 and the row is full. When they add up to more than 12, the last column drops into a new row. A col without a number takes the same share as the other columns without a number. The g-3 class on the row makes gaps between the columns.

The order is always container → row → col. A row may only be inside a container and a column only inside a row.

<div class="container">
  <div class="row g-3">
    <div class="col-4"> Yellow Edge </div>
    <div class="col-4"> Blue Overhang </div>
    <div class="col-4"> Red Slab </div>
  </div>
</div>

This is what it looks like in the browser. Three columns of four parts each fill the row.

Yellow Edge
Blue Overhang
Red Slab

These columns stay side by side even on a phone, because nothing tells them when to rearrange. How to stack them on a narrow screen is in the Breakpoint part.

More: W3Schools: Bootstrap 5 Grid Basic

Utility classes: spacing and how to read names

A utility class sets one CSS property: spacing, alignment, background colour. The most common ones are spacing.

The letter m is margin (outer spacing), p is padding (inner spacing). A side can follow the letter. Without a side the spacing applies on all sides.

Side letter Side
t top
b bottom
s left (start)
e right (end)
x left and right
y top and bottom
Step Size
0 0
1 4 px
2 8 px
3 16 px
4 24 px
5 48 px
auto the remaining space; mx-auto centres the element
<div class="p-1">p-1</div>
<div class="p-3">p-3</div>
<div class="p-5">p-5</div>
<div class="mt-4 p-3">mt-4 and p-3</div>
<div class="mx-auto w-50 p-3">mx-auto and w-50: half width, centred</div>

This is what it looks like in the browser. The coloured area is the element with its padding. The gap above the fourth element is margin.

p-1
p-3
p-5
mt-4 and p-3
mx-auto and w-50: half width, centred

How to read class names

Class names follow a system. Once you know it, you can read a class even when you see it for the first time.

A component. The class says what the element is.

<table class="table"> ... </table>

A component and a variant. The first class says what it is. The second says how it looks. You write both.

<button class="btn btn-primary">Log an ascent</button>
<table class="table table-striped"> ... </table>

A component and its part. Classes for the parts inside a component.

<div class="card">
  <div class="card-body">
    <h5 class="card-title">Blue Overhang</h5>
    <p class="card-text">Line 7, blue holds.</p>
  </div>
</div>

A property and a value. One class sets one CSS property.

<h1 class="text-center">Climbing wall</h1>
<div class="bg-light"> ... </div>

Spacing: letter, side, step. The letter m is margin, p is padding.

<div class="p-4 mb-5"> ... </div>
<div class="px-3 py-2"> ... </div>

You read the first line as: padding step 4 on all sides, margin bottom step 5. You read the second line as: padding left and right step 3, top and bottom step 2.

More: W3Schools: Bootstrap 5 Utilities

Card

A card is a box with an image, a heading and text. It suits a list of things of the same kind, in our case routes. The code is in Example 3.

More: W3Schools: Bootstrap 5 Cards

Breakpoint: when the columns rearrange

A breakpoint is the window width at which the layout changes. The abbreviation in a class means “from this width up”.

Abbreviation From width Typical device
(none) 0 phone
sm 576 px phone in landscape
md 768 px tablet
lg 992 px laptop
xl 1200 px large monitor

One element can have several classes for different widths. The one with the largest breakpoint that the window is wide enough for applies:

<div class="row g-2">
  <div class="col-12 col-md-6 col-lg-4 col-xl-3"> Yellow Edge </div>
  <div class="col-12 col-md-6 col-lg-4 col-xl-3"> Blue Overhang </div>
  <div class="col-12 col-md-6 col-lg-4 col-xl-3"> Red Slab </div>
  <div class="col-12 col-md-6 col-lg-4 col-xl-3"> Green Corner </div>
</div>
Window width Class that applies Parts of 12 Columns per row
phone col-12 12 1
tablet (from 768 px) col-md-6 6 2
laptop (from 992 px) col-lg-4 4 3
large monitor (from 1200 px) col-xl-3 3 4

This is what it looks like in the browser. Make the browser window narrower and wider and watch how many columns are in a row.

Yellow Edge
Blue Overhang
Red Slab
Green Corner

A breakpoint is not only for columns. It can be in any class, always in the middle of the name:

<div class="col-md-4"> ... </div>
<p class="d-none d-md-block">This text is not visible on a phone.</p>

You read the first line as: a column, from width md up, 4 parts of 12. You read the second line as: do not show (d-none), from width md up show as a block (d-md-block).

A navbar is a ready-made menu. On a wide screen the items are side by side. On a narrow screen they hide behind a button with three lines. The navbar-expand-md class says from which width the menu is unfolded. The active class marks the page you are on. The fixed-top class pins the menu to the top of the window; last week you did this with position: fixed. The code is in Example 2.

More: W3Schools: Bootstrap 5 Navbar

Text

<p class="display-4">Climbing wall</p>
<p class="lead">The lead paragraph is a little larger.</p>
<p class="text-center">Centred text.</p>
<p class="fw-bold">Bold text.</p>
<p class="text-muted">Less important text.</p>

This is what it looks like in the browser.

Climbing wall

The lead paragraph is a little larger.

Centred text.

Bold text.

Less important text.

More: W3Schools: Bootstrap 5 Typography

Table

A table gets the table class and variants: table-striped (stripes), table-hover (the row is highlighted under the mouse), table-bordered (borders). The table-responsive wrapper adds horizontal scrolling on a phone, so the table does not overflow the page.

<div class="table-responsive">
  <table class="table table-striped table-hover">
    <thead>
      <tr><th>Route</th><th>Line</th><th>Holds</th><th>Grade</th><th>Set on</th></tr>
    </thead>
    <tbody>
      <tr><td>Yellow Edge</td><td>3</td><td>yellow</td><td>5a (V)</td><td>14 Sep 2026</td></tr>
      <tr><td>Blue Overhang</td><td>7</td><td>blue</td><td>6a (VI+)</td><td>21 Sep 2026</td></tr>
      <tr><td>Red Slab</td><td>9</td><td>red</td><td>6b (VII)</td><td>5 Oct 2026</td></tr>
    </tbody>
  </table>
</div>

This is what it looks like in the browser. Move the mouse over the rows.

Route Line Holds Grade Set on
Yellow Edge 3 yellow 5a (V) 14 Sep 2026
Blue Overhang 7 blue 6a (VI+) 21 Sep 2026
Red Slab 9 red 6b (VII) 5 Oct 2026

More: W3Schools: Bootstrap 5 Tables

Images

The img-fluid class shrinks an image so that it does not overflow the page. Last week you did this with max-width: 100%. The rounded class rounds the corners.

<img src="img/stena.jpg" class="img-fluid rounded" alt="A view of the climbing wall">

This is what it looks like in the browser. Make the window narrower; the image shrinks with it.

A view of the climbing wall

More: W3Schools: Bootstrap 5 Images

Alert and badge

An alert is a coloured message. A badge is a small label, in our case the grade next to the route name.

<div class="alert alert-success">Your registration is saved.</div>
<p>Blue Overhang <span class="badge text-bg-warning">6a (VI+)</span></p>

This is what it looks like in the browser.

Your registration is saved.

Blue Overhang 6a (VI+)

More: W3Schools: Bootstrap 5 Alerts, W3Schools: Bootstrap 5 Badges

Buttons

A button always has the btn class and a variant. A link <a> can look like a button too.

<button type="button" class="btn btn-primary">Log an ascent</button>
<button type="button" class="btn btn-outline-primary">Show routes</button>
<button type="button" class="btn btn-danger btn-sm">Delete</button>
<a href="form.html" class="btn btn-success">Registration</a>

This is what it looks like in the browser.

Registration

More: W3Schools: Bootstrap 5 Buttons

Components that move

A drop-down menu or an accordion (collapsible paragraphs) work without you writing any JavaScript. They are controlled by data-bs-… attributes in the HTML. The data-bs-target attribute points to the id of the element that should unfold. They need the <script> from Example 1.

<div class="accordion" id="faq">
  <div class="accordion-item">
    <h2 class="accordion-header">
      <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#otazka1">
        What to bring
      </button>
    </h2>
    <div id="otazka1" class="accordion-collapse collapse show" data-bs-parent="#faq">
      <div class="accordion-body">Comfortable clothes and clean shoes. You can rent climbing shoes and a harness.</div>
    </div>
  </div>
  <div class="accordion-item">
    <h2 class="accordion-header">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#otazka2">
        How to read the grade
      </button>
    </h2>
    <div id="otazka2" class="accordion-collapse collapse" data-bs-parent="#faq">
      <div class="accordion-body">A number and a letter, for example 6a. The higher the number and letter, the harder the route.</div>
    </div>
  </div>
</div>

This is what it looks like in the browser. Click a question.

Comfortable clothes and clean shoes. You can rent climbing shoes and a harness.
A number and a letter, for example 6a. The higher the number and letter, the harder the route.

More: W3Schools: Bootstrap 5 Collapse

The form

Every field gets a class. The name, id and for attributes stay exactly as last week. Bootstrap changes only the look.

Element Class
<label> form-label
<input>, <textarea> form-control
<select> form-select
the wrapper of one radio or checkbox form-check
<input type="radio">, <input type="checkbox"> form-check-input
the <label> of a radio or checkbox form-check-label
the <legend> of a group fs-6 (normal font size)
the wrapper of one field with spacing below mb-3

The whole form is in Example 4.

More: W3Schools: Bootstrap 5 Forms

What leaves the form

In a few weeks PHP will process the form. PHP receives name=value pairs. So you must know what the value is for each kind of field.

Field What is sent
text, e-mail, number, date, textarea what the user typed
select the value of the selected option, not the text a person sees
radio the value of the one selected option in the group
a group of checkbox (name ends with []) the value of every ticked one; when none is ticked, nothing is sent
a single checkbox its value when it is ticked; otherwise nothing is sent

This gives the rules that apply to every form in this course:

  • Every field has a name. It is written in lowercase, without accents and without spaces; words are joined by an underscore: since.
  • Every option, every radio and every checkbox has a value. The value is short, without accents and without spaces.
  • The first option in a select has an empty value="". It lets you find out that the user selected nothing.
  • A group of checkboxes where several can be ticked has a name with square brackets: interest[]. PHP then receives all ticked values at once as an array.

More: W3Schools: HTML Form Attributes

Bootstrap and your own CSS

When two equally strong rules apply to the same element, the one that comes later wins. That is why style.css is attached after Bootstrap. Keep in style.css only what Bootstrap does not have: your colours, the .highlight class, :hover. Delete from style.css what Bootstrap handles itself (centring the content, the menu, the look of the form). In F12 you can see which rule lost: it is crossed out (Example 5).

Testing on a phone

Press F12. At the top left of the panel that opened there is a phone-and-tablet icon. Click it, or press Ctrl + Shift + M. The page is displayed in a narrow window. Drag the edge to change the width and see when the layout changes. The same icon closes the phone view; F12 closes the panel.

F12 open, the phone-and-tablet icon highlighted at the top left of the panel
The phone-and-tablet icon is at the top left of the F12 panel.

The most common errors and what they mean

What you see Cause Fix
the page looks unstyled a typo in the <link> to Bootstrap, or the <link> is missing compare with Example 1
the menu does not unfold on a phone the <script> before </body> is missing add it from Example 1
the menu does not unfold although the <script> is there data-bs-target does not point to the id of the menu data-bs-target="#menu" in the button, id="menu" in the menu
the columns are below each other even on a wide screen col is not directly inside row the order is container, row, col
the last column dropped to the next row the columns add up to more than 12 recount the numbers in the col-md-… classes
your colours disappeared style.css is attached before Bootstrap swap the order of the <link> tags
the content is hidden under the menu fixed-top without offsetting the content in style.css: body { padding-top: 70px; }
the page is tiny on a phone <meta name="viewport"> is missing add it from Example 1
a test says an option has no value the AI left an option without a value add a value to every option except the “– select –” one, which has value=""

UkážkyExamples

Ukážka 1: kostra stránky s Bootstrap

index.html
<!doctype html>
<html lang="sk">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Lezecká stena</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <main class="container">
    <h1>Lezecká stena</h1>
  </main>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

Čo robí ktorý riadok:

  • <meta name="viewport" …>: stránka sa na mobile zobrazí v šírke displeja.
  • prvý <link>: pripojí Bootstrap z CDN.
  • druhý <link>: pripojí tvoje CSS. Musí byť druhý, aby tvoje pravidlá vyhrali.
  • class="container": obsah je na stred a má obmedzenú šírku.
  • <script>: pridá správanie komponentov, napríklad rozbaľovanie menu.

Ukážka 2: menu ako navbar

index.html
<nav class="navbar navbar-expand-md bg-dark navbar-dark fixed-top">
  <div class="container">
    <a class="navbar-brand" href="index.html">Lezecká stena</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#menu">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="menu">
      <ul class="navbar-nav">
        <li class="nav-item"><a class="nav-link active" href="index.html">Domov</a></li>
        <li class="nav-item"><a class="nav-link" href="form.html">Registrácia</a></li>
      </ul>
    </div>
  </div>
</nav>
css/style.css
body { padding-top: 70px; }   /* aby pripnuté menu neprekrylo obsah */

Čo robí ktorý riadok:

  • navbar navbar-expand-md: menu, ktoré je od šírky md vyššie rozbalené.
  • bg-dark navbar-dark: tmavé pozadie a k nemu svetlý text.
  • fixed-top: menu je pripnuté na vrchu okna.
  • navbar-brand: názov webu vľavo.
  • navbar-toggler: button s tromi čiarkami. Vidno ho len na úzkej obrazovke.
  • data-bs-target="#menu": button rozbalí element, ktorý má id="menu".
  • collapse navbar-collapse: časť, ktorá sa na úzkej obrazovke schová.
  • nav-link active: link na stránku, na ktorej práve si. Na form.html je active pri link Registrácia.
Menu na širokom okne, položky sú vedľa seba
Menu na širokom okne: položky sú vedľa seba.
Menu na mobile, položky sú schované, vpravo je tlačidlo s tromi čiarkami
Menu na mobile: položky sú schované, vpravo je tlačidlo s tromi čiarkami.
Menu na mobile po kliknutí na tlačidlo, položky sú pod sebou
Menu na mobile po kliknutí na tlačidlo: položky sú pod sebou.

Ukážka 3: cesty ako card v mriežke (grid)

index.html
<div class="row g-3">
  <div class="col-md-6 col-lg-4">
    <div class="card h-100">
      <img src="img/zlta-hrana.jpg" class="card-img-top" alt="Cesta Žltá hrana">
      <div class="card-body">
        <h5 class="card-title">Žltá hrana <span class="badge text-bg-warning">5a (V)</span></h5>
        <p class="card-text">Línia 3, žlté chyty. Vhodná pre začiatočníkov.</p>
        <p class="card-text text-muted">Postavená 14. 9. 2026</p>
      </div>
    </div>
  </div>
  <div class="col-md-6 col-lg-4">
    <div class="card h-100">
      <img src="img/modry-previs.jpg" class="card-img-top" alt="Cesta Modrý previs">
      <div class="card-body">
        <h5 class="card-title">Modrý previs <span class="badge text-bg-warning">6a (VI+)</span></h5>
        <p class="card-text">Línia 7, modré chyty. Previs s dobrými chytmi.</p>
        <p class="card-text text-muted">Postavená 21. 9. 2026</p>
      </div>
    </div>
  </div>
  <div class="col-md-6 col-lg-4">
    <div class="card h-100">
      <img src="img/cervena-platna.jpg" class="card-img-top" alt="Cesta Červená platňa">
      <div class="card-body">
        <h5 class="card-title">Červená platňa <span class="badge text-bg-warning">6b (VII)</span></h5>
        <p class="card-text">Línia 9, červené chyty. Malé stupy, treba dobre stáť.</p>
        <p class="card-text text-muted">Postavená 5. 10. 2026</p>
      </div>
    </div>
  </div>
</div>

Čo robí ktorý riadok:

  • row g-3: row grid s medzerami medzi columns.
  • col-md-6 col-lg-4: na tablete dve card v row, na notebooku tri, na mobile jedna.
  • card h-100: card vysoká ako celý column. Card v row sú potom rovnako vysoké.
  • card-img-top: image na vrchu card, široký ako card.
  • card-body: vnútro card s odstupmi.
  • card-title, card-text: heading a text card.

Takto to vyzerá v prehliadači. Zužuj okno: tri card v row, potom dve, potom jedna.

Cesta Žltá hrana
Žltá hrana 5a (V)

Línia 3, žlté chyty. Vhodná pre začiatočníkov.

Postavená 14. 9. 2026

Cesta Modrý previs
Modrý previs 6a (VI+)

Línia 7, modré chyty. Previs s dobrými chytmi.

Postavená 21. 9. 2026

Cesta Červená platňa
Červená platňa 6b (VII)

Línia 9, červené chyty. Malé stupy, treba dobre stáť.

Postavená 5. 10. 2026

Karty ciest na mobile, sú pod sebou
Tie isté karty na mobile: sú pod sebou.

Ukážka 4: registrácia lezca

form.html
<form method="get" action="">

  <div class="mb-3">
    <label for="name" class="form-label">Meno a priezvisko</label>
    <input type="text" class="form-control" id="name" name="name" required>
  </div>

  <div class="mb-3">
    <label for="email" class="form-label">E-mail</label>
    <input type="email" class="form-control" id="email" name="email" required>
  </div>

  <div class="mb-3">
    <label for="since" class="form-label">Leziem od roku</label>
    <input type="number" class="form-control" id="since" name="since" min="1950" max="2026">
  </div>

  <div class="mb-3">
    <label for="date" class="form-label">Dátum prvej návštevy</label>
    <input type="date" class="form-control" id="date" name="date">
  </div>

  <div class="mb-3">
    <label for="grade" class="form-label">Najvyššia vylezená obťažnosť</label>
    <select class="form-select" id="grade" name="grade" required>
      <option value="">-- vyber --</option>
      <option value="5a">5a (V)</option>
      <option value="5c">5c (VI)</option>
      <option value="6a">6a (VI+)</option>
      <option value="6b">6b (VII)</option>
    </select>
  </div>

  <fieldset class="mb-3">
    <legend class="fs-6">Štýl lezenia</legend>
    <div class="form-check">
      <input class="form-check-input" type="radio" name="style" id="style_toprope" value="toprope" checked>
      <label class="form-check-label" for="style_toprope">s horným istením</label>
    </div>
    <div class="form-check">
      <input class="form-check-input" type="radio" name="style" id="style_lead" value="lead">
      <label class="form-check-label" for="style_lead">s dolným istením</label>
    </div>
    <div class="form-check">
      <input class="form-check-input" type="radio" name="style" id="style_boulder" value="boulder">
      <label class="form-check-label" for="style_boulder">bouldering</label>
    </div>
  </fieldset>

  <fieldset class="mb-3">
    <legend class="fs-6">Mám záujem o</legend>
    <div class="form-check">
      <input class="form-check-input" type="checkbox" name="interest[]" id="interest_course" value="course">
      <label class="form-check-label" for="interest_course">kurz pre začiatočníkov</label>
    </div>
    <div class="form-check">
      <input class="form-check-input" type="checkbox" name="interest[]" id="interest_rental" value="rental">
      <label class="form-check-label" for="interest_rental">požičanie výstroja</label>
    </div>
  </fieldset>

  <div class="form-check mb-3">
    <input class="form-check-input" type="checkbox" name="consent" id="consent" value="yes" required>
    <label class="form-check-label" for="consent">Súhlasím s prevádzkovým poriadkom</label>
  </div>

  <div class="mb-3">
    <label for="message" class="form-label">Správa</label>
    <textarea class="form-control" id="message" name="message" rows="3"></textarea>
  </div>

  <button type="submit" class="btn btn-primary">Registrovať</button>
</form>

Čo z tohto form odíde:

Field name Čo odíde
meno, e-mail, rok, dátum, správa name, email, since, date, message to, čo používateľ napísal
najvyššia obťažnosť grade 5a, 5c, 6a alebo 6b; nie text „6a (VI+)”
štýl lezenia style toprope, lead alebo boulder
mám záujem o interest[] course, rental, obe, alebo nič
súhlas consent ano

Takto to vyzerá v prehliadači. Vyplň form, stlač Registrovať a pozri si adresný riadok. Nájdi v ňom grade, style a interest.

Štýl lezenia
Mám záujem o

Po odoslaní vyzerá adresný riadok napríklad takto. Znaky %5B%5D sú zakódované hranaté zátvorky [].

form.html?name=Jana+Nováková&email=jana@example.com&since=2021&date=2026-10-13&grade=6a&style=lead&interest%5B%5D=course&interest%5B%5D=rental&consent=yes&message=

Ukážka 5: to isté vlastným CSS a classes Bootstrap

Vľavo je to, čo si minulý týždeň písal do style.css. Vpravo je class Bootstrap, ktorá robí to isté.

Vlastné CSS z týždňa 3 Class Bootstrap
max-width: 800px; margin: 0 auto; container
padding: 16px; p-3
margin-bottom: 24px; mb-4
text-align: center; text-center
max-width: 100%; na image img-fluid
position: fixed; top: 0; left: 0; right: 0; fixed-top
border: 1px solid …; border
Tá istá stránka dvakrát vedľa seba: vľavo s vlastným CSS, vpravo s Bootstrap
Tá istá stránka: vľavo s vlastným CSS (cv02), vpravo s Bootstrap (cv03).
F12, karta Elements, vpravo v časti Styles je jedno pravidlo prečiarknuté
F12, karta Elements, vpravo časť Styles: prečiarknuté pravidlo prehralo s pravidlom, ktoré je nad ním.

Ukážka 6: prompt pre AI na prerobenie webu na Bootstrap

Web neprerábaš ručne, zadáš to AI. Tento prompt sa od minulých líši: AI nedostane len zadanie, ale aj tvoje súbory.

Prerob môj web na Bootstrap 5.3 (z CDN jsdelivr). Posielam ti svoje súbory
index.html, form.html a css/style.css. Tému, texty a názvy súborov nemeň.

STRÁNKY
- Do oboch stránok pripoj Bootstrap CSS a až za ním môj css/style.css.
  Pred </body> pripoj bootstrap.bundle.min.js. Nechaj meta viewport.
- Menu prerob na navbar (navbar-expand-md, fixed-top), rovnaký na oboch
  stránkach, s class active pri link na aktuálnu stránku.
- Hlavný obsah daj do <main class="container">; v nav a vo footer daj
  <div class="container"> dovnútra. Obsah v main rozdeľ na <section> s id.
- Na index.html použi grid (row, col-md-6, col-lg-4) a aspoň tri karty (card).
- Pridaj table s classes table a table-striped v obale table-responsive.
- Image daj class img-fluid.

Form (form.html)
Form neskôr spracuje PHP, preto ho oprav presne podľa týchto pravidiel:
- <form method="get" action="">.
- Každé field má attribute name: malé písmená, bez diakritiky a bez medzier,
  slová spojené podčiarkovníkom (napr. since). Každé name je iné.
  Ak moje field name už má, nechaj ho.
- Každé field má id a vlastný <label for="..."> s tým istým id.
- select: prvá možnosť je <option value="">-- vyber --</option>.
  Každá ďalšia možnosť má attribute value s krátkou hodnotou bez diakritiky
  a bez medzier; text medzi tags je pre človeka.
- radio: všetky v skupine majú rovnaké name, každé má vlastné value a
  vlastné id, jedno má checked. Skupina je vo <fieldset> s <legend>.
- skupina checkboxov, z ktorých sa dá vybrať viac: name končí hranatými
  zátvorkami (napr. interest[]), každý má vlastné value a id.
- samostatný checkbox (súhlas): má value="yes".
- Povinné fields majú required. Číselné field má min a max.
- Button je <button type="submit">.
- Class Bootstrap: form-label, form-control, form-select, form-check,
  form-check-input, form-check-label, okolo každého field <div class="mb-3">,
  na <legend> class fs-6.

CSS
V css/style.css nechaj len to, čo Bootstrap nerieši (moje farby, class
.highlight, :hover) a pridaj odsadenie body zhora kvôli fixed-top.
Ostatné zmaž a na začiatok súboru napíš v komentári, čo si zmazal a prečo.
Žiadne inline štýly, žiadna tag <style>, žiadny vlastný JavaScript.

KOMENTÁRE
Ku každému bloku HTML napíš krátky slovenský komentár, ktoré class
Bootstrap používa a čo robia.

Na konci vypíš table všetkých fields form: name, typ field a aké
hodnoty môže poslať.

Tu sú moje súbory:
[VLOŽ obsah index.html, form.html a css/style.css]

Prečo je prompt napísaný práve takto:

  • posielaš svoje súbory: AI upravuje tvoj web, nevymýšľa nový,
  • zoznam, čo zmeniť: dostaneš presne tie časti Bootstrap, ktoré dnes preberáme,
  • name bez diakritiky a medzier: podľa name si PHP údaj vyzdvihne, musí sa dať napísať presne,
  • value pri každej možnosti: PHP dostane value, nie text, ktorý vidí človek. Text môžeš neskôr zmeniť a program funguje ďalej,
  • prázdna prvá možnosť v select: dá sa zistiť, že používateľ nič nevybral,
  • hranaté zátvorky pri skupine checkboxov: PHP dostane všetky zaškrtnuté hodnoty naraz,
  • komentár o zmazanom CSS: vieš vysvetliť, čo Bootstrap nahradil,
  • table fields na konci: form skontroluješ bez čítania celého kódu a máš podklad na obhajobu.

Keď výsledok nesedí, celý prompt nepíš znova. Napíš AI, čo presne treba opraviť, napríklad: „Druhá možnosť v select nemá value, doplň ho.”

Example 1: the skeleton of a page with Bootstrap

index.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Climbing wall</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <main class="container">
    <h1>Climbing wall</h1>
  </main>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

What each line does:

  • <meta name="viewport" …>: on a phone the page is displayed at the width of the display.
  • the first <link>: attaches Bootstrap from the CDN.
  • the second <link>: attaches your CSS. It must be second so that your rules win.
  • class="container": the content is centred and has a limited width.
  • <script>: adds the behaviour of components, for example unfolding the menu.

Example 2: the menu as a navbar

index.html
<nav class="navbar navbar-expand-md bg-dark navbar-dark fixed-top">
  <div class="container">
    <a class="navbar-brand" href="index.html">Climbing wall</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#menu">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="menu">
      <ul class="navbar-nav">
        <li class="nav-item"><a class="nav-link active" href="index.html">Home</a></li>
        <li class="nav-item"><a class="nav-link" href="form.html">Registration</a></li>
      </ul>
    </div>
  </div>
</nav>
css/style.css
body { padding-top: 70px; }   /* so that the pinned menu does not cover the content */

What each line does:

  • navbar navbar-expand-md: a menu that is unfolded from width md up.
  • bg-dark navbar-dark: a dark background with light text.
  • fixed-top: the menu is pinned to the top of the window.
  • navbar-brand: the name of the website on the left.
  • navbar-toggler: the button with three lines. It is visible only on a narrow screen.
  • data-bs-target="#menu": the button unfolds the element that has id="menu".
  • collapse navbar-collapse: the part that hides on a narrow screen.
  • nav-link active: the link to the page you are on. On form.html the active class is on the Registration link.
The menu in a wide window, the items are side by side
The menu in a wide window: the items are side by side.
The menu on a phone, the items are hidden, a button with three lines is on the right
The menu on a phone: the items are hidden, a button with three lines is on the right.
The menu on a phone after clicking the button, the items are below each other
The menu on a phone after clicking the button: the items are below each other.

Example 3: routes as cards in a grid

index.html
<div class="row g-3">
  <div class="col-md-6 col-lg-4">
    <div class="card h-100">
      <img src="img/zlta-hrana.jpg" class="card-img-top" alt="The Yellow Edge route">
      <div class="card-body">
        <h5 class="card-title">Yellow Edge <span class="badge text-bg-warning">5a (V)</span></h5>
        <p class="card-text">Line 3, yellow holds. Suitable for beginners.</p>
        <p class="card-text text-muted">Set on 14 Sep 2026</p>
      </div>
    </div>
  </div>
  <div class="col-md-6 col-lg-4">
    <div class="card h-100">
      <img src="img/modry-previs.jpg" class="card-img-top" alt="The Blue Overhang route">
      <div class="card-body">
        <h5 class="card-title">Blue Overhang <span class="badge text-bg-warning">6a (VI+)</span></h5>
        <p class="card-text">Line 7, blue holds. An overhang with good holds.</p>
        <p class="card-text text-muted">Set on 21 Sep 2026</p>
      </div>
    </div>
  </div>
  <div class="col-md-6 col-lg-4">
    <div class="card h-100">
      <img src="img/cervena-platna.jpg" class="card-img-top" alt="The Red Slab route">
      <div class="card-body">
        <h5 class="card-title">Red Slab <span class="badge text-bg-warning">6b (VII)</span></h5>
        <p class="card-text">Line 9, red holds. Small footholds, you need good footwork.</p>
        <p class="card-text text-muted">Set on 5 Oct 2026</p>
      </div>
    </div>
  </div>
</div>

What each line does:

  • row g-3: a grid row with gaps between the columns.
  • col-md-6 col-lg-4: two cards per row on a tablet, three on a laptop, one on a phone.
  • card h-100: a card as tall as the whole column. The cards in a row are then equally tall.
  • card-img-top: the image at the top of the card, as wide as the card.
  • card-body: the inside of the card, with spacing.
  • card-title, card-text: the heading and the text of the card.

This is what it looks like in the browser. Make the window narrower: three cards per row, then two, then one.

The Yellow Edge route
Yellow Edge 5a (V)

Line 3, yellow holds. Suitable for beginners.

Set on 14 Sep 2026

The Blue Overhang route
Blue Overhang 6a (VI+)

Line 7, blue holds. An overhang with good holds.

Set on 21 Sep 2026

The Red Slab route
Red Slab 6b (VII)

Line 9, red holds. Small footholds, you need good footwork.

Set on 5 Oct 2026

The route cards on a phone, below each other
The same cards on a phone: they are below each other.

Example 4: climber registration

form.html
<form method="get" action="">

  <div class="mb-3">
    <label for="name" class="form-label">Full name</label>
    <input type="text" class="form-control" id="name" name="name" required>
  </div>

  <div class="mb-3">
    <label for="email" class="form-label">E-mail</label>
    <input type="email" class="form-control" id="email" name="email" required>
  </div>

  <div class="mb-3">
    <label for="since" class="form-label">Climbing since (year)</label>
    <input type="number" class="form-control" id="since" name="since" min="1950" max="2026">
  </div>

  <div class="mb-3">
    <label for="date" class="form-label">Date of first visit</label>
    <input type="date" class="form-control" id="date" name="date">
  </div>

  <div class="mb-3">
    <label for="grade" class="form-label">Hardest grade climbed</label>
    <select class="form-select" id="grade" name="grade" required>
      <option value="">-- select --</option>
      <option value="5a">5a (V)</option>
      <option value="5c">5c (VI)</option>
      <option value="6a">6a (VI+)</option>
      <option value="6b">6b (VII)</option>
    </select>
  </div>

  <fieldset class="mb-3">
    <legend class="fs-6">Climbing style</legend>
    <div class="form-check">
      <input class="form-check-input" type="radio" name="style" id="style_toprope" value="toprope" checked>
      <label class="form-check-label" for="style_toprope">top rope</label>
    </div>
    <div class="form-check">
      <input class="form-check-input" type="radio" name="style" id="style_lead" value="lead">
      <label class="form-check-label" for="style_lead">lead</label>
    </div>
    <div class="form-check">
      <input class="form-check-input" type="radio" name="style" id="style_boulder" value="boulder">
      <label class="form-check-label" for="style_boulder">bouldering</label>
    </div>
  </fieldset>

  <fieldset class="mb-3">
    <legend class="fs-6">I am interested in</legend>
    <div class="form-check">
      <input class="form-check-input" type="checkbox" name="interest[]" id="interest_course" value="course">
      <label class="form-check-label" for="interest_course">a beginners' course</label>
    </div>
    <div class="form-check">
      <input class="form-check-input" type="checkbox" name="interest[]" id="interest_rental" value="rental">
      <label class="form-check-label" for="interest_rental">gear rental</label>
    </div>
  </fieldset>

  <div class="form-check mb-3">
    <input class="form-check-input" type="checkbox" name="consent" id="consent" value="yes" required>
    <label class="form-check-label" for="consent">I agree with the wall rules</label>
  </div>

  <div class="mb-3">
    <label for="message" class="form-label">Message</label>
    <textarea class="form-control" id="message" name="message" rows="3"></textarea>
  </div>

  <button type="submit" class="btn btn-primary">Register</button>
</form>

What this form sends:

Field name What is sent
name, e-mail, year, date, message name, email, since, date, message what the user typed
hardest grade grade 5a, 5c, 6a or 6b; not the text “6a (VI+)”
climbing style style toprope, lead or boulder
I am interested in interest[] course, rental, both, or nothing
agreement consent ano

This is what it looks like in the browser. Fill in the form, press Register and look at the address bar. Find grade, style and interest in it.

Climbing style
I am interested in

After submitting, the address bar looks for example like this. The characters %5B%5D are the encoded square brackets [].

form.html?name=Jana+Novakova&email=jana@example.com&since=2021&date=2026-10-13&grade=6a&style=lead&interest%5B%5D=course&interest%5B%5D=rental&consent=yes&message=

Example 5: the same with your own CSS and with Bootstrap classes

On the left is what you wrote into style.css last week. On the right is the Bootstrap class that does the same.

Your own CSS from week 3 Bootstrap class
max-width: 800px; margin: 0 auto; container
padding: 16px; p-3
margin-bottom: 24px; mb-4
text-align: center; text-center
max-width: 100%; on an image img-fluid
position: fixed; top: 0; left: 0; right: 0; fixed-top
border: 1px solid …; border
The same page twice side by side: with its own CSS on the left, with Bootstrap on the right
The same page: with its own CSS on the left (cv02), with Bootstrap on the right (cv03).
F12, the Elements tab, one rule is crossed out in the Styles part on the right
F12, the Elements tab, the Styles part on the right: the crossed-out rule lost to the rule above it.

Example 6: an AI prompt for rebuilding the website with Bootstrap

You do not rebuild the website by hand, you brief an AI. This prompt differs from the earlier ones: the AI gets not only the brief but also your files.

Rebuild my website with Bootstrap 5.3 (from the jsdelivr CDN). I am sending you
my files index.html, form.html and css/style.css. Do not change the topic, the
texts or the file names.

PAGES
- Attach the Bootstrap CSS to both pages and only after it my css/style.css.
  Attach bootstrap.bundle.min.js before </body>. Keep the meta viewport.
- Turn the menu into a navbar (navbar-expand-md, fixed-top), the same on both
  pages, with the active class on the link to the current page.
- Put the main content into <main class="container">; in nav and footer put
  <div class="container"> inside. Divide the content in main into <section>s with ids.
- On index.html use the grid (row, col-md-6, col-lg-4) and at least three
  cards (card).
- Add a table with the classes table and table-striped inside a
  table-responsive wrapper.
- Give the image the class img-fluid.

FORM (form.html)
The form will later be processed by PHP, so fix it exactly by these rules:
- <form method="get" action="">.
- Every field has a name attribute: lowercase, no accents, no spaces, words
  joined by an underscore (e.g. since). Every name is different.
  If my field already has a name, keep it.
- Every field has an id and its own <label for="..."> with the same id.
- select: the first option is <option value="">-- select --</option>.
  Every other option has a value attribute with a short value without accents
  and spaces; the text between the tags is for people.
- radio: all in a group share one name, each has its own value and its own id,
  one has checked. The group is in a <fieldset> with a <legend>.
- a group of checkboxes where several can be ticked: the name ends with square
  brackets (e.g. interest[]), each has its own value and id.
- a single checkbox (agreement): has value="yes".
- Required fields have required. A number field has min and max.
- The button is <button type="submit">.
- Bootstrap classes: form-label, form-control, form-select, form-check,
  form-check-input, form-check-label, <div class="mb-3"> around every field,
  and the class fs-6 on <legend>.

CSS
Keep in css/style.css only what Bootstrap does not handle (my colours, the
.highlight class, :hover) and add top padding to body because of fixed-top.
Delete the rest and write a comment at the top of the file saying what you
deleted and why. No inline styles, no <style> tag, no custom JavaScript.

COMMENTS
Add a short comment to every HTML block saying which Bootstrap classes it uses
and what they do.

At the end print a table of all form fields: name, field type and which values
it can send.

Here are my files:
[PASTE the content of index.html, form.html and css/style.css]

Why the prompt is written this way:

  • you send your files: the AI edits your website, it does not invent a new one,
  • the list of what to change: you get exactly the parts of Bootstrap we cover today,
  • name without accents and spaces: PHP picks the value up by its name, so it must be easy to type exactly,
  • a value on every option: PHP receives the value, not the text a person sees. You can change the text later and the program keeps working,
  • the empty first option in select: you can find out that the user selected nothing,
  • square brackets on a checkbox group: PHP receives all ticked values at once,
  • the comment about deleted CSS: you can explain what Bootstrap replaced,
  • the table of fields at the end: you check the form without reading all the code and you have material for the defence.

When the result is not right, do not rewrite the whole prompt. Tell the AI exactly what to fix, for example: “The second option in the select has no value, add it.”

Úlohy na cvičenieLab tasks

Úlohy dostaneš aj ako zadanie cv03 v Classroom 50, sú v súbore README.md v tvojom repository.

Link na zadanie cv03: prijať zadanie
(platí pre skupiny B. Stehlíkovej; ostatné skupiny dostanú link od svojho cvičiaceho)

Úloha 4.1: Príprava Kubeflow. Priprav si Kubeflow podľa návodu 04 Odovzdávanie, časť 1: v Explorer je hore WEB, dole na stavovej lište je Go Live. Ak tam nie je, rozšírenia vráti tento príkaz v termináli:

code-server --install-extension Natizyskunk.sftp --install-extension yandeu.five-server --install-extension bmewburn.vscode-intelephense-client --install-extension mblode.twig-language-2

Potom F1, Developer: Reload Window. Nastavenie pripojenia na sigma zostáva.

Úloha 4.2: Zadanie a kópia minulého týždňa. Prijmi zadanie cv03 v Classroom 50 (link je vyššie) a repository naklonuj do ~/web/ti/cv03 podľa návodu 04, časti 2 a 3. Potom do neho prekopíruj svoj web z minulého týždňa:

cd ~/web/ti
rsync -a --exclude .git --exclude .github --exclude README.md cv02/ cv03/
ls cv03

Vo výpise musí byť index.html, form.html, css, img a README.md. Pokračuješ vo svojej téme z cv02. Priečinok cv02 zostáva tak, ako si ho odovzdal.

Úloha 4.3: Bootstrap cez AI. Prompt z Ukážky 6 vlož do AI a na koniec vlož obsah svojich troch súborov z cv03. Výsledok ulož do tých istých súborov v cv03. Stránky si pozri cez Five Server (pravý klik do súboru, Open with Five Server). Prečítaj komentáre v kóde: každú class musíš vedieť prečítať. Ak výsledok nie je dobrý, spusti znova príkaz rsync z úlohy 4.2 a začni od čistej kópie.

Úloha 4.4: Grid. Zmeň rozloženie cards na notebooku z troch v riadku na dve. Pridaj jednu novú card.

Úloha 4.5: Navbar. Pridaj do menu jednu položku, napríklad link na section s id na stránke index.html. Over, že class active je na každej stránke pri správnom link.

Úloha 4.6: Form. Skontroluj table fields, ktorú AI vypísala: každé field má name, každá možnosť má value. Pridaj jedno nové field s classes Bootstrap, s label, name a id. Odošli form a v adresnom riadku nájdi hodnoty value.

Úloha 4.7: Odstupy a farby. Jednej časti stránky zmeň pozadie a odstupy iba classes Bootstrap. Do style.css pri tejto úlohe nezasahuj.

Úloha 4.8: Vlastné CSS. V style.css nastav menu svoju farbu. V F12 nájdi jedno prečiarknuté pravidlo a zisti, ktoré pravidlo ho prebilo.

Úloha 4.9: Mobil. Cez F12 a ikonu mobilu skontroluj obe stránky: menu sa rozbalí, card idú pod seba, image a table nepretečú mimo stránku.

Úloha 4.10: Commit a push. Commit a push podľa návodu 04 Odovzdávanie, časť 5. Urob commit po každej hotovej úlohe, nie jeden na konci. Výsledok automatických testov si pozri podľa časti 6. Pri červenom ✕ si prečítaj názov testu s FAIL, oprav to a pushni znova.

Úloha 4.11: Upload Folder a kontrola na sigma. Podľa návodu 04, časť 7: klikni pravým na priečinok cv03 a v menu úplne dole zvoľ Upload Folder. Over v prehliadači https://sigma.tuke.sk/student/meno.priezvisko/ti/cv03/: obe stránky aj image.

Hodnotenie: 1 bod. V repository cv03 na GitHub aj na sigma je tvoj web z cv02 prerobený na Bootstrap a úlohy sú splnené. Commit a push najneskôr do nasledujúceho cvičenia.

You also get the tasks as the assignment cv03 in Classroom 50, in the README.md file in your repository.

Link to the assignment cv03: accept the assignment
(valid for B. Stehlíková’s groups; other groups get the link from their own teacher)

Task 4.1: Getting Kubeflow ready. Get Kubeflow ready following guide 04 Submitting, part 1: Explorer shows WEB at the top, the status bar at the bottom shows Go Live. If it does not, this terminal command brings the extensions back:

code-server --install-extension Natizyskunk.sftp --install-extension yandeu.five-server --install-extension bmewburn.vscode-intelephense-client --install-extension mblode.twig-language-2

Then F1, Developer: Reload Window. The sigma connection settings stay.

Task 4.2: The assignment and a copy of last week. Accept the assignment cv03 in Classroom 50 (the link is above) and clone the repository into ~/web/ti/cv03 following guide 04, parts 2 and 3. Then copy your website from last week into it:

cd ~/web/ti
rsync -a --exclude .git --exclude .github --exclude README.md cv02/ cv03/
ls cv03

The listing must contain index.html, form.html, css, img and README.md. You continue with your own topic from cv02. The cv02 folder stays as you submitted it.

Task 4.3: Bootstrap with AI. Paste the prompt from Example 6 into an AI and paste the content of your three files from cv03 at the end. Save the result into the same files in cv03. View the pages with Five Server (right click in the file, Open with Five Server). Read the comments in the code: you must be able to read every class. If the result is not good, run the rsync command from task 4.2 again and start from a clean copy.

Task 4.4: The grid. Change the card layout on a laptop from three per row to two. Add one new card.

Task 4.5: Navbar. Add one item to the menu, for example a link to a section with an id on the index.html page. Check that the active class is on the right link on each page.

Task 4.6: The form. Check the table of fields the AI printed: every field has a name, every option has a value. Add one new field with Bootstrap classes, a label, a name and an id. Submit the form and find the value values in the address bar.

Task 4.7: Spacing and colours. Change the background and the spacing of one part of the page with Bootstrap classes only. Do not touch style.css in this task.

Task 4.8: Your own CSS. Set your own colour for the menu in style.css. In F12 find one crossed-out rule and find out which rule overrode it.

Task 4.9: Phone. With F12 and the phone icon check both pages: the menu unfolds, the cards go below each other, the image and the table do not overflow the page.

Task 4.10: Commit and push. Commit and push following guide 04 Submitting, part 5. Make a commit after every finished task, not one at the end. Look at the result of the automatic tests following part 6. With a red ✕ read the name of the test marked FAIL, fix it and push again.

Task 4.11: Upload Folder and the check on sigma. Following guide 04, part 7: right-click the cv03 folder and choose Upload Folder at the very bottom of the menu. Check in the browser https://sigma.tuke.sk/student/name.surname/ti/cv03/: both pages and the image.

Grading: 1 point. The repository cv03 on GitHub and on sigma contains your website from cv02 rebuilt with Bootstrap, and the tasks are done. Commit and push by the next lab at the latest.

Obhajoba a live codingDefence and live coding

Pri obhajobe budú použité iba otázky a úlohy z týchto zoznamov. Live coding robíš v kópii, odovzdaný stav v cv03 sa nezmení. Kópiu si priprav pred obhajobou:

cd ~/web/ti
mkdir -p obhajoba1
rsync -a --exclude .git cv03/ obhajoba1/cv03/

Potom klikni pravým na priečinok obhajoba1 a v menu úplne dole zvoľ Upload Folder. Kópia je na https://sigma.tuke.sk/student/meno.priezvisko/ti/obhajoba1/cv03/.

Vysvetli (code walkthrough)

  1. Čo robí <link> na Bootstrap a odkiaľ sa súbor berie.
  2. Prečo je style.css pripojený až za Bootstrap.
  3. Načo je <script> pred </body>.
  4. Načo je <meta name="viewport">.
  5. Čo robí container.
  6. Čo je row a prečo musí byť okolo columns.
  7. Prečítaj col-md-4: čo znamená každá časť.
  8. Prečo má riadok 12 dielov a koľko columns col-md-4 sa doň zmestí.
  9. Čo sa stane s tvojimi columns na mobile a prečo.
  10. Čo robí navbar-expand-md.
  11. Ako button s tromi čiarkami vie, ktoré menu má rozbaliť.
  12. Čo robí class active a prečo je na každej stránke pri inom link.
  13. Z akých častí sa skladá tvoja card.
  14. Čo robí form-control a čo form-select.
  15. Prečítaj mb-3 a px-4.
  16. Čo robí img-fluid.
  17. Čo robí table-responsive.
  18. Čo odíde z tvojho select, keď používateľ vyberie druhú možnosť.
  19. Čo odíde zo skupiny checkboxov, keď sú zaškrtnuté dva, a čo, keď nie je zaškrtnutý žiadny.
  20. Čo zostalo v tvojom style.css a prečo.
  21. Prečo je container v nav vnútri a main je container sám.
  22. Z akých častí sa skladá tvoja section a koľko riadkov má.

Uprav (live coding)

  1. Zmeň tri columns v row na dva.
  2. Pridaj jednu card.
  3. Zmeň farbu button na zelenú.
  4. Vycentruj heading class.
  5. Zväčši odstup pod jednou časťou stránky.
  6. Pridaj do form field s classes Bootstrap, label, name a id.
  7. Pridaj do select jednu možnosť s value.
  8. Zmeň breakpoint z md na lg a ukáž rozdiel v zobrazení mobilu.
  9. Pridaj položku do menu.
  10. Pridaj nad form alert.
  11. Skry jeden element na mobile.
  12. Pridaj card footer s dátumom.
  13. Pridaj do section druhý riadok s textom.

Zdôvodni (design decisions)

  1. Prečo použiť framework a nepísať všetko vlastným CSS.
  2. Čo si nechal vo vlastnom CSS a prečo práve to.
  3. Prečo sa Bootstrap pripája z CDN.
  4. Prečo si zvolil práve tento počet columns.
  5. Prečo má každá možnosť vo form attribute value.
  6. Prečo stránka používa main, section a footer, a nie iba div.

Definition of Done

  • Repository cv03 je na GitHub a posledný commit má zelenú ✓.
  • Web je na sigma: obe stránky aj image.
  • Na mobile sa menu rozbalí, card idú pod seba, image a table nepretečú.
  • V HTML nie sú inline štýly ani tag <style>.
  • Každé field form má name, každá možnosť má value.
  • Každú class vo svojom kóde vieš prečítať.

Only the questions and tasks from these lists are used at the defence. You do the live coding in a copy; the submitted state in cv03 does not change. Prepare the copy before the defence:

cd ~/web/ti
mkdir -p obhajoba1
rsync -a --exclude .git cv03/ obhajoba1/cv03/

Then right-click the obhajoba1 folder and choose Upload Folder at the very bottom of the menu. The copy is at https://sigma.tuke.sk/student/name.surname/ti/obhajoba1/cv03/.

Explain (code walkthrough)

  1. What the <link> to Bootstrap does and where the file comes from.
  2. Why style.css is attached after Bootstrap.
  3. What the <script> before </body> is for.
  4. What <meta name="viewport"> is for.
  5. What container does.
  6. What row is and why it must be around the columns.
  7. Read col-md-4: what each part means.
  8. Why a row has 12 parts and how many col-md-4 columns fit into it.
  9. What happens to your columns on a phone and why.
  10. What navbar-expand-md does.
  11. How the button with three lines knows which menu to unfold.
  12. What the active class does and why it is on a different link on each page.
  13. Which parts your card consists of.
  14. What form-control does and what form-select does.
  15. Read mb-3 and px-4.
  16. What img-fluid does.
  17. What table-responsive does.
  18. What your select sends when the user selects the second option.
  19. What a checkbox group sends when two are ticked, and what when none is ticked.
  20. What stayed in your style.css and why.
  21. Why the container is inside nav while main is the container itself.
  22. Which parts your section consists of and how many rows it has.

Modify (live coding)

  1. Change three columns per row to two.
  2. Add one card.
  3. Change the colour of a button to green.
  4. Centre a heading with a class.
  5. Increase the spacing below one part of the page.
  6. Add a field to the form with Bootstrap classes, a label, a name and an id.
  7. Add one option with a value to the select.
  8. Change the breakpoint from md to lg and show the difference in the phone view.
  9. Add an item to the menu.
  10. Add an alert above the form.
  11. Hide one element on a phone.
  12. Add a footer with a date to a card.
  13. Add a second row with text to a section.

Justify (design decisions)

  1. Why use a framework instead of writing everything in your own CSS.
  2. What you kept in your own CSS and why exactly that.
  3. Why Bootstrap is attached from a CDN.
  4. Why you chose exactly this number of columns.
  5. Why every option in the form has a value attribute.
  6. Why the page uses main, section and footer, and not just div.

Definition of Done

  • The repository cv03 is on GitHub and the last commit has a green ✓.
  • The website is on sigma: both pages and the image.
  • On a phone the menu unfolds, the cards go below each other, the image and the table do not overflow.
  • There are no inline styles and no <style> tag in the HTML.
  • Every form field has a name, every option has a value.
  • You can read every class in your code.