Skip to content

Instantly share code, notes, and snippets.

@Skydrifa
Last active April 13, 2021 12:00
Show Gist options
  • Save Skydrifa/f1925df0a359c5b7d612f2e58dbcf6e9 to your computer and use it in GitHub Desktop.
Save Skydrifa/f1925df0a359c5b7d612f2e58dbcf6e9 to your computer and use it in GitHub Desktop.
Challenge_ text_outside_the_div

Collapsing inline elements on a block element (Flexbox)

alt text

** Description: ** This program from Smart Ninja. Comes to challenge the group of Web Development 1 to propose the various solutions for the challenge and discuss what it is the one that is more correct on a Web Development Website.

What we want? Every child inside the Parent Box (Flexbox)

alt text

## Tree different solutions:

  1. Parent affects chid items
     * Flex
     * Display
  2. Parent & Child
     * Position

Other cool things to help you:

  1. Justify-content: space-around;
  2. Word-Wrap: break-word;

First Solution:

 1. Parent affects chid items (code only on parent)
     * Flex
     
    (PARENT) header {
    
              ## display: flex; (use it always on the top of the other orders)
              ## flex-flow: row wrap;  / flex-wrap: wrap;
              
              }

Second Solution:

 1. Parent affects chid items (code only on parent)
     * Flex
     
    (PARENT) header {
    
              ## display: flex; (use it always on the top of the other orders)
              
              Fallbacks
              
              ## display: block;
              ## display: inline-block;
              ## display: flow-root; - The old fix was to set overflow: auto on the container, so a class like this is often                 created and used on elements that contain floated elements
              With display: flow-root on the container element, a new block formatting context is established for the                     element with flow layout formatting, and this fixes our overflowing issues much more elegantly.
              
              https://www.digitalocean.com/community/tutorials/css-no-more-clearfix-flow-root
              - Opera Mini and Internet Explorer 11 cannot handle display: flow-root;
              
              HTML
              <p class="ex_">HELLO WORLD!</p>
              CSS
              p.ex1 {display: none;}
              p.ex2 {display: inline;}
              p.ex3 {display: block;}
              p.ex4 {display: inline-block;} - inline can be a block element (a,span,img)
              
              }

alt text

Third Solution:

 2. Parent & Child
     * Position
     
      (PARENT) header {
              position: relative; - move o conteúdo
      }
      (CHILD) header .container {
              position: absolute; - tira da div da caixa em que se encontra e fica parent com a caixa mais próxima
      }
     

Fundamentals for a good Sctructure on HTML

** Description: ** HTML is made up of various elements that act as the building blocks of web pages. For the purpose of styling, elements are divided into two categories: block-level elements and inline elements.

Block-level Elements

** Description: ** A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can). A block-level element always starts on a new line and takes up the full width of a page, from left to right. A block-level element can take up one line or multiple lines and has a line break before and after the element.

Examples of block-level elements:
  1. - The
    element is usually used as a container for other HTML elements and to separate them for the rest. convém agrupar divs numa section para não criar espaços desnecessários e usar o line-height para entre alinahmento.
  2. -

    1. ,
        ,
        ,

Inline Elements

** Description: ** An inline element does not start on a new line and only takes up as much width as necessary. An inline element does not cause a line break (start on a new line) and does not take up the full width of a page, only the space bounded by its opening and closing tag.

This is an inline element inside a paragraph.

Examples of inline elements:
  1. - The element can be used as a container for HTML text. But essentially, it is used to style a certain text within a larger text element.

alt text

Collapsing block elements or Margin Collapsing (Flexbox)

alt text alt text

  Solution: Padding -
            Margin - ás vezes o margin faz com que o size da caixa e por isso tem de ser o paddding a resolver
            

Origin of the Collapsing block elements Problem (Flexbox)

alt text

Solution for not having block collapsing (Flexbox)

alt text

Final Considerations:

Why you need to do this kind of Challenges?

Aren't you always searching for a question on the web for your problem? We need to start contributing to the ones who help us as well.

IN THE END _UPLOAD_SOLUTION: The solution will be uploaded on Stack_Overflow!

Try youself!

Considerations: Understanding the difference between these two elements allows you to better understand the structure of a web page and how it is displayed.

alt text

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="My Fakebook">
<meta name="keywords" content="Float_Flexbox_challenge">
<meta name="author" content="Smart_Ninja_Group">
<link rel="stylesheet" href="style_challenge.css">
<link rel="icon" type="image/png" href="https://i.imgur.com/HqOcDay.png?2">
<title> Challenge </title>
</head>
<body>
<header>
<div class="container">
<h1>Smart Ninja</h1>
<h2> CSS3 + HTML5 showcase styled </h2>
<p>
Made by <a href="https://www.smartninja.pt/"> Smart Ninja Group 2021</a>
</p>
<a href="write_in_the_end_the_various_solutions_for_the_challenge" class="link-github"> Github _ Project </a>
</div>
</header>
</body>
</html>
@import url(https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Sora:wght@400;600;700&display=swap);
/* Display purposes */
* {
margin: 0; /*for reset page for all browsers */
padding:0;
box-sizing: border-box;
font-weight: normal; /*for reset pre-def of type */
width:100%;
}
body {
font-family: "Sora", Arial;
font-size: 100%;
min-height:960px;
height:100%;
min-width:560px;
width: 100%;
overflow: hidden;
}
/* Challenge Begins */
header{
padding:0;
display: flex;
height:40px;
}
header .container {
width: 100%;
display: flex;
align-items: center;
text-align: center;
padding: 0;
text-align: left;
border: 3px solid black;
}
header .container2 p {
font-size: 1.5rem;
padding: 1em 1.5em;
line-height: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment