FLEXBOX

Flex container *parent element*

/* Main properties for flex container*/
Example
      
  /* Flex Container (Parent Element) */
  .flex container {
    display: flex; /* Establishes a flex container */
    
    /* Main properties for flex container*/
    justify-content: space-evenly; /* Aligns flex items along the main axis */
    align-items: center; /* Aligns flex items along the cross axis */
        
align-items: center; /* Aligns flex items along the cross axis */

The align-items property aligns items on the cross axis. For example, if you have a flex container with display: flex and a vertical direction, this property will control the alignment of items vertically within it.

/* Optional properties for flex container*/ flex-direction: row;/* Defines the direction of flex items (row, column, etc.) */ flex-wrap: wrap; /* Allows flex items to wrap onto multiple lines */ flex-flow: column; /* Shorthand for flex-direction and flex-wrap */ align-content: stretch; /* Aligns lines of flex items within the flex container */ }


Flex container *Flex Item (Child Element)*

/* Main properties for flex item*/
Here are some tips:
Example
              
  .flex child {
    /* Optional properties for flex item *child of flex* */
    
    align-self: center; /* Allows a single flex item to align itself independently */
    
    order: 2; /* Changes the order of the flex item */
    
    flex-basis: auto; /*default size "width" before applying "flex-grow" or "flex-shrink" */
    
    flex-grow: 2; /*grow based on flex-basis */ 
    
    flex-shrink: 2;  /*shrink based on flex-basis */
    
    flex: 1 0 5em; /* flex: flex-grow flex-shrink flex-basis *Shorthand* */
    
  }
              
            


GRID


  .grid {
    /* Grid container *parent element* */
    grid-template-columns: repeat(
      auto-fill,
      minmax(250px, 1fr)
    ); /* to get responsive, works with grid-template-columns and grid-template-rows */
  
    grid-template-columns: repeat(
      3,
      1fr
    ); /* values for columns can be put in different units or mixed ways of defining them. */
    grid-template-columns: 22% 22% 22%; /* create columns, the number of values passed represent
        the number of columns created, and their size. */
  
    grid-template-areas:
      "header header header"
      "nav main sidebar"
      "nav footer"; /* works with grid-template-columns and grid-template-rows, the name repetition is
        meaning of spreading // reference , crash course Traversy media for grid */
    width: clamp(200px, 50%, 600px); /* min, preferred, max */
  
    justify-content: center; // just like flexbox
  
    align-items: center; //just like flexbox
  
    gap: 10%; // works as a margin, work also in flexbox
  
    grid-auto-flow: column; // get content to fill the width, just like flexbox do by default
  
    grid-auto-rows: minmax(
      10em,
      auto
    ); /* sets the height of columns, can work as height or if used with minmax(), can be as a min-height */
  
    grid-template-rows: auto; /* works the same as grid-template-columns, 
          the height is the height of the rows with the most content. */
  }
  .parent {
    display: grid;
  
    /* Optional properties for grid container*/
  
    display: grid;
    grid-template-columns: auto;
    grid-template-rows: max-content;
    grid-gap: 0ch;
    grid-auto-rows: min-content;
    grid-auto-columns: minmax();
    grid-template-areas: calc();
    justify-content: center;
    align-items: center;
  }
              
      
    



  .child {
  /* Optional properties for grid item *child of grid* */

    grid-column: auto ;
    grid-row: span ;
    grid-area: auto ;
    align-self: center ;
    justify-self: auto ;
  }
  .a {
    max-width: 5em;
    height: 5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    align-self: center ; /* just like flexbox */
    justify-self: end ; /* just like align-self */

    &:nth-child(1) {
      /* spread a column to go over more columns */ 
      /* same way with */
      grid-row-start: auto ;
      grid-row-end: auto ;
      grid-row: auto;
      /* Example */
      grid-column-start: 1;
      grid-column-end: 4; /* number should be bigger than 2 */
      grid-column: 1 / 3; /* shorthand */
    }
  }
    

TIPS FROM COPILOT

  1. Anchor Positioning: Utilize anchor positioning to place an element relative to another element anywhere on the page, which can be a game-changer for creating complex layouts without resorting to JavaScript.
  2. Shades of Grey: Having a variety of grey shades can be incredibly useful for borders, dividers, and state changes. It's important to have a palette of greys to convey subtleties in your design.
  3. Performance Optimization: Always prune unused styles, minify, and compress your CSS files for smaller file sizes. This not only improves load times but also helps with maintaining your stylesheets.
  4. Immutable Caching: Generate hashed file names for your CSS files to enable safe, immutable caching. This ensures that users always get the most up-to-date styles without cache issues.
  5. Bundle CSS Files: To reduce the number of network requests, bundle your CSS files together. This can significantly improve the performance of your website.
  6. Avoid Naming Collisions: Use naming conventions like BEM (Block Element Modifier) to prevent visual regressions and maintain consistency across your stylesheets.
  7. Use :empty Pseudo-class: The `:empty` pseudo-class can be used to hide or style empty elements that often appear in user-generated content.
  8. Prevent Scroll Bounce: You can prevent the bounce effect when scrolling rapidly to the top or bottom of a webpage with certain CSS properties.
  9. Color Accessibility: Regularly test your color choices for accessibility using tools like WebAIM's color contrast checker or browser dev tools.
  10. Negative Animation Delay: For more natural staggered animations, consider using a negative animation delay. This can make transitions appear smoother and more cohesive.