SlideShare une entreprise Scribd logo
1  sur  38
Télécharger pour lire hors ligne
LAYOUT MED CSS
Dagens föreläsning Dagens agenda
• Snabb repetition av HTML & CSS
• Element för positionering & layout
• Positionering av element
• Statisk
• Relativ
• Absolut
• Fixederad
• Layout med CSS
• Exempel, exempel & exempel
Repetition: CSS
• Att formge en webbplats
• Olika klädsel till samma innehåll
• Hur hittar man det man vill formge?
Boxmodellen för HTML-element
Exempel på boxmodellen
Vad gör en layout bra?
Att visa upp
HTML-element
Tre olika metoder för att visa upp element
Float
Flexbox
Grid
MAN KAN I PRINCIP BYGGA
ALLT MED ALLA TEKNIKERNA
Men det är en dålig idé…
ATT VÄLJA HUR ELEMENT SKA VISAS UPP
display: float
• Fungerar bäst när man vill positionera individuellt element i förhållande till andra
element. Exempel:
• En bild ska ligga till höger/vänster om texten
• En informationsruta ska ligga till höger/vänster om annat innehåll
display: flex
• Fungerar bäst när man vill positionera flera element i förhållande till varandra,
exempelvis:
• Flera bilder efter varandra
• Element ska ha olika storlekar beroende på tillgång av yta
display: grid
• Fungerar bäst när man vill positionera element som ett rutnät, exempelvis:
• Bygga layouter med kolumner som har ”fasta” propotioner
• Element ska ha olika storlekar beroende på tillgång av yta
Idag tittar vi på: float
OLIKA SÄTT ATT
POSITIONERA ELEMENT
relativ, statisk, absolut, fixerad
CSS - position
BOXMODELLEN
Egenskapen: box-sizing
DEMO - POSITIONERING
Med float
https://de
veloper.m
ozilla.org/
en-
US/docs/
Web/HTM
L/Element
Hur skapar man en layout?
Vi behöver alltså
• Sidhuvud <header>
• Navigation <nav>
• Innehåll <main>
• Sidfot <footer>
Kan vara bra att ha…
• En box (<div>) som omsluter hela sidan.
DEMO LAYOUT
HT19 - DA156A - Layout med CSS

Contenu connexe

Tendances

HT17 - DA156A - Introduktion till CSS
HT17 - DA156A - Introduktion till CSSHT17 - DA156A - Introduktion till CSS
HT17 - DA156A - Introduktion till CSSAnton Tibblin
 
HT17 - DA156A - Ramverk och bibliotek
HT17 - DA156A - Ramverk och bibliotekHT17 - DA156A - Ramverk och bibliotek
HT17 - DA156A - Ramverk och bibliotekAnton Tibblin
 
jQuery & HTML5 Cache
jQuery & HTML5 CachejQuery & HTML5 Cache
jQuery & HTML5 CacheAnton Tibblin
 
HT17 - DA156A - Kursintroduktion
HT17 - DA156A - KursintroduktionHT17 - DA156A - Kursintroduktion
HT17 - DA156A - KursintroduktionAnton Tibblin
 
HT17 - DA156A - Responsiv webbutveckling
HT17 - DA156A - Responsiv webbutvecklingHT17 - DA156A - Responsiv webbutveckling
HT17 - DA156A - Responsiv webbutvecklingAnton Tibblin
 
VT17 - DA355A - Introduktion HTML
VT17 - DA355A - Introduktion HTMLVT17 - DA355A - Introduktion HTML
VT17 - DA355A - Introduktion HTMLAnton Tibblin
 
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)Anton Tibblin
 
HT18 - DA156A - Layout med CSS (2)
HT18 - DA156A - Layout med CSS (2)HT18 - DA156A - Layout med CSS (2)
HT18 - DA156A - Layout med CSS (2)Anton Tibblin
 
VT2018 - DA355A - LocalStorage & Bootstrap
VT2018 - DA355A - LocalStorage & BootstrapVT2018 - DA355A - LocalStorage & Bootstrap
VT2018 - DA355A - LocalStorage & BootstrapAnton Tibblin
 
VT17 - DA355A - Introduktion till CSS
VT17 - DA355A - Introduktion till CSSVT17 - DA355A - Introduktion till CSS
VT17 - DA355A - Introduktion till CSSAnton Tibblin
 
Webbapplikationer - HTML
Webbapplikationer - HTMLWebbapplikationer - HTML
Webbapplikationer - HTMLAnton Tibblin
 
HT17 - DA156A - JavaScript i webbutveckling
HT17 - DA156A - JavaScript i webbutvecklingHT17 - DA156A - JavaScript i webbutveckling
HT17 - DA156A - JavaScript i webbutvecklingAnton Tibblin
 
HT19 - DA354A - Webbprogrammering med bottle
HT19 - DA354A - Webbprogrammering med bottleHT19 - DA354A - Webbprogrammering med bottle
HT19 - DA354A - Webbprogrammering med bottleAnton Tibblin
 
HT20 - DA106A - Kursintroduktion
HT20 - DA106A - KursintroduktionHT20 - DA106A - Kursintroduktion
HT20 - DA106A - KursintroduktionAnton Tibblin
 
HT18 - DA354A - Bottle web app
HT18 - DA354A - Bottle web appHT18 - DA354A - Bottle web app
HT18 - DA354A - Bottle web appAnton Tibblin
 

Tendances (20)

HT17 - DA156A - Introduktion till CSS
HT17 - DA156A - Introduktion till CSSHT17 - DA156A - Introduktion till CSS
HT17 - DA156A - Introduktion till CSS
 
HT17 - DA156A - Ramverk och bibliotek
HT17 - DA156A - Ramverk och bibliotekHT17 - DA156A - Ramverk och bibliotek
HT17 - DA156A - Ramverk och bibliotek
 
Html 3 ht14
Html 3 ht14Html 3 ht14
Html 3 ht14
 
jQuery & HTML5 Cache
jQuery & HTML5 CachejQuery & HTML5 Cache
jQuery & HTML5 Cache
 
HT17 - DA156A - Kursintroduktion
HT17 - DA156A - KursintroduktionHT17 - DA156A - Kursintroduktion
HT17 - DA156A - Kursintroduktion
 
JavaScript - Intro
JavaScript - IntroJavaScript - Intro
JavaScript - Intro
 
HT17 - DA156A - Responsiv webbutveckling
HT17 - DA156A - Responsiv webbutvecklingHT17 - DA156A - Responsiv webbutveckling
HT17 - DA156A - Responsiv webbutveckling
 
VT17 - DA355A - Introduktion HTML
VT17 - DA355A - Introduktion HTMLVT17 - DA355A - Introduktion HTML
VT17 - DA355A - Introduktion HTML
 
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)
 
HT18 - DA156A - Layout med CSS (2)
HT18 - DA156A - Layout med CSS (2)HT18 - DA156A - Layout med CSS (2)
HT18 - DA156A - Layout med CSS (2)
 
Ajax - jQuery
Ajax - jQueryAjax - jQuery
Ajax - jQuery
 
VT2018 - DA355A - LocalStorage & Bootstrap
VT2018 - DA355A - LocalStorage & BootstrapVT2018 - DA355A - LocalStorage & Bootstrap
VT2018 - DA355A - LocalStorage & Bootstrap
 
VT17 - DA355A - Introduktion till CSS
VT17 - DA355A - Introduktion till CSSVT17 - DA355A - Introduktion till CSS
VT17 - DA355A - Introduktion till CSS
 
Webbapplikationer - HTML
Webbapplikationer - HTMLWebbapplikationer - HTML
Webbapplikationer - HTML
 
HT17 - DA156A - JavaScript i webbutveckling
HT17 - DA156A - JavaScript i webbutvecklingHT17 - DA156A - JavaScript i webbutveckling
HT17 - DA156A - JavaScript i webbutveckling
 
HT19 - DA354A - Webbprogrammering med bottle
HT19 - DA354A - Webbprogrammering med bottleHT19 - DA354A - Webbprogrammering med bottle
HT19 - DA354A - Webbprogrammering med bottle
 
jQuery and Ajax
jQuery and AjaxjQuery and Ajax
jQuery and Ajax
 
HT20 - DA106A - Kursintroduktion
HT20 - DA106A - KursintroduktionHT20 - DA106A - Kursintroduktion
HT20 - DA106A - Kursintroduktion
 
LocalStorage
LocalStorageLocalStorage
LocalStorage
 
HT18 - DA354A - Bottle web app
HT18 - DA354A - Bottle web appHT18 - DA354A - Bottle web app
HT18 - DA354A - Bottle web app
 

Similaire à HT19 - DA156A - Layout med CSS

HT23 - DA106A - Layout med CSS (1)
HT23 - DA106A - Layout med CSS (1)HT23 - DA106A - Layout med CSS (1)
HT23 - DA106A - Layout med CSS (1)Anton Tibblin
 
HT16 - DA156A - CSS, layout
HT16 - DA156A - CSS, layoutHT16 - DA156A - CSS, layout
HT16 - DA156A - CSS, layoutAnton Tibblin
 
VT16 - DA355A - Layout med CSS
VT16 - DA355A - Layout med CSSVT16 - DA355A - Layout med CSS
VT16 - DA355A - Layout med CSSAnton Tibblin
 
HT18 - DA156A - Layout med CSS
HT18 - DA156A - Layout med CSSHT18 - DA156A - Layout med CSS
HT18 - DA156A - Layout med CSSAnton Tibblin
 
HT18 - DA156A - Extra
HT18 - DA156A - ExtraHT18 - DA156A - Extra
HT18 - DA156A - ExtraAnton Tibblin
 
HT16 - DA156A - Introduktion till CSS
HT16 - DA156A - Introduktion till CSSHT16 - DA156A - Introduktion till CSS
HT16 - DA156A - Introduktion till CSSAnton Tibblin
 
Vi skapar en webbsida
Vi skapar en webbsidaVi skapar en webbsida
Vi skapar en webbsidaJonas_Isegrim
 
VT18 - DA355A - Introduktion till CSS
VT18 - DA355A - Introduktion till CSSVT18 - DA355A - Introduktion till CSS
VT18 - DA355A - Introduktion till CSSAnton Tibblin
 

Similaire à HT19 - DA156A - Layout med CSS (8)

HT23 - DA106A - Layout med CSS (1)
HT23 - DA106A - Layout med CSS (1)HT23 - DA106A - Layout med CSS (1)
HT23 - DA106A - Layout med CSS (1)
 
HT16 - DA156A - CSS, layout
HT16 - DA156A - CSS, layoutHT16 - DA156A - CSS, layout
HT16 - DA156A - CSS, layout
 
VT16 - DA355A - Layout med CSS
VT16 - DA355A - Layout med CSSVT16 - DA355A - Layout med CSS
VT16 - DA355A - Layout med CSS
 
HT18 - DA156A - Layout med CSS
HT18 - DA156A - Layout med CSSHT18 - DA156A - Layout med CSS
HT18 - DA156A - Layout med CSS
 
HT18 - DA156A - Extra
HT18 - DA156A - ExtraHT18 - DA156A - Extra
HT18 - DA156A - Extra
 
HT16 - DA156A - Introduktion till CSS
HT16 - DA156A - Introduktion till CSSHT16 - DA156A - Introduktion till CSS
HT16 - DA156A - Introduktion till CSS
 
Vi skapar en webbsida
Vi skapar en webbsidaVi skapar en webbsida
Vi skapar en webbsida
 
VT18 - DA355A - Introduktion till CSS
VT18 - DA355A - Introduktion till CSSVT18 - DA355A - Introduktion till CSS
VT18 - DA355A - Introduktion till CSS
 

Plus de Anton Tibblin

2024 - Localstorage & cookies Geolocation Mediahantering.pdf
2024 - Localstorage & cookies Geolocation Mediahantering.pdf2024 - Localstorage & cookies Geolocation Mediahantering.pdf
2024 - Localstorage & cookies Geolocation Mediahantering.pdfAnton Tibblin
 
VT24 - jQuery & Ajax - Flerplattformsapplikationer med webbtekniker
VT24 - jQuery & Ajax - Flerplattformsapplikationer med webbteknikerVT24 - jQuery & Ajax - Flerplattformsapplikationer med webbtekniker
VT24 - jQuery & Ajax - Flerplattformsapplikationer med webbteknikerAnton Tibblin
 
VT24 - Responsiv design & Ramverk inom webbutveckling
VT24 - Responsiv design & Ramverk inom webbutvecklingVT24 - Responsiv design & Ramverk inom webbutveckling
VT24 - Responsiv design & Ramverk inom webbutvecklingAnton Tibblin
 
DA395A - VT24 - JavaScript & Document object model
DA395A - VT24 - JavaScript & Document object modelDA395A - VT24 - JavaScript & Document object model
DA395A - VT24 - JavaScript & Document object modelAnton Tibblin
 
VT24 - DA395A - Kursintroduktion: Flerplattformsapplikationer med webbtekniker
VT24 - DA395A - Kursintroduktion: Flerplattformsapplikationer med webbteknikerVT24 - DA395A - Kursintroduktion: Flerplattformsapplikationer med webbtekniker
VT24 - DA395A - Kursintroduktion: Flerplattformsapplikationer med webbteknikerAnton Tibblin
 
HT23 - DA354A - Webbprogrammering med Python
HT23 - DA354A - Webbprogrammering med PythonHT23 - DA354A - Webbprogrammering med Python
HT23 - DA354A - Webbprogrammering med PythonAnton Tibblin
 
HT23 - DA354A - Fil- och felhantering
HT23 - DA354A - Fil- och felhanteringHT23 - DA354A - Fil- och felhantering
HT23 - DA354A - Fil- och felhanteringAnton Tibblin
 
HT23 - DA354A - Listor och lexikon
HT23 - DA354A - Listor och lexikonHT23 - DA354A - Listor och lexikon
HT23 - DA354A - Listor och lexikonAnton Tibblin
 
HT23 - DA354A - Kursintroduktion
HT23 - DA354A - KursintroduktionHT23 - DA354A - Kursintroduktion
HT23 - DA354A - KursintroduktionAnton Tibblin
 
HT23 - DA106A - Användbarhet (2)
HT23 - DA106A - Användbarhet (2)HT23 - DA106A - Användbarhet (2)
HT23 - DA106A - Användbarhet (2)Anton Tibblin
 
HT23 - DA106A - Användbarhet 1
HT23 - DA106A - Användbarhet 1HT23 - DA106A - Användbarhet 1
HT23 - DA106A - Användbarhet 1Anton Tibblin
 
HT23 - DA106A - Ramverk & Bibliotek
HT23 - DA106A - Ramverk & BibliotekHT23 - DA106A - Ramverk & Bibliotek
HT23 - DA106A - Ramverk & BibliotekAnton Tibblin
 
HT23 - DA106A - Introduktion till JavaScript
HT23 - DA106A - Introduktion till JavaScriptHT23 - DA106A - Introduktion till JavaScript
HT23 - DA106A - Introduktion till JavaScriptAnton Tibblin
 
HT23 - DA106A - Responsiv webbutveckling
HT23 - DA106A - Responsiv webbutvecklingHT23 - DA106A - Responsiv webbutveckling
HT23 - DA106A - Responsiv webbutvecklingAnton Tibblin
 
HT23 - DA106A - Layout (2)
HT23 - DA106A - Layout (2)HT23 - DA106A - Layout (2)
HT23 - DA106A - Layout (2)Anton Tibblin
 
Introduktion till CSS
Introduktion till CSSIntroduktion till CSS
Introduktion till CSSAnton Tibblin
 
HTML - Tabeller och formulär
HTML - Tabeller och formulärHTML - Tabeller och formulär
HTML - Tabeller och formulärAnton Tibblin
 
Introduktion till HTML
Introduktion till HTMLIntroduktion till HTML
Introduktion till HTMLAnton Tibblin
 
LocalStorage - GeoLocation - Media
LocalStorage - GeoLocation - MediaLocalStorage - GeoLocation - Media
LocalStorage - GeoLocation - MediaAnton Tibblin
 

Plus de Anton Tibblin (20)

2024 - Localstorage & cookies Geolocation Mediahantering.pdf
2024 - Localstorage & cookies Geolocation Mediahantering.pdf2024 - Localstorage & cookies Geolocation Mediahantering.pdf
2024 - Localstorage & cookies Geolocation Mediahantering.pdf
 
VT24 - jQuery & Ajax - Flerplattformsapplikationer med webbtekniker
VT24 - jQuery & Ajax - Flerplattformsapplikationer med webbteknikerVT24 - jQuery & Ajax - Flerplattformsapplikationer med webbtekniker
VT24 - jQuery & Ajax - Flerplattformsapplikationer med webbtekniker
 
VT24 - Responsiv design & Ramverk inom webbutveckling
VT24 - Responsiv design & Ramverk inom webbutvecklingVT24 - Responsiv design & Ramverk inom webbutveckling
VT24 - Responsiv design & Ramverk inom webbutveckling
 
DA395A - VT24 - JavaScript & Document object model
DA395A - VT24 - JavaScript & Document object modelDA395A - VT24 - JavaScript & Document object model
DA395A - VT24 - JavaScript & Document object model
 
VT24 - DA395A - Kursintroduktion: Flerplattformsapplikationer med webbtekniker
VT24 - DA395A - Kursintroduktion: Flerplattformsapplikationer med webbteknikerVT24 - DA395A - Kursintroduktion: Flerplattformsapplikationer med webbtekniker
VT24 - DA395A - Kursintroduktion: Flerplattformsapplikationer med webbtekniker
 
HT23 - DA354A - Webbprogrammering med Python
HT23 - DA354A - Webbprogrammering med PythonHT23 - DA354A - Webbprogrammering med Python
HT23 - DA354A - Webbprogrammering med Python
 
HT23 - DA354A - Fil- och felhantering
HT23 - DA354A - Fil- och felhanteringHT23 - DA354A - Fil- och felhantering
HT23 - DA354A - Fil- och felhantering
 
HT23 - DA354A - Listor och lexikon
HT23 - DA354A - Listor och lexikonHT23 - DA354A - Listor och lexikon
HT23 - DA354A - Listor och lexikon
 
HT23 - DA354A - Kursintroduktion
HT23 - DA354A - KursintroduktionHT23 - DA354A - Kursintroduktion
HT23 - DA354A - Kursintroduktion
 
HT23 - DA106A - Användbarhet (2)
HT23 - DA106A - Användbarhet (2)HT23 - DA106A - Användbarhet (2)
HT23 - DA106A - Användbarhet (2)
 
HT23 - DA106A - Användbarhet 1
HT23 - DA106A - Användbarhet 1HT23 - DA106A - Användbarhet 1
HT23 - DA106A - Användbarhet 1
 
HT23 - DA106A - Ramverk & Bibliotek
HT23 - DA106A - Ramverk & BibliotekHT23 - DA106A - Ramverk & Bibliotek
HT23 - DA106A - Ramverk & Bibliotek
 
HT23 - DA106A - Introduktion till JavaScript
HT23 - DA106A - Introduktion till JavaScriptHT23 - DA106A - Introduktion till JavaScript
HT23 - DA106A - Introduktion till JavaScript
 
HT23 - DA106A - Responsiv webbutveckling
HT23 - DA106A - Responsiv webbutvecklingHT23 - DA106A - Responsiv webbutveckling
HT23 - DA106A - Responsiv webbutveckling
 
HT23 - DA106A - Layout (2)
HT23 - DA106A - Layout (2)HT23 - DA106A - Layout (2)
HT23 - DA106A - Layout (2)
 
Introduktion till CSS
Introduktion till CSSIntroduktion till CSS
Introduktion till CSS
 
HTML - Tabeller och formulär
HTML - Tabeller och formulärHTML - Tabeller och formulär
HTML - Tabeller och formulär
 
Introduktion till HTML
Introduktion till HTMLIntroduktion till HTML
Introduktion till HTML
 
Kursintroduktion
KursintroduktionKursintroduktion
Kursintroduktion
 
LocalStorage - GeoLocation - Media
LocalStorage - GeoLocation - MediaLocalStorage - GeoLocation - Media
LocalStorage - GeoLocation - Media
 

HT19 - DA156A - Layout med CSS