SlideShare a Scribd company logo
1 of 21
CSS Layout – Steps



               http://flic.kr/p/9P5DTb
CSS Layout – Steps
1. Consider each element!
  Which box belongs where? Create a declaration for each element.
News    Static   Login




#news   #info    #login
CSS Layout – Steps
1. Consider each element!
  Which box belongs where? Create a declaration for each element.
2. Think of the widths!
  Do design rules like the golden ratio or a grid play a role?
The Golden Ratio




        goldenratiocalculator.com
Grid Based Designs   http://grid-based.com/
CSS Layout – Steps
1. Consider each element!
  Which box belongs where? Create a declaration for each element.
2. Think of the widths!
  Do design rules like the golden ratio or a grid play a role?
3. Calculate the values!
  Sorry, you need to do some maths here…
28% + 2% + 50% + 2% + 18% = 100%

220px + 20px + 480px + 20px + 220px = 960px




         It needs to add up
         or your layout will break!
CSS Layout – Steps
1. Consider each element!
  Which box belongs where? Create a declaration for each element.
2. Think of the widths!
  Do design rules like the golden ratio or a grid play a role?
3. Calculate the values!
  Sorry, you need to do some maths here…
4. Apply the values in the CSS!
  Try to be as concise as possible!
#red {
         background-color: red;
         width: 18%;
         height: 400px;
         margin: 0 2% 0 0;
}
#green {
        background-color: green;
        width: 50%;
        height: 400px;
        margin: 0 2% 0 0;
}
#blue {
        background-color: blue;
        width: 28%;
        height: 400px;
        margin: 0;
}
CSS Layout – Steps
1. Consider each element!
  Which box belongs where? Create a declaration for each element.
2. Think of the widths!
  Do design rules like the golden ratio or a grid play a role?
3. Calculate the values!
  Sorry, you need to do some maths here…
4. Apply the values in the CSS!
  Try to be as concise as possible!
5. Choose the method of layout!
  Is it going to be float or position?
VS
http://flic.kr/p/56L7gN                          http://flic.kr/p/aeLWkc


    • text related images        • elements in a
    • varying heights in           concreted position
      column layout              • need to overwrite
      ( less hassle)              document flow
    • listing things             • flexible
      (document flow             • need to overlap
      matters)
VS
http://flic.kr/p/56L7gN                          http://flic.kr/p/aeLWkc




    Rule
    If elements should not interact, use absolute
    positioning, if they should, use floats.
                                       —says Kilian Valkhof
                                         kilianvalkhof.com
CSS Layout – Steps
1. Consider each element!
  Which box belongs where? Create a declaration for each element.
2. Think of the widths!
  Do design rules like the golden ratio or a grid play a role?
3. Calculate the values!
  Sorry, you need to do some maths here…
4. Apply the values in the CSS!
  Try to be a concise as possible!
5. Choose the method of layout!
  Is it going to be float or position?
6. Apply the method in the CSS!
  Know where to put things!
#red {                                #red {
           background-color: red;                background-color: red;
           width: 18%;                           width: 18%;
                                                 height: 400px;
           height: 400px;
                                                 position: absolute;
           margin: 0 2% 0 0;
                                                 top: 0;
           float: left;                          left: 0;
}                                     }
#green {                              #green {
           background-color: green;              background-color: green;
           width: 50%;                           width: 50%;
           height: 400px;                        height: 400px;
           margin: 0 2% 0 0;                     position: absolute;
                                                 top: 0;
           float: left;
                                                 left: 20%;
}
                                      }
#blue {                               #blue {
           background-color: blue;               background-color: blue;
           width: 28%;                           width: 28%;
           height: 400px;                        height: 400px;
           margin: 0;                            position: absolute;
           float: left;                          top: 0;
}                                                left: 72%;
                                      }
CSS Layout – Steps
1. Consider each element!
  Which box belongs where? Create a declaration for each element.
2. Think of the widths!
  Do design rules like the golden ratio or a grid play a role?
3. Calculate the values!
  Sorry, you need to do some maths here…
4. Apply the values in the CSS!
  Try to be as concise as possible!
5. Choose the method of layout!
  Is it going to be float or position?
6. Apply the method in the CSS!
  Know where to put things!
7. Rewrite the CSS with combined selectors
   and shorthand notation!
#red {
           background-color: red;
           width: 18%;
           height: 400px;
           margin: 0 2% 0 0;
           float: left;
}
#green {
           background-color: green;
           width: 50%;
           height: 400px;
           margin: 0 2% 0 0;
           float: left;
}
#blue {
           background-color: blue;
           width: 28%;
           height: 400px;
           margin: 0;
           float: left;
}
#red {                         #red {
                                          background-color: red;
                                          width: 18%;
           height: 400px;
           margin: 0 2% 0 0;
           float: left;
}                              }
#green {                       #green {
                                          background-color: green;
                                          width: 50%;
           height: 400px;
           margin: 0 2% 0 0;
           float: left;
}                              }
#blue {                        #blue {
                                          background-color: blue;
                                          width: 28%;
           height: 400px;
           margin: 0;
           float: left;
}                              }
#red, #green, #blue {        #red {
         height: 400px;                 background-color: red;
         float: left;                   width: 18%;
}
#red, #green {
         margin: 0 2% 0 0;
}                            }
#blue {                      #green {
         margin: 0;                     background-color: green;
}                                       width: 50%;



                             }
                             #blue {
                                        background-color: blue;
                                        width: 28%;



                             }
#red, #green, #blue {
         height: 400px;
         float: left;
}
#red, #green {
         margin: 0 2% 0 0;
}
#red {
         background-color: red;
         width: 18%;
}
#green {
         background-color: green;
         width: 50%;
}
#blue {
         background-color: blue;
         width: 28%;
         margin: 0;
}
CSS Layout – Steps
1. Consider each element!
  Which box belongs where? Create a declaration for each element.
2. Think of the widths!
  Do design rules like the golden ratio or a grid play a role?
3. Calculate the values!
  Sorry, you need to do some maths here…
4. Apply the values in the CSS!
  Try to be as concise as possible!
5. Choose the method of layout!
  Is it going to be float or position?
6. Apply the method in the CSS!
  Know where to put things!
7. Rewrite the CSS with combined selectors
   and shorthand notation!

More Related Content

More from Alexander Sperl

E-Learning in der wissenschaftlichen Weiterbildung
E-Learning in der wissenschaftlichen WeiterbildungE-Learning in der wissenschaftlichen Weiterbildung
E-Learning in der wissenschaftlichen WeiterbildungAlexander Sperl
 
Das ICM als Modell für die praxisnahe Ausbildung im Lehramt
Das ICM als Modell für die praxisnahe Ausbildung im LehramtDas ICM als Modell für die praxisnahe Ausbildung im Lehramt
Das ICM als Modell für die praxisnahe Ausbildung im LehramtAlexander Sperl
 
Vortrag WS 7, Arbeitstagung Weimar
Vortrag WS 7, Arbeitstagung WeimarVortrag WS 7, Arbeitstagung Weimar
Vortrag WS 7, Arbeitstagung WeimarAlexander Sperl
 
Präsentation M.Sc. Kinderzahnheilkunde
Präsentation M.Sc. KinderzahnheilkundePräsentation M.Sc. Kinderzahnheilkunde
Präsentation M.Sc. KinderzahnheilkundeAlexander Sperl
 
Präsentation AG E-Learning, Fachforum JLU 2014
Präsentation AG E-Learning, Fachforum JLU 2014Präsentation AG E-Learning, Fachforum JLU 2014
Präsentation AG E-Learning, Fachforum JLU 2014Alexander Sperl
 
E-Learning-Unterstützung im WM³-Projekt
E-Learning-Unterstützung im WM³-ProjektE-Learning-Unterstützung im WM³-Projekt
E-Learning-Unterstützung im WM³-ProjektAlexander Sperl
 
Präsentation AG E-Learning, Projektgesamttreffen
Präsentation AG E-Learning, ProjektgesamttreffenPräsentation AG E-Learning, Projektgesamttreffen
Präsentation AG E-Learning, ProjektgesamttreffenAlexander Sperl
 
Struktur, Layout und Design
Struktur, Layout und DesignStruktur, Layout und Design
Struktur, Layout und DesignAlexander Sperl
 
Wissensvermittlung in allen drei Phasen der Lehrerbildung
Wissensvermittlung in allen drei Phasen der LehrerbildungWissensvermittlung in allen drei Phasen der Lehrerbildung
Wissensvermittlung in allen drei Phasen der LehrerbildungAlexander Sperl
 

More from Alexander Sperl (15)

Videos in der Lehre
Videos in der LehreVideos in der Lehre
Videos in der Lehre
 
E-Learning in der wissenschaftlichen Weiterbildung
E-Learning in der wissenschaftlichen WeiterbildungE-Learning in der wissenschaftlichen Weiterbildung
E-Learning in der wissenschaftlichen Weiterbildung
 
Das ICM als Modell für die praxisnahe Ausbildung im Lehramt
Das ICM als Modell für die praxisnahe Ausbildung im LehramtDas ICM als Modell für die praxisnahe Ausbildung im Lehramt
Das ICM als Modell für die praxisnahe Ausbildung im Lehramt
 
Vortrag WS 7, Arbeitstagung Weimar
Vortrag WS 7, Arbeitstagung WeimarVortrag WS 7, Arbeitstagung Weimar
Vortrag WS 7, Arbeitstagung Weimar
 
Präsentation M.Sc. Kinderzahnheilkunde
Präsentation M.Sc. KinderzahnheilkundePräsentation M.Sc. Kinderzahnheilkunde
Präsentation M.Sc. Kinderzahnheilkunde
 
Präsentation AG E-Learning, Fachforum JLU 2014
Präsentation AG E-Learning, Fachforum JLU 2014Präsentation AG E-Learning, Fachforum JLU 2014
Präsentation AG E-Learning, Fachforum JLU 2014
 
E-Learning-Unterstützung im WM³-Projekt
E-Learning-Unterstützung im WM³-ProjektE-Learning-Unterstützung im WM³-Projekt
E-Learning-Unterstützung im WM³-Projekt
 
Präsentation AG E-Learning, Projektgesamttreffen
Präsentation AG E-Learning, ProjektgesamttreffenPräsentation AG E-Learning, Projektgesamttreffen
Präsentation AG E-Learning, Projektgesamttreffen
 
Layout
LayoutLayout
Layout
 
Analysing Prototypes
Analysing PrototypesAnalysing Prototypes
Analysing Prototypes
 
Struktur, Layout und Design
Struktur, Layout und DesignStruktur, Layout und Design
Struktur, Layout und Design
 
Wissensvermittlung in allen drei Phasen der Lehrerbildung
Wissensvermittlung in allen drei Phasen der LehrerbildungWissensvermittlung in allen drei Phasen der Lehrerbildung
Wissensvermittlung in allen drei Phasen der Lehrerbildung
 
Lernplattformen
LernplattformenLernplattformen
Lernplattformen
 
Color
ColorColor
Color
 
Aspects of good design
Aspects of good designAspects of good design
Aspects of good design
 

Recently uploaded

Peaches App development presentation deck
Peaches App development presentation deckPeaches App development presentation deck
Peaches App development presentation decktbatkhuu1
 
💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...
💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...
💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...sonalitrivedi431
 
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...Call Girls in Nagpur High Profile
 
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...ranjana rawat
 
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...RitikaRoy32
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfAmirYakdi
 
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...Call Girls in Nagpur High Profile
 
Government polytechnic college-1.pptxabcd
Government polytechnic college-1.pptxabcdGovernment polytechnic college-1.pptxabcd
Government polytechnic college-1.pptxabcdshivubhavv
 
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)amitlee9823
 
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts ServiceVVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Servicearoranaina404
 
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...BarusRa
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdftbatkhuu1
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...Pooja Nehwal
 
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...kumaririma588
 
Design Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxDesign Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxTusharBahuguna2
 
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...SUHANI PANDEY
 

Recently uploaded (20)

Peaches App development presentation deck
Peaches App development presentation deckPeaches App development presentation deck
Peaches App development presentation deck
 
💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...
💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...
💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...
 
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...
 
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
 
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
 
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
UI:UX Design and Empowerment Strategies for Underprivileged Transgender Indiv...
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
 
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
 
Government polytechnic college-1.pptxabcd
Government polytechnic college-1.pptxabcdGovernment polytechnic college-1.pptxabcd
Government polytechnic college-1.pptxabcd
 
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts ServiceVVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
 
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
 
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
 
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...
 
Design Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxDesign Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptx
 
B. Smith. (Architectural Portfolio.).pdf
B. Smith. (Architectural Portfolio.).pdfB. Smith. (Architectural Portfolio.).pdf
B. Smith. (Architectural Portfolio.).pdf
 
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
 

Steps for CSS Layout

  • 1. CSS Layout – Steps http://flic.kr/p/9P5DTb
  • 2. CSS Layout – Steps 1. Consider each element! Which box belongs where? Create a declaration for each element.
  • 3. News Static Login #news #info #login
  • 4. CSS Layout – Steps 1. Consider each element! Which box belongs where? Create a declaration for each element. 2. Think of the widths! Do design rules like the golden ratio or a grid play a role?
  • 5. The Golden Ratio goldenratiocalculator.com
  • 6. Grid Based Designs http://grid-based.com/
  • 7. CSS Layout – Steps 1. Consider each element! Which box belongs where? Create a declaration for each element. 2. Think of the widths! Do design rules like the golden ratio or a grid play a role? 3. Calculate the values! Sorry, you need to do some maths here…
  • 8. 28% + 2% + 50% + 2% + 18% = 100% 220px + 20px + 480px + 20px + 220px = 960px It needs to add up or your layout will break!
  • 9. CSS Layout – Steps 1. Consider each element! Which box belongs where? Create a declaration for each element. 2. Think of the widths! Do design rules like the golden ratio or a grid play a role? 3. Calculate the values! Sorry, you need to do some maths here… 4. Apply the values in the CSS! Try to be as concise as possible!
  • 10. #red { background-color: red; width: 18%; height: 400px; margin: 0 2% 0 0; } #green { background-color: green; width: 50%; height: 400px; margin: 0 2% 0 0; } #blue { background-color: blue; width: 28%; height: 400px; margin: 0; }
  • 11. CSS Layout – Steps 1. Consider each element! Which box belongs where? Create a declaration for each element. 2. Think of the widths! Do design rules like the golden ratio or a grid play a role? 3. Calculate the values! Sorry, you need to do some maths here… 4. Apply the values in the CSS! Try to be as concise as possible! 5. Choose the method of layout! Is it going to be float or position?
  • 12. VS http://flic.kr/p/56L7gN http://flic.kr/p/aeLWkc • text related images • elements in a • varying heights in concreted position column layout • need to overwrite ( less hassle) document flow • listing things • flexible (document flow • need to overlap matters)
  • 13. VS http://flic.kr/p/56L7gN http://flic.kr/p/aeLWkc Rule If elements should not interact, use absolute positioning, if they should, use floats. —says Kilian Valkhof kilianvalkhof.com
  • 14. CSS Layout – Steps 1. Consider each element! Which box belongs where? Create a declaration for each element. 2. Think of the widths! Do design rules like the golden ratio or a grid play a role? 3. Calculate the values! Sorry, you need to do some maths here… 4. Apply the values in the CSS! Try to be a concise as possible! 5. Choose the method of layout! Is it going to be float or position? 6. Apply the method in the CSS! Know where to put things!
  • 15. #red { #red { background-color: red; background-color: red; width: 18%; width: 18%; height: 400px; height: 400px; position: absolute; margin: 0 2% 0 0; top: 0; float: left; left: 0; } } #green { #green { background-color: green; background-color: green; width: 50%; width: 50%; height: 400px; height: 400px; margin: 0 2% 0 0; position: absolute; top: 0; float: left; left: 20%; } } #blue { #blue { background-color: blue; background-color: blue; width: 28%; width: 28%; height: 400px; height: 400px; margin: 0; position: absolute; float: left; top: 0; } left: 72%; }
  • 16. CSS Layout – Steps 1. Consider each element! Which box belongs where? Create a declaration for each element. 2. Think of the widths! Do design rules like the golden ratio or a grid play a role? 3. Calculate the values! Sorry, you need to do some maths here… 4. Apply the values in the CSS! Try to be as concise as possible! 5. Choose the method of layout! Is it going to be float or position? 6. Apply the method in the CSS! Know where to put things! 7. Rewrite the CSS with combined selectors and shorthand notation!
  • 17. #red { background-color: red; width: 18%; height: 400px; margin: 0 2% 0 0; float: left; } #green { background-color: green; width: 50%; height: 400px; margin: 0 2% 0 0; float: left; } #blue { background-color: blue; width: 28%; height: 400px; margin: 0; float: left; }
  • 18. #red { #red { background-color: red; width: 18%; height: 400px; margin: 0 2% 0 0; float: left; } } #green { #green { background-color: green; width: 50%; height: 400px; margin: 0 2% 0 0; float: left; } } #blue { #blue { background-color: blue; width: 28%; height: 400px; margin: 0; float: left; } }
  • 19. #red, #green, #blue { #red { height: 400px; background-color: red; float: left; width: 18%; } #red, #green { margin: 0 2% 0 0; } } #blue { #green { margin: 0; background-color: green; } width: 50%; } #blue { background-color: blue; width: 28%; }
  • 20. #red, #green, #blue { height: 400px; float: left; } #red, #green { margin: 0 2% 0 0; } #red { background-color: red; width: 18%; } #green { background-color: green; width: 50%; } #blue { background-color: blue; width: 28%; margin: 0; }
  • 21. CSS Layout – Steps 1. Consider each element! Which box belongs where? Create a declaration for each element. 2. Think of the widths! Do design rules like the golden ratio or a grid play a role? 3. Calculate the values! Sorry, you need to do some maths here… 4. Apply the values in the CSS! Try to be as concise as possible! 5. Choose the method of layout! Is it going to be float or position? 6. Apply the method in the CSS! Know where to put things! 7. Rewrite the CSS with combined selectors and shorthand notation!