SlideShare a Scribd company logo
1 of 32
Download to read offline
Layout med CSS
Dagens föreläsning
• Snabb repetition
• Element för positionering
• Positionering av element
• Static
• Relative
• Absolute
• Fixed
• Layout med CSS
• Exempel, exempel & exempel
Frågor kring det vi gått igenom hittils?
• HTML
• Doctype <!doctype html>
• Teckenuppsättning <meta charset=”utf-8”>
• Taggar <h1>, <p>, <ul>, <li>, <i>, <b>
• Tabeller <table><tr><td></td></tr></table>
• Formulär <form action=”#” method=”get”>
• CSS
• Selektorer h1, .class, #id
• Egenskaper font-size:12px; color:red;
Översikt HTML-dokument
Vad innehåller sidan?
Metadata om sidan
Sidans teckenkodning
Sidans titel
Sidans innehåll
HTML, rotelementet
Länkar
Var länken lederLänk-element Länkens namn
Extern länk
Länk inom
webbplatsen
Intern länk
Tabeller
I webbläsaren
Formulär
CSS
• Att formge en webbplats
• Olika klädsel till samma innehåll
• Hur hittar man det man vill ändra på?
Boxar
Total bredd för en box är: Content (width) + Padding + Border.
Margin är sedan marginalen från boxen
Utvecklingsverktyget i Chrome (F12)
Elementet <div>
“The <div> tag defines a division or a section in an HTML document.”
Positionera saker
Positionering
• Visar elementen i den ordning de skrivs i HTML-koden
• Static (standard)
• Relative
• Visar elementen i relation till förälder-elementet eller dokumentet
• Absolute
• Fixed
Position: static
• Är standard-positionen för HTML-element
• Elementen visas i den ordning som de skrivs i (det som står först i
HTML-dokumentet visas först)
• Egenskaper som ej används med position: static
• left, right, top, bottom
• z-index
Position: relative
• Elementen visas i den ordning som de skrivs i (det som står först i
HTML-dokumentet visas först)
• Egenskaper som kan användas med position: relative
• left, right, top, bottom
• Avstånd från elementets normala plats på webbsidan
• z-index
• Avgör om elementet ska ligga över/under andra element
Position: absolute
• Specificerar ett elements position relativt mot
• Förälder-elementet (som har ”position: relative”)
• Eller om detta ej finns, till dokumentet
Position: fixed
• Specificerar ett elements position relativt mot
• Hela dokumentet
• Positionen påverkas inte när man skrollar, utan ligger ”fastklistrad” på
samma plats på skärmen
Att lägga element bredvid varandra
• Egenskapen ”float”
• Gör så att man kan placera block-element bredvid varandra
• Float:left; Flyttar elementet till vänster
• Float:right; Flyttar elementet till höger
• Gäller
• postion: static
• position: relative
https://www.w3schools.com/cssref/css_selectors.asp
Demo positionering
https://developer.mozilla.org/en-US/docs/Web/HTML/Element
Andra, ”bättre”, element för layout
<header> Definierar ett sidhuvud för dokument/artikel
<nav> Definierar en navigation
<main> Definierar huvudinnehåll i ett dokument
<section> Definierar en sektion i ett dokument/artikel
<aside> Definierar innehåll som skiljer sig (t.ex. ”sidebar”)
<footer> Definierar en sidfot för dokument/artikel
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.
box-sizing: content-box;
box-sizing: border-box;
Demo layout
Egenskapen: box-sizing
http://www.w3schools.com/cssref/css3_pr_box-sizing.asp

More Related Content

What's hot

VT17 - DA355A - Intro JS
VT17 - DA355A - Intro JSVT17 - DA355A - Intro JS
VT17 - DA355A - Intro JSAnton Tibblin
 
Webbapplikationer - HTML
Webbapplikationer - HTMLWebbapplikationer - HTML
Webbapplikationer - HTMLAnton Tibblin
 
VT18 - DA355A - Introduktion till CSS
VT18 - DA355A - Introduktion till CSSVT18 - DA355A - Introduktion till CSS
VT18 - DA355A - Introduktion till CSSAnton Tibblin
 
VT17 - DA355A - Responsive design
VT17 - DA355A - Responsive designVT17 - DA355A - Responsive design
VT17 - DA355A - Responsive designAnton Tibblin
 
HT17 - DA156A - Introduktion till HTML
HT17 - DA156A - Introduktion till HTMLHT17 - DA156A - Introduktion till HTML
HT17 - DA156A - Introduktion till 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
 
VT18 - DA355A/DA344A - Introduktion till HTML
VT18 - DA355A/DA344A - Introduktion till HTMLVT18 - DA355A/DA344A - Introduktion till HTML
VT18 - DA355A/DA344A - Introduktion till HTMLAnton Tibblin
 
HT17 - DA156A - Tabeller & Formulär
HT17 - DA156A - Tabeller & FormulärHT17 - DA156A - Tabeller & Formulär
HT17 - DA156A - Tabeller & FormulärAnton Tibblin
 
HT16 - DA156A - Introduktion till HTML
HT16 - DA156A - Introduktion till HTMLHT16 - DA156A - Introduktion till HTML
HT16 - DA156A - Introduktion till HTMLAnton Tibblin
 
HT17 - DA156A - Ramverk och bibliotek
HT17 - DA156A - Ramverk och bibliotekHT17 - DA156A - Ramverk och bibliotek
HT17 - DA156A - Ramverk och bibliotekAnton Tibblin
 
HT17 - DA156A - JavaScript i webbutveckling
HT17 - DA156A - JavaScript i webbutvecklingHT17 - DA156A - JavaScript i webbutveckling
HT17 - DA156A - JavaScript i webbutvecklingAnton Tibblin
 
HT17 - DA156A - Kursintroduktion
HT17 - DA156A - KursintroduktionHT17 - DA156A - Kursintroduktion
HT17 - DA156A - KursintroduktionAnton Tibblin
 
jQuery & HTML5 Cache
jQuery & HTML5 CachejQuery & HTML5 Cache
jQuery & HTML5 CacheAnton Tibblin
 
HT16 - DA156A - Kursintroduktion
HT16 - DA156A - KursintroduktionHT16 - DA156A - Kursintroduktion
HT16 - DA156A - KursintroduktionAnton Tibblin
 
HT17 - DA156A - Responsiv webbutveckling
HT17 - DA156A - Responsiv webbutvecklingHT17 - DA156A - Responsiv webbutveckling
HT17 - DA156A - Responsiv webbutvecklingAnton Tibblin
 
HT19 - DA156A - Layout med CSS (2)
HT19 - DA156A - Layout med CSS (2)HT19 - DA156A - Layout med CSS (2)
HT19 - DA156A - Layout med CSS (2)Anton Tibblin
 
HT19 - DA156A - Layout med CSS
HT19 - DA156A - Layout med CSSHT19 - DA156A - Layout med CSS
HT19 - DA156A - Layout med CSSAnton Tibblin
 
HT18 - DA156A - Extra
HT18 - DA156A - ExtraHT18 - DA156A - Extra
HT18 - DA156A - ExtraAnton Tibblin
 

What's hot (20)

VT17 - DA355A - Intro JS
VT17 - DA355A - Intro JSVT17 - DA355A - Intro JS
VT17 - DA355A - Intro JS
 
Webbapplikationer - HTML
Webbapplikationer - HTMLWebbapplikationer - HTML
Webbapplikationer - HTML
 
VT18 - DA355A - Introduktion till CSS
VT18 - DA355A - Introduktion till CSSVT18 - DA355A - Introduktion till CSS
VT18 - DA355A - Introduktion till CSS
 
VT17 - DA355A - Responsive design
VT17 - DA355A - Responsive designVT17 - DA355A - Responsive design
VT17 - DA355A - Responsive design
 
HT17 - DA156A - Introduktion till HTML
HT17 - DA156A - Introduktion till HTMLHT17 - DA156A - Introduktion till HTML
HT17 - DA156A - Introduktion till HTML
 
JavaScript - Intro
JavaScript - IntroJavaScript - Intro
JavaScript - Intro
 
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)
 
VT18 - DA355A/DA344A - Introduktion till HTML
VT18 - DA355A/DA344A - Introduktion till HTMLVT18 - DA355A/DA344A - Introduktion till HTML
VT18 - DA355A/DA344A - Introduktion till HTML
 
HT17 - DA156A - Tabeller & Formulär
HT17 - DA156A - Tabeller & FormulärHT17 - DA156A - Tabeller & Formulär
HT17 - DA156A - Tabeller & Formulär
 
HT16 - DA156A - Introduktion till HTML
HT16 - DA156A - Introduktion till HTMLHT16 - DA156A - Introduktion till HTML
HT16 - DA156A - Introduktion till HTML
 
HT17 - DA156A - Ramverk och bibliotek
HT17 - DA156A - Ramverk och bibliotekHT17 - DA156A - Ramverk och bibliotek
HT17 - DA156A - Ramverk och bibliotek
 
HT17 - DA156A - JavaScript i webbutveckling
HT17 - DA156A - JavaScript i webbutvecklingHT17 - DA156A - JavaScript i webbutveckling
HT17 - DA156A - JavaScript i webbutveckling
 
HT17 - DA156A - Kursintroduktion
HT17 - DA156A - KursintroduktionHT17 - DA156A - Kursintroduktion
HT17 - DA156A - Kursintroduktion
 
jQuery & HTML5 Cache
jQuery & HTML5 CachejQuery & HTML5 Cache
jQuery & HTML5 Cache
 
HT16 - DA156A - Kursintroduktion
HT16 - DA156A - KursintroduktionHT16 - DA156A - Kursintroduktion
HT16 - DA156A - Kursintroduktion
 
HT17 - DA156A - Responsiv webbutveckling
HT17 - DA156A - Responsiv webbutvecklingHT17 - DA156A - Responsiv webbutveckling
HT17 - DA156A - Responsiv webbutveckling
 
HT19 - DA156A - Layout med CSS (2)
HT19 - DA156A - Layout med CSS (2)HT19 - DA156A - Layout med CSS (2)
HT19 - DA156A - Layout med CSS (2)
 
4 html 2_ht13
4 html 2_ht134 html 2_ht13
4 html 2_ht13
 
HT19 - DA156A - Layout med CSS
HT19 - DA156A - Layout med CSSHT19 - DA156A - Layout med CSS
HT19 - DA156A - Layout med CSS
 
HT18 - DA156A - Extra
HT18 - DA156A - ExtraHT18 - DA156A - Extra
HT18 - DA156A - Extra
 

Similar to HT17 - DA156A - Layout med HTML & CSS

HT18 - DA156A - Layout med CSS
HT18 - DA156A - Layout med CSSHT18 - DA156A - Layout med CSS
HT18 - DA156A - Layout med CSSAnton Tibblin
 
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
 
Föreläsning 1: Grundläggande HTML
Föreläsning 1: Grundläggande HTMLFöreläsning 1: Grundläggande HTML
Föreläsning 1: Grundläggande HTMLJohannes Karlsson
 
VT2019 - DA355A - Intro HTML & CSS
VT2019 - DA355A - Intro HTML & CSSVT2019 - DA355A - Intro HTML & CSS
VT2019 - DA355A - Intro HTML & CSSAnton Tibblin
 
Introduktion till CSS
Introduktion till CSSIntroduktion till CSS
Introduktion till CSSAnton Tibblin
 
Introduktion till HTML
Introduktion till HTMLIntroduktion till HTML
Introduktion till HTMLAnton Tibblin
 
HT19 - DA156A - Introduktion till CSS
HT19 - DA156A - Introduktion till CSSHT19 - DA156A - Introduktion till CSS
HT19 - DA156A - Introduktion till CSSAnton Tibblin
 
HT18 - DA156A - Introduktion till CSS
HT18 - DA156A - Introduktion till CSSHT18 - DA156A - Introduktion till CSS
HT18 - DA156A - Introduktion till CSSAnton Tibblin
 

Similar to HT17 - DA156A - Layout med HTML & CSS (10)

HT18 - DA156A - Layout med CSS
HT18 - DA156A - Layout med CSSHT18 - DA156A - Layout med CSS
HT18 - 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)
 
Föreläsning 1: Grundläggande HTML
Föreläsning 1: Grundläggande HTMLFöreläsning 1: Grundläggande HTML
Föreläsning 1: Grundläggande HTML
 
Föreläsning om HTML
Föreläsning om HTMLFöreläsning om HTML
Föreläsning om HTML
 
Föreläsning om CSS
Föreläsning om CSSFöreläsning om CSS
Föreläsning om CSS
 
VT2019 - DA355A - Intro HTML & CSS
VT2019 - DA355A - Intro HTML & CSSVT2019 - DA355A - Intro HTML & CSS
VT2019 - DA355A - Intro HTML & CSS
 
Introduktion till CSS
Introduktion till CSSIntroduktion till CSS
Introduktion till CSS
 
Introduktion till HTML
Introduktion till HTMLIntroduktion till HTML
Introduktion till HTML
 
HT19 - DA156A - Introduktion till CSS
HT19 - DA156A - Introduktion till CSSHT19 - DA156A - Introduktion till CSS
HT19 - DA156A - Introduktion till CSS
 
HT18 - DA156A - Introduktion till CSS
HT18 - DA156A - Introduktion till CSSHT18 - DA156A - Introduktion till CSS
HT18 - DA156A - Introduktion till CSS
 

More from 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
 
HTML - Tabeller och formulär
HTML - Tabeller och formulärHTML - Tabeller och formulär
HTML - Tabeller och formulärAnton Tibblin
 
LocalStorage - GeoLocation - Media
LocalStorage - GeoLocation - MediaLocalStorage - GeoLocation - Media
LocalStorage - GeoLocation - MediaAnton Tibblin
 
VT23 - RWD & Ramverk
VT23 - RWD & RamverkVT23 - RWD & Ramverk
VT23 - RWD & RamverkAnton Tibblin
 

More from 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)
 
HTML - Tabeller och formulär
HTML - Tabeller och formulärHTML - Tabeller och formulär
HTML - Tabeller och formulär
 
Kursintroduktion
KursintroduktionKursintroduktion
Kursintroduktion
 
LocalStorage - GeoLocation - Media
LocalStorage - GeoLocation - MediaLocalStorage - GeoLocation - Media
LocalStorage - GeoLocation - Media
 
jQuery & Ajax
jQuery & AjaxjQuery & Ajax
jQuery & Ajax
 
VT23 - RWD & Ramverk
VT23 - RWD & RamverkVT23 - RWD & Ramverk
VT23 - RWD & Ramverk
 

HT17 - DA156A - Layout med HTML & CSS