SlideShare una empresa de Scribd logo
1 de 19
HET BOX MODEL
In CSS werk je met „boxes‟

   Elk HTML-doosje wordt door CSS als een box
    behandeld.
   Dat heet het BOX-model van CSS
   Let op: Zowel inline als block elementen zijn
    boxes!
   Een box is een rechthoek, met een breedte en
    een hoogte
   De afmetingen kunnen ook 0 zijn
De standaard eigenschappen van
een box
   De standaard eigenschappen van een
    element/box worden bepaald door de browser,
    zoals bijvoorbeeld:
     De marges tussen <p>‟s
     De regelafstand in een <p>

     De linkermarge van een <h1>

     De rand om een <img>

   CSS kan dat allemaal wijzigen, en meer
Een box met 3 eigenschappen
                Box-breedte: 300px
                  width: 300px




  width: 300px; height: 100px; background-color: teal;
Een box heeft inhoud
            Box-breedte: 300px
              width: 300px

     inhoud inhoud inhoud inhoud inho
     inhoud inhoud inhoud inhoud inho
     inhoud inhoud inhoud inhoud inho
     inhoud inhoud inhoud inhoud inho




                  Inhoud erin
Meer ruimte in de box
           Box-breedte: 340px
              width: 300px

      inhoud inhoud inhoud inhoud inho
      inhoud inhoud inhoud inhoud inho
      inhoud inhoud inhoud inhoud inho
      inhoud inhoud inhoud inhoud inho




               padding: 20px;
Randen om de box
          Box-breedte: 360px
              width: 300px


      inhoud inhoud inhoud inhoud inho
      inhoud inhoud inhoud inhoud inho
      inhoud inhoud inhoud inhoud inho
      inhoud inhoud inhoud inhoud inho




          border: 10px solid red;
Meer ruimte om de box
         Box-breedte: 420px
                width: 300px



        inhoud inhoud inhoud inhoud inho
        inhoud inhoud inhoud inhoud inho
        inhoud inhoud inhoud inhoud inho
        inhoud inhoud inhoud inhoud inho



              margin: 30px;
De uiteindelijke grootte:

           300 + 40 + 20 + 60= 420px




                   inhoud inhoud inhoud inhoud inho
                   inhoud inhoud inhoud inhoud inho
                   inhoud inhoud inhoud inhoud inho
                   inhoud inhoud inhoud inhoud inho



{width : 300px; height : 100px; padding : 20px; border :10px solid
                       red; margin : 30px;}
De grootte van de box

   Een box kan dus veel groter zijn dan je
    opgegeven width!
   Padding, border en margin komen erbij.
Helaas, Internet Explorer

   Oudere versies van IE (t/m versie 5.5) deden
    het fout:
     De uiteindelijke grootte bestond uit width + margin
     En padding en border vielen binnen de width!

     De uiteindelijke breedte van de vorige box was
      geen 420px maar 360px
   Groot probleem voor acceptatie van layout met
    CSS.
POSITIE
Wat is je positie?

   In CSS kunnen boxes gepositioneerd worden.
   Je kunt o.a. de top en left bepalen


                             top: 40px;


                left: 45px
Drie soorten posities
   Boxes kunnen een van de drie volgende
    posities hebben:
     Statisch {position: static;}
     Precies bepaald {position: absolute}
     T.o.v normale plaatsing {position: relative}

   Boxes zijn standaard static
   Let op: Top en Left werken alleen in absolute
    en relative positie
   Posities worden bepaald t.ov. de ouder
What You See is What You Get

   Veel WYSIWYG-editors werken met de
    absolute position van boxes.
   Voordeel: positie en grootte van een element
    is pixelprecies op de pagina aan te geven.
   Nadeel: Alleen handig als je van te voren al
    weet hoe groot iets moet worden, hoeveel
    tekst er precies in een box moet.
Voorbeeld code van absolute
position:
   <p style=“position :absolute; left :140px; top :200px;
    width : 400px; height : 300px; background-color :
    yellow; margin : 10px; padding : 2px;”>Deze
    paragraaf staat op een precieze plek op het
    scherm!</p>



       Deze paragraaf staat op een precieze
       plek op het scherm
Twee boxes met marge, naast
elkaar




 {margin: 20px;}
 De boxes staan 40px van elkaar af!
Twee boxes met marge, onder
elkaar




                                     De grootste marge telt




{margin: 20px;}
De boxes staan 20px van elkaar af!
Dit was een presentatie van
pc-coach

Más contenido relacionado

Destacado

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destacado (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Boxmodel

  • 2. In CSS werk je met „boxes‟  Elk HTML-doosje wordt door CSS als een box behandeld.  Dat heet het BOX-model van CSS  Let op: Zowel inline als block elementen zijn boxes!  Een box is een rechthoek, met een breedte en een hoogte  De afmetingen kunnen ook 0 zijn
  • 3. De standaard eigenschappen van een box  De standaard eigenschappen van een element/box worden bepaald door de browser, zoals bijvoorbeeld:  De marges tussen <p>‟s  De regelafstand in een <p>  De linkermarge van een <h1>  De rand om een <img>  CSS kan dat allemaal wijzigen, en meer
  • 4. Een box met 3 eigenschappen Box-breedte: 300px width: 300px width: 300px; height: 100px; background-color: teal;
  • 5. Een box heeft inhoud Box-breedte: 300px width: 300px inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho Inhoud erin
  • 6. Meer ruimte in de box Box-breedte: 340px width: 300px inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho padding: 20px;
  • 7. Randen om de box Box-breedte: 360px width: 300px inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho border: 10px solid red;
  • 8. Meer ruimte om de box Box-breedte: 420px width: 300px inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho margin: 30px;
  • 9. De uiteindelijke grootte: 300 + 40 + 20 + 60= 420px inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho inhoud inhoud inhoud inhoud inho {width : 300px; height : 100px; padding : 20px; border :10px solid red; margin : 30px;}
  • 10. De grootte van de box  Een box kan dus veel groter zijn dan je opgegeven width!  Padding, border en margin komen erbij.
  • 11. Helaas, Internet Explorer  Oudere versies van IE (t/m versie 5.5) deden het fout:  De uiteindelijke grootte bestond uit width + margin  En padding en border vielen binnen de width!  De uiteindelijke breedte van de vorige box was geen 420px maar 360px  Groot probleem voor acceptatie van layout met CSS.
  • 13. Wat is je positie?  In CSS kunnen boxes gepositioneerd worden.  Je kunt o.a. de top en left bepalen top: 40px; left: 45px
  • 14. Drie soorten posities  Boxes kunnen een van de drie volgende posities hebben:  Statisch {position: static;}  Precies bepaald {position: absolute}  T.o.v normale plaatsing {position: relative}  Boxes zijn standaard static  Let op: Top en Left werken alleen in absolute en relative positie  Posities worden bepaald t.ov. de ouder
  • 15. What You See is What You Get  Veel WYSIWYG-editors werken met de absolute position van boxes.  Voordeel: positie en grootte van een element is pixelprecies op de pagina aan te geven.  Nadeel: Alleen handig als je van te voren al weet hoe groot iets moet worden, hoeveel tekst er precies in een box moet.
  • 16. Voorbeeld code van absolute position:  <p style=“position :absolute; left :140px; top :200px; width : 400px; height : 300px; background-color : yellow; margin : 10px; padding : 2px;”>Deze paragraaf staat op een precieze plek op het scherm!</p> Deze paragraaf staat op een precieze plek op het scherm
  • 17. Twee boxes met marge, naast elkaar {margin: 20px;} De boxes staan 40px van elkaar af!
  • 18. Twee boxes met marge, onder elkaar De grootste marge telt {margin: 20px;} De boxes staan 20px van elkaar af!
  • 19. Dit was een presentatie van pc-coach