Giter Club home page Giter Club logo

natours's Introduction

Table of Contents

  1. Building a header
  2. CSS animations
  3. Building a complex animated button
  4. The 3 pillars to writing good HTML and CSS
  5. The Cascade and Specificity
  6. How CSS values are processed
  7. Inheritance
  8. CSS Units
  9. How CSS renders a website
  10. Box Types
  11. Positioning schemes
  12. The Think-Build-Architect Mindset
  13. What is Sass?
  14. Sass syntax vs SCSS syntax
  15. Basic responsive design principles
  16. Layout types
  17. Building a Custom Grid with Floats
  18. Building an About Section
  19. Building a Features Section
  20. Building a Tours Section
  21. Building a Stories Section
  22. Building a Booking Section
  23. Building a Beautiful Navigation
  24. Building a Pure CSS Popup

1. Building the header

  • The best way to perform a basic reset using the universal selector.
  • Setting up project-wide font definitions.
  • Clipping parts of elements using clip-path.
  • The easiest way to center anything with the transform, top and left properties.

2. CSS animations

3. Building a complex animated button


4. The 3 pillars to writing good HTML and CSS

  • Responsive design
    • Fluid layouts
    • Media queries
    • Responsive images
    • Correct units
    • Desktop-first vs mobile-first
  • Maintainable and scalable code
    • Clean
    • Easy-to-understand
    • Supports potential for future growth
    • Reusable
    • How to organize files
    • How to name classes
    • How to structure HTML
  • Web performance
    • Make less HTTP requests
    • Write less code
    • Compress code
    • Use a CSS preprocessor
    • Use as few images as possible
    • Compress images

5. The Cascade and Specificity

  • Cascade: the process of combining different stylesheets and resolving conflicts between different CSS rules and declarations when more than one rule applies to a certain element.
  • To resolve conflicts between conflicting declarations, the Cascade first looks at the importance (weight), then at the selector specificity, and lastly at the source order.
  • Importance
    • User !important declarations
    • Author !important declarations
    • Author declarations
    • User declarations
    • Default browser declarations
  • Specificity
    • Inline styles
    • IDs
    • Classes, pseudo-classes, attribute
    • Elements, pseudo-elements
  • Source order
    • The last declaration in the code will override all other and will be applied.
  • CSS declarations marked with !important have the highest priority.
  • But, only use !important as a last resource. It's better to use correct specificities – more maintainable code!
  • Inline styles will always have priority over styles in external stylesheets.
  • A selector that contains 1 ID is more specific than one with 1000 classes.
  • A selector that contains 1 class is more specific than one with 1000 elements.
  • The universal selector * has no specificity value (0, 0, 0, 0).
  • Rely more on specificity than on the order of selectors.
  • But, rely on order when using 3rd-party stylesheets – always put your author stylesheet last.

6. How CSS values are processed

  • Each property has an initial value, used if nothing is declared (and if there is no inheritance).
  • Browsers specify a root font-size for each page (usually 16px).
  • Percentages and relative values are always converted to pixels.
  • Percentages are measured relative to their parent's font-size, if used to specify font-size.
  • Percentages are measured relative their parent's width, if used to spefify lengths.
  • em are measured relative to their parent font-size, if used to specify font-size.
  • em are measured relative to the current font-size, if used to specify lengths.
  • rem are always measured relative to the document's root font-size.
  • vh and vw are simply percentage measurements of the viewport's height and width.

7. Inheritance

  • Inheritance passes the values for some specific properties from parents to children – more maintainable code.
  • Properties related to text are inherited: font-family, font-size, color, etc. Other properties like padding and margin are not inherited.
  • The computed value of a property is what gets inherited, not the declared value.
  • Inheritance of a property only works if no one declares a value for that property.
  • The inherit keyword forces inheritance on a certain property.
  • The initial keyword resets a property to its initial value.
  • Absolute Lengths vs Relative Lengths.
  • The em and rem units are practical in creating perfectly scalable layouts.

9. How CSS renders a website

  • The Visual Formatting Model: an algorithm that calculates boxes and determines the layout of these boxes, for each element in the render tree, in order to determine the final layout of the page. It takes into account:
    • Dimensions of boxes: the box model.
    • Box type: inline, block, and inline-block.
    • Positioning scheme: floats and positioning.
    • Stacking context.
    • Other elements in the render tree.
    • Viewport size, dimensions of images, etc.

  • The Box Model:
    • Content: text, images, etc.
    • Padding: transparent area around the content, inside the box.
    • Border: goes around the padding and the content.
    • Margin: space between boxes.
    • Fill area: area that gets filled with background color or background image.

10. Box Types

  • Block-level boxes
    • Elements formatted visually as blocks
    • 100% of parent's width
    • Vertically, one after another
    • Box-model applies as showed
      display: block
      (display: flex)
      (display: list-item)
      (display: table)
  • Inline-block boxes
    • A mix of block and inline
    • Occupies only content's space
    • No line-breaks
    • Box-model applies as showed
      display: inline-block

  • Inline boxes
    • Content is distributed in lines
    • Occupies only content's space
    • No line-breaks
    • No heights and widths
    • Paddings and margins only horizontal
      display: inline

11. Positioning schemes

  • Normal flow
    • Default positioning scheme
    • NOT floated
    • NOT absolutely positioned
    • Elements laid out according to their source order
      position: relative

  • Floats
    • Element is removed from the normal flow.
    • Text and inline elements will wrap around the floated element
    • The container will not adjust its height to the element
      float: left
      float: right
  • Absolute positioning
    • Element is removed from the normal flow
    • No impact on surrounding content or elements
    • We use top, bottom and right to offset the element from its relatively positioned container
      position: absolute
      position: fixed

12. The Think-Build-Architect Mindset

  1. Think about the layout of your webpage or web app before writing code.
    Component Driven Design:
    • Modular building blocks that make up interfaces.
    • Held together by the layout of the page.
    • Re-usable across a project, and between different projects.
    • Independent, allowing us to use them anywhere on the page.

  2. Build your layout in HTML and CSS with a consistent structure for naming classes.
    BEM – Block Element Modifier:
    • BLOCK: standalone component that is meaningful on its own.
    • ELEMENT: part of a block that has no standalone meaning.
    • MODIFIER: a different version of a block or an element.
    • Low-specificity selectors:
      .block {}
      .block__element {}
      .block__element--modifier {}
  3. Create a logical architecture for your CSS with files and folders.
    The 7-1 Pattern:
    • 7 different folders for partial Sass files, and 1 main Sass file to import all other files into a compiled CSS stylesheet:
      base/
      components/
      layout/
      pages/
      themes/
      abstracts/
      vendors/

13. What is Sass?

  • Sass is a CSS preprocessors; an extension of CSS that adds power and elegance to the basic language.
  • Sass source code gets compiled into CSS code.
  • Features:
    • Variables for reusable values such as colors, font-size, spacing, etc.
    • Nesting of selectors inside of one another, allowing us to write less code.
    • Operators for mathematical operations right inside of CSS.
    • Partials and imports to write CSS in different files and importing them all into one single file.
    • Mixins to write reusable pieces of CSS code.
    • Functions similar to mixins, but also produce a value that can be used later.
    • Extends to make different selectors inherit declarations that are common to all of them.
    • Control directives for writing complex code using conditionals and loops.

14. Sass syntax vs SCSS syntax

  • Sass syntax uses indentation instead of curly braces.
  • SCSS syntax is closer to CSS; uses curly braces.

15. Basic responsive design principles

  1. Fluid grids and layouts
    To allow content to easily adapt to the current viewport width used to browse the website. Uses % rather than px for all layout-related lengths.

  2. Flexible/responsive images
    Images behave differently than text content, and so we need to ensure that they also adapt nicely to the current viewport.

  3. Media queries
    To change styles on certain viewport widths (breakpoints), allowing us to create different versions of our website for different widths.

16. Layout types

  • Float layouts
  • Flexbox
  • CSS grid

17. Building a Custom Grid with Floats

  • Architecting and building a simple grid system.
  • Using the attribute selector.
  • Using the :not pseudo-class.
  • Using calc() instead Sass operations to perform operations on different units.

18. Building an About Section

  • Thinking about components.
  • Using utility classes.
  • Using the background-clip property.
  • transforming multiple properties simultaneously.
  • Using the outline-offset property together with outline.
  • Styling elements that are NOT hovered while others are.

19. Building a Features Section

  • Using an icon font (linea.io).
  • Creating the "skewed section" with a skew() transformation.
  • Using the direct child selector >.

20. Building a Tours Section

21. Building a Stories Section

  • Making text float around shapes with shape-outside and float.
  • Applying a filter to images.
  • Creating a background video covering an entire section.
  • Using the <video> HTML element.
  • Using the object-fit property.

22. Building a Booking Section

23. Building a Beautiful Navigation

  • The "checkbox hack."
  • Custom animation timing functions that use cubic bezier curves.
  • Animating "solid-color gradients."
  • Using transform-origin.
  • Creating an amaizingly creative effect!

24. Building a Pure CSS Popup

  • Using the :target pseudo-class to select elements based on the current URL's fragment.
  • Creating boxes with equal height using display: table-cell.
  • Creating CSS text columns.
  • Using hyphens to automatically hyphenate words.

natours's People

Stargazers

Daniel Giger avatar

Watchers

Victor Espaillat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.