SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Kürzlich hochgeladen

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
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
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
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
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
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 

Kürzlich hochgeladen (20)

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
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
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
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
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
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

Empfohlen

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
 

Empfohlen (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