SlideShare a Scribd company logo
CSS – Layout (2)
Tips & trix, samt nya tekniker
Dagens föreläsning
• Tips och trix kring CSS
• CSS reset
• Repetition av arv (och viktighet av CSS-regler)
• ”Nya” CSS 3-egenskaper
• CSS-animationer
• Layout med Flexbox
• Layout med Grids
• Demos! =)
Förinställda CSS-regler för webbläsaren
Förinställda CSS-regler för webbläsaren
Att skriva över webbläsarens evenskaper?
Men detta är ju jobbigt – hur vet
jag alla webbläsarens förinställda
CSS-egenskaper?
… och hur ändrar jag dessa?
CSS: reset?
http://meyerweb.com/eric/tools/css/reset/
HT17 - DA156A - CSS, Layout 2
HT17 - DA156A - CSS, Layout 2
CSS reset
Fördelar
• Full kontroll över sin CSS-kod
• Tar bort ev. skillnader mellan
webbläsare
Nackdelar
• Mer kod att skriva, då vi ej
använder den ”färdiga” koden
webbläsaren
• Man måste tänka på att formge
alla element som ska formges.
• <strong> är nu inte fetstilt, t.ex.
• Listor har inga nummer/punkter
• Etc.
Att hålla koll på vilka egenskaper
som gäller
Inte alltid så enkelt som man tror!
Ju mer specifik en seletor är, ju
högre prioriteras den
Tumregel
Exempel
HTML
CSS
Webbläsare
Exempel
HTML
CSS
Webbläsare
HT17 - DA156A - CSS, Layout 2
Exempel
HTML
CSS
Webbläsare
HT17 - DA156A - CSS, Layout 2
Exempel
HTML
CSS
Webbläsare
HT17 - DA156A - CSS, Layout 2
HT17 - DA156A - CSS, Layout 2
http://css3generator.com/
Demo
Rundade hörn, skugga, animationer, etc.
+ CSS reset
Flexbox
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
HT17 - DA156A - CSS, Layout 2
Vad är flexbox?
• Ett sätt att positionera ut element på en webbsida
• Ett alternativ till att använda t.ex. float för att bygga layouter
• Flexbox utgår från att positionerna ut barn-element i en ”container”
på olika sätt.
Om Flexbox
Fördelar
• Enkelt att anpassa elements
storlek efter dess innehåll
• Enkelt att centrera element
(vertikalt & horisontellt)
• Enkelt att sätta i vilken ordning
som element ska visas
• Dåligt stöd för äldre webbläsare,
även ”nyare” versioner av IE (IE
11 har stöd)
• Svårt att bygga ”bra” layouter,
mer för att strukturera innehåll
• Nackdelar
Support för flexbox
Vårt upplägg
#container flex-direction
• flex-direction: row; (standard)
• flex-direction: row-reverse;
#container flex-direction
flex-direction: column-reverse;flex-direction: column;
#container flex-wrap
• flex-wrap: nowrap; (standard) – Allt på samma rad
• flex-wrap: wrap;
• flex-wrap: wrap-reverse;
#container justify-content
• justify-content: flex-start;
• justify-content: flex-end;
• justify-content: center;
#container justify-content
• justify-content: space-between;
• justify-content: space-around;
#container align-items
• align-items: flex-start; (standard)
• align-items: flex-end;
• align-items: center;
#container align-items
• align-items: baseline;
• align-items: stretch;
#container align-content
• Används bara vid flera rader
.container { align-content: flex-start | flex-end | center | space-between | space-around | stretch; }
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Hur man positionerar .item
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Nytt också:
CSS-grids
https://css-tricks.com/snippets/css/complete-guide-grid/
HT17 - DA156A - CSS, Layout 2

More Related Content

PDF
HT17 - DA156A - Layout med HTML & CSS
PDF
HT17 - DA156A - Sammanfattning av kursen
PDF
HT17 - DA156A - Ramverk och bibliotek
PDF
HT17 - DA156A - Introduktion till CSS
PDF
HT17 - DA156A - JavaScript i webbutveckling
PDF
VT17 - DA355A - Intro JS
PDF
HT17 - DA156A - Introduktion till HTML
PDF
HT17 - DA156A - Kursintroduktion
HT17 - DA156A - Layout med HTML & CSS
HT17 - DA156A - Sammanfattning av kursen
HT17 - DA156A - Ramverk och bibliotek
HT17 - DA156A - Introduktion till CSS
HT17 - DA156A - JavaScript i webbutveckling
VT17 - DA355A - Intro JS
HT17 - DA156A - Introduktion till HTML
HT17 - DA156A - Kursintroduktion

What's hot (20)

PDF
VT17 - DA355A - Introduktion HTML
PDF
VT17 - DA355A - Responsive design
PDF
HT16 - DA156A - Introduktion till CSS
PDF
HT17 - DA156A - Responsiv webbutveckling
PDF
VT17 - DA355A - Introduktion till CSS
PPTX
JavaScript - Intro
PPTX
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)
PPTX
Webbapplikationer - HTML
PPTX
jQuery & HTML5 Cache
PDF
HT19 - DA156A - Layout med CSS (2)
PPTX
HT16 - DA156A - Ramverk och bibliotek
PDF
HT19 - DA156A - Layout med CSS
PDF
HT16 - DA156A - Introduktion till HTML
PDF
HT16 - DA156A - Kursintroduktion
PDF
HT19 - DA354A - Webbprogrammering med bottle
PDF
Html 3 ht14
PDF
HT16 - DA156A - Introduktion till JavaScript
PDF
HT20 - DA106A - Kursintroduktion
PDF
HT16 - DA156A - CSS, layout
PDF
HT18 - DA354A - Bottle web app
VT17 - DA355A - Introduktion HTML
VT17 - DA355A - Responsive design
HT16 - DA156A - Introduktion till CSS
HT17 - DA156A - Responsiv webbutveckling
VT17 - DA355A - Introduktion till CSS
JavaScript - Intro
Webbapplikationer - Kursintroduktion (anton.tibblin@mah.se)
Webbapplikationer - HTML
jQuery & HTML5 Cache
HT19 - DA156A - Layout med CSS (2)
HT16 - DA156A - Ramverk och bibliotek
HT19 - DA156A - Layout med CSS
HT16 - DA156A - Introduktion till HTML
HT16 - DA156A - Kursintroduktion
HT19 - DA354A - Webbprogrammering med bottle
Html 3 ht14
HT16 - DA156A - Introduktion till JavaScript
HT20 - DA106A - Kursintroduktion
HT16 - DA156A - CSS, layout
HT18 - DA354A - Bottle web app
Ad

Similar to HT17 - DA156A - CSS, Layout 2 (20)

PDF
HT18 - DA156A - Layout med CSS (2)
PDF
HT23 - DA106A - Layout (2)
PDF
HT18 - DA156A - Extra
PDF
13 cms ht14
PPTX
Responsiv webbdesign + HTML5 + CSS5
PDF
4 html 2_ht13
PDF
VT23 - RWD & Ramverk
PDF
Vi skapar en webbsida
PDF
VT18 - DA355A - Introduktion till CSS
PPT
Global återställing av CSS
PDF
HT18 - DA156A - Introduktion till CSS
PDF
HT19 - DA156A - Introduktion till CSS
PDF
HT23 - DA106A - Responsiv webbutveckling
PDF
DA106A - Introduktion till webbutveckling - Responsiv design
PDF
VT2018 - DA355A - LocalStorage & Bootstrap
PDF
HT23 - DA106A - Layout med CSS (1)
PDF
HT18 - DA156A - Frameworks
PDF
HT19 - DA156A - Ramverk och bibliotek
PDF
Introduktion till CSS
PDF
HT24 - Introduktion till webbutveckling - Introduktion till CSS
HT18 - DA156A - Layout med CSS (2)
HT23 - DA106A - Layout (2)
HT18 - DA156A - Extra
13 cms ht14
Responsiv webbdesign + HTML5 + CSS5
4 html 2_ht13
VT23 - RWD & Ramverk
Vi skapar en webbsida
VT18 - DA355A - Introduktion till CSS
Global återställing av CSS
HT18 - DA156A - Introduktion till CSS
HT19 - DA156A - Introduktion till CSS
HT23 - DA106A - Responsiv webbutveckling
DA106A - Introduktion till webbutveckling - Responsiv design
VT2018 - DA355A - LocalStorage & Bootstrap
HT23 - DA106A - Layout med CSS (1)
HT18 - DA156A - Frameworks
HT19 - DA156A - Ramverk och bibliotek
Introduktion till CSS
HT24 - Introduktion till webbutveckling - Introduktion till CSS
Ad

More from Anton Tibblin (20)

PPTX
React - Gästföreläsning - Flerplattformsapplikationer
PDF
2025 - DA395A - Localstorage & cookies Geolocation Mediahantering.pdf
PDF
DA395A -jQuery och Ajax - Flerplattformsapplikationer med webbtekniker
PDF
VT25 - JavaScript och DOM - Flerplattformsapplikationer med webbtekniker
PDF
VT25 - DA395A - Kursintroduktion i Flerplattformsapplikationerm med webbtekniker
PDF
HT24 - DA354B - Introduktion till programmering - OOP
PDF
DA354B - Introduktion till programmering - Webbprogrammering
PDF
DA354B - Introduktion till programmering: Fil- och felhantering
PDF
HT24 - DA354B - Mer om funktioner i Python
PDF
HT24 - DA354B -Intro:Funktioner i Python
PDF
HT24 - DA354B - Introduktion till Python
PDF
HT24 - DA354B - Kursintroduktion till programmering
PDF
HT24 - Introduktion till webbutveckling - Tabeller och formulär
PDF
HT24 - Introduktion till webbutveckling - Introduktion till HTML
PDF
HT24 - Introduktion till webbutveckling - Kursintroduktion
PDF
2024 - Localstorage & cookies Geolocation Mediahantering.pdf
PDF
VT24 - jQuery & Ajax - Flerplattformsapplikationer med webbtekniker
PDF
VT24 - Responsiv design & Ramverk inom webbutveckling
PDF
DA395A - VT24 - JavaScript & Document object model
PDF
VT24 - DA395A - Kursintroduktion: Flerplattformsapplikationer med webbtekniker
React - Gästföreläsning - Flerplattformsapplikationer
2025 - DA395A - Localstorage & cookies Geolocation Mediahantering.pdf
DA395A -jQuery och Ajax - Flerplattformsapplikationer med webbtekniker
VT25 - JavaScript och DOM - Flerplattformsapplikationer med webbtekniker
VT25 - DA395A - Kursintroduktion i Flerplattformsapplikationerm med webbtekniker
HT24 - DA354B - Introduktion till programmering - OOP
DA354B - Introduktion till programmering - Webbprogrammering
DA354B - Introduktion till programmering: Fil- och felhantering
HT24 - DA354B - Mer om funktioner i Python
HT24 - DA354B -Intro:Funktioner i Python
HT24 - DA354B - Introduktion till Python
HT24 - DA354B - Kursintroduktion till programmering
HT24 - Introduktion till webbutveckling - Tabeller och formulär
HT24 - Introduktion till webbutveckling - Introduktion till HTML
HT24 - Introduktion till webbutveckling - Kursintroduktion
2024 - Localstorage & cookies Geolocation Mediahantering.pdf
VT24 - jQuery & Ajax - Flerplattformsapplikationer med webbtekniker
VT24 - Responsiv design & Ramverk inom webbutveckling
DA395A - VT24 - JavaScript & Document object model
VT24 - DA395A - Kursintroduktion: Flerplattformsapplikationer med webbtekniker

HT17 - DA156A - CSS, Layout 2