SlideShare uma empresa Scribd logo
1 de 37
Floats in CSS
                            The most difficult and frustrating part of web design




Friday, February 17, 2012
How boxes work in CSS


             •       By default a box will have a width of 100%, or the full width of its container.

             •       By default a box will have a height that conforms to the content of that box.

             •       If you set a height in CSS, that overrides the content.

             •       By default a box will stack from the top down.




Friday, February 17, 2012
The defaults for a box
                            CSS
        div	
  {




        }

                            HTML

        <div></div>



Friday, February 17, 2012
The defaults for a box
                            CSS
        div	
  {
         border:1px	
  solid	
  #000;



        }

                            HTML

        <div></div>



Friday, February 17, 2012
How boxes work in CSS


     •       By default a box will have a width of 100%, or the full width of its container.

     •       By default a box will have a height that conforms to the content of that box.

     •       If you set a height in CSS, that overrides the content.

     •       By default a box will stack from the top down.




Friday, February 17, 2012
The defaults for a box
                            CSS
        div	
  {
         border:1px	
  solid	
  #000;



        }

                            HTML

        <div></div>



Friday, February 17, 2012
The defaults for a box
                            CSS
        div	
  {
         border:1px	
  solid	
  #000;   hello world




        }

                            HTML

        <div>hello	
  world</div>



Friday, February 17, 2012
How boxes work in CSS


     •       By default a box will have a width of 100%, or the full width of its container.

     •       By default a box will have a height that conforms to the content of that box.

     •       If you set a height in CSS, that overrides the content.

     •       By default a box will stack from the top down.




Friday, February 17, 2012
The defaults for a box
                            CSS
        div	
  {
         border:1px	
  solid	
  #000;                      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
                                                           do eiusmod tempor incididunt ut labore




        }

                            HTML
        <div>Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  
        consectetur	
  adipisicing	
  elit,	
  sed	
  
        do	
  eiusmod	
  tempor	
  incididunt	
  ut	
  
        labore</div>


Friday, February 17, 2012
The defaults for a box
                            CSS
        div	
  {
         border:1px	
  solid	
  #000;                      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
                                                           do eiusmod tempor incididunt ut labore
         height:	
  10px;


        }

                            HTML
        <div>Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  
        consectetur	
  adipisicing	
  elit,	
  sed	
  
        do	
  eiusmod	
  tempor	
  incididunt	
  ut	
  
        labore</div>


Friday, February 17, 2012
How boxes work in CSS


     •       By default a box will have a width of 100%, or the full width of its container.

     •       By default a box will have a height that conforms to the content of that box.

     •       If you set a height in CSS, that overrides the content.

     •       By default a box will stack from the top down.




Friday, February 17, 2012
The defaults for a box
                            CSS
        div	
  {
         border:1px	
  solid	
  #000;   hello world




        }

                            HTML

        <div>hello	
  world</div>



Friday, February 17, 2012
The defaults for a box
                            CSS
        div	
  {
         border:1px	
  solid	
  #000;   hello world
                                        Another box




        }

                            HTML

        <div>hello	
  world</div>
        <div>Another	
  box</div>

Friday, February 17, 2012
How boxes work in CSS


     •       By default a box will have a width of 100%, or the full width of its container.

     •       By default a box will have a height that conforms to the content of that box.

     •       If you set a height in CSS, that overrides the content.

     •       By default a box will stack from the top down.




Friday, February 17, 2012
Floats



Friday, February 17, 2012
Stacking



                  •         By default boxes will stack from the top down, regardless of width.




Friday, February 17, 2012
Default: stack from the top




                                                <div	
  id=“beige”></div>
                                                <div	
  id=“brown”></div>
                                                <div	
  id=“orange”></div>


Friday, February 17, 2012
Stacking from the left

                            float:left;




                                           float:left;




                     float:left;


                                                            <div	
  id=“beige”></div>
                                                            <div	
  id=“brown”></div>
                                                            <div	
  id=“orange”></div>


Friday, February 17, 2012
Stacking from both sides

                            float:left;         float:left;              float:right;




                                                              <div	
  id=“beige”></div>
                                                              <div	
  id=“brown”></div>
                                                              <div	
  id=“orange”></div>


Friday, February 17, 2012
Two boxes floating right

                            float:left;         float:right;                     float:right;




                                                               <div	
  id=“beige”></div>
                                                               <div	
  id=“brown”></div>
                                                               <div	
  id=“orange”></div>


Friday, February 17, 2012
All boxes floating right

                            float:right;        float:right;   float:right;




                                                                    <div	
  id=“beige”></div>
                                                                    <div	
  id=“brown”></div>
                                                                    <div	
  id=“orange”></div>


Friday, February 17, 2012
Float left
                            CSS
        img	
  {




        }
                                                                              Lorem ipsum dolor sit amet, consectetur
                                                           adipisicing elit, sed do eiusmod tempor incididunt ut labore et
                            HTML                           dolore magna aliqua.

        <p><img	
  src=“tree.jpg”>Lorem	
  ipsum	
  
        dolor	
  sit	
  amet,	
  consectetur	
  
        adipisicing	
  elit,	
  sed	
  do	
  eiusmod	
  
        tempor	
  incididunt	
  ut	
  labore	
  et	
  
        dolore	
  magna	
  aliqua.</p>



Friday, February 17, 2012
Float left
                              CSS
        img	
  {
                                                                Lorem ipsum dolor sit amet, consectetur
            float:	
  left;                                     adipisicing elit, sed do eiusmod tempor
                                                                incididunt ut labore et dolore magna aliqua.
        }



                            HTML
        <p><img	
  src=“tree.jpg”>Lorem	
  ipsum	
  
        dolor	
  sit	
  amet,	
  consectetur	
  
        adipisicing	
  elit,	
  sed	
  do	
  eiusmod	
  
        tempor	
  incididunt	
  ut	
  labore	
  et	
  
        dolore	
  magna	
  aliqua.</p>



Friday, February 17, 2012
The problem with floats



Friday, February 17, 2012
Problem with floats
                            [F]loating elements can overlap with the margin, border and padding areas of other
                            elements … when the floating element is wider or higher than the element it is inside.



      <div	
  id=“container”>




      </div>


Friday, February 17, 2012
Problem with floats
                            [F]loating elements can overlap with the margin, border and padding areas of other
                            elements … when the floating element is wider or higher than the element it is inside.



      <div	
  id=“container”>
                                                                      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
                                                                      eiusmod tempor incididunt ut labore et dolore magna aliqua.


             <p>Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  
             consectetur	
  adipisicing	
  elit,	
  
             sed	
  do	
  eiusmod	
  tempor	
  incididunt	
  
             ut	
  labore	
  et	
  dolore	
  magna	
  
             aliqua.</p>




      </div>


Friday, February 17, 2012
Problem with floats
                            [F]loating elements can overlap with the margin, border and padding areas of other
                            elements … when the floating element is wider or higher than the element it is inside.



      <div	
  id=“container”>


             <img	
  src=“tree.jpg”>
             <p>Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  
             consectetur	
  adipisicing	
  elit,	
  
             sed	
  do	
  eiusmod	
  tempor	
  incididunt	
  
             ut	
  labore	
  et	
  dolore	
  magna	
                  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
             aliqua.</p>                                              eiusmod tempor incididunt ut labore et dolore magna aliqua.




      </div>


Friday, February 17, 2012
Problem with floats
                            [F]loating elements can overlap with the margin, border and padding areas of other
                            elements … when the floating element is wider or higher than the element it is inside.



      <div	
  id=“container”>
                                                                                     Lorem ipsum dolor sit amet, consectetur
                                                                                     adipisicing elit, sed do eiusmod tempor
             <img	
  src=“tree.jpg”	
  style=“float:left”>                           incididunt ut labore et dolore magna aliqua.

             <p>Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  
             consectetur	
  adipisicing	
  elit,	
  
             sed	
  do	
  eiusmod	
  tempor	
  incididunt	
  
             ut	
  labore	
  et	
  dolore	
  magna	
  
             aliqua.</p>




      </div>


Friday, February 17, 2012
Let’s say I have a container




Friday, February 17, 2012
Add a box




Friday, February 17, 2012
Apply a float:left to the box




Friday, February 17, 2012
When an item is floated:



                  •         its parent element no longer respects it as content.

                  •         an item that is floated will overlap its container’s borders.




Friday, February 17, 2012
CSS Clear



Friday, February 17, 2012
Clear means “no floating elements allowed”
                p	
  {
                                                   Lorem ipsum dolor sit amet, consectetur
                                                   adipisicing elit, sed do eiusmod tempor
                                                   incididunt ut labore et dolore magna aliqua.
                     clear:left;                   Ut enim ad minim veniam




                }

                     Possible values for “clear”

               clear:none;
               clear:left;
               clear:right;
               clear:both;
Friday, February 17, 2012
Using a clear to fix float issue


                                                1. Create an empty <div>
                                                2. Apply clear:both; to the <div>




Friday, February 17, 2012
Common issue with layout
                            What youʼre hoping to build   What you probably end up with




Friday, February 17, 2012
The Fix
                            What youʼre hoping to build



                                                            .clear{

                                                             clear:both;

                                                            }


                                                            <div	
  class=“clear”></div>


                                                                Putting an empty <div> at the bottom of your document.

Friday, February 17, 2012

Mais conteúdo relacionado

Último

Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 

Último (20)

Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
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
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
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...
 

Floats

  • 1. Floats in CSS The most difficult and frustrating part of web design Friday, February 17, 2012
  • 2. How boxes work in CSS • By default a box will have a width of 100%, or the full width of its container. • By default a box will have a height that conforms to the content of that box. • If you set a height in CSS, that overrides the content. • By default a box will stack from the top down. Friday, February 17, 2012
  • 3. The defaults for a box CSS div  { } HTML <div></div> Friday, February 17, 2012
  • 4. The defaults for a box CSS div  { border:1px  solid  #000; } HTML <div></div> Friday, February 17, 2012
  • 5. How boxes work in CSS • By default a box will have a width of 100%, or the full width of its container. • By default a box will have a height that conforms to the content of that box. • If you set a height in CSS, that overrides the content. • By default a box will stack from the top down. Friday, February 17, 2012
  • 6. The defaults for a box CSS div  { border:1px  solid  #000; } HTML <div></div> Friday, February 17, 2012
  • 7. The defaults for a box CSS div  { border:1px  solid  #000; hello world } HTML <div>hello  world</div> Friday, February 17, 2012
  • 8. How boxes work in CSS • By default a box will have a width of 100%, or the full width of its container. • By default a box will have a height that conforms to the content of that box. • If you set a height in CSS, that overrides the content. • By default a box will stack from the top down. Friday, February 17, 2012
  • 9. The defaults for a box CSS div  { border:1px  solid  #000; Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore } HTML <div>Lorem  ipsum  dolor  sit  amet,   consectetur  adipisicing  elit,  sed   do  eiusmod  tempor  incididunt  ut   labore</div> Friday, February 17, 2012
  • 10. The defaults for a box CSS div  { border:1px  solid  #000; Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore height:  10px; } HTML <div>Lorem  ipsum  dolor  sit  amet,   consectetur  adipisicing  elit,  sed   do  eiusmod  tempor  incididunt  ut   labore</div> Friday, February 17, 2012
  • 11. How boxes work in CSS • By default a box will have a width of 100%, or the full width of its container. • By default a box will have a height that conforms to the content of that box. • If you set a height in CSS, that overrides the content. • By default a box will stack from the top down. Friday, February 17, 2012
  • 12. The defaults for a box CSS div  { border:1px  solid  #000; hello world } HTML <div>hello  world</div> Friday, February 17, 2012
  • 13. The defaults for a box CSS div  { border:1px  solid  #000; hello world Another box } HTML <div>hello  world</div> <div>Another  box</div> Friday, February 17, 2012
  • 14. How boxes work in CSS • By default a box will have a width of 100%, or the full width of its container. • By default a box will have a height that conforms to the content of that box. • If you set a height in CSS, that overrides the content. • By default a box will stack from the top down. Friday, February 17, 2012
  • 16. Stacking • By default boxes will stack from the top down, regardless of width. Friday, February 17, 2012
  • 17. Default: stack from the top <div  id=“beige”></div> <div  id=“brown”></div> <div  id=“orange”></div> Friday, February 17, 2012
  • 18. Stacking from the left float:left; float:left; float:left; <div  id=“beige”></div> <div  id=“brown”></div> <div  id=“orange”></div> Friday, February 17, 2012
  • 19. Stacking from both sides float:left; float:left; float:right; <div  id=“beige”></div> <div  id=“brown”></div> <div  id=“orange”></div> Friday, February 17, 2012
  • 20. Two boxes floating right float:left; float:right; float:right; <div  id=“beige”></div> <div  id=“brown”></div> <div  id=“orange”></div> Friday, February 17, 2012
  • 21. All boxes floating right float:right; float:right; float:right; <div  id=“beige”></div> <div  id=“brown”></div> <div  id=“orange”></div> Friday, February 17, 2012
  • 22. Float left CSS img  { } Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et HTML dolore magna aliqua. <p><img  src=“tree.jpg”>Lorem  ipsum   dolor  sit  amet,  consectetur   adipisicing  elit,  sed  do  eiusmod   tempor  incididunt  ut  labore  et   dolore  magna  aliqua.</p> Friday, February 17, 2012
  • 23. Float left CSS img  { Lorem ipsum dolor sit amet, consectetur float:  left; adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. } HTML <p><img  src=“tree.jpg”>Lorem  ipsum   dolor  sit  amet,  consectetur   adipisicing  elit,  sed  do  eiusmod   tempor  incididunt  ut  labore  et   dolore  magna  aliqua.</p> Friday, February 17, 2012
  • 24. The problem with floats Friday, February 17, 2012
  • 25. Problem with floats [F]loating elements can overlap with the margin, border and padding areas of other elements … when the floating element is wider or higher than the element it is inside. <div  id=“container”> </div> Friday, February 17, 2012
  • 26. Problem with floats [F]loating elements can overlap with the margin, border and padding areas of other elements … when the floating element is wider or higher than the element it is inside. <div  id=“container”> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <p>Lorem  ipsum  dolor  sit  amet,   consectetur  adipisicing  elit,   sed  do  eiusmod  tempor  incididunt   ut  labore  et  dolore  magna   aliqua.</p> </div> Friday, February 17, 2012
  • 27. Problem with floats [F]loating elements can overlap with the margin, border and padding areas of other elements … when the floating element is wider or higher than the element it is inside. <div  id=“container”> <img  src=“tree.jpg”> <p>Lorem  ipsum  dolor  sit  amet,   consectetur  adipisicing  elit,   sed  do  eiusmod  tempor  incididunt   ut  labore  et  dolore  magna   Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do aliqua.</p> eiusmod tempor incididunt ut labore et dolore magna aliqua. </div> Friday, February 17, 2012
  • 28. Problem with floats [F]loating elements can overlap with the margin, border and padding areas of other elements … when the floating element is wider or higher than the element it is inside. <div  id=“container”> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor <img  src=“tree.jpg”  style=“float:left”> incididunt ut labore et dolore magna aliqua. <p>Lorem  ipsum  dolor  sit  amet,   consectetur  adipisicing  elit,   sed  do  eiusmod  tempor  incididunt   ut  labore  et  dolore  magna   aliqua.</p> </div> Friday, February 17, 2012
  • 29. Let’s say I have a container Friday, February 17, 2012
  • 30. Add a box Friday, February 17, 2012
  • 31. Apply a float:left to the box Friday, February 17, 2012
  • 32. When an item is floated: • its parent element no longer respects it as content. • an item that is floated will overlap its container’s borders. Friday, February 17, 2012
  • 34. Clear means “no floating elements allowed” p  { Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. clear:left; Ut enim ad minim veniam } Possible values for “clear” clear:none; clear:left; clear:right; clear:both; Friday, February 17, 2012
  • 35. Using a clear to fix float issue 1. Create an empty <div> 2. Apply clear:both; to the <div> Friday, February 17, 2012
  • 36. Common issue with layout What youʼre hoping to build What you probably end up with Friday, February 17, 2012
  • 37. The Fix What youʼre hoping to build .clear{ clear:both; } <div  class=“clear”></div> Putting an empty <div> at the bottom of your document. Friday, February 17, 2012