SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Dernier

Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
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
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 

Dernier (20)

Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
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.
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

En vedette

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
 

En vedette (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