Giter VIP home page Giter VIP logo

website's Introduction

Website

How to make a website from scratch?

Dealing with files

  • Homepage content file: index.html
  • Media folder: images
  • CSS folder: styles
  • JavaScript folder: scripts

Layout Draft

  • header
  • nav
  • aside
  • main
  • footer

Link CSS

  • Add a new main.css file inside the styles folder.
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 62.5%;
    font-family: Arial, Helvetica, sans-serif;
}
  • Link the main.css file to the index.html file.
<!DOCTYPE html>
<html lang="en">
<head>
    ...
๐Ÿ‘‰๐Ÿฝ  <link rel="stylesheet" href="./styles/main.css">
</head>
<body>...</body>
</html>

Header

Header content

  • Add an <h1></h1> heading tag, and a <p></p> paragraph tag inside the <header></header> container.
<!DOCTYPE html>
<html lang="en">
<head>...
</head>
<body>
โŒ <header></header>
    <header>
๐Ÿ‘‰๐Ÿฝ      <h1>Website</h1>
๐Ÿ‘‰๐Ÿฝ      <p>How to make a Website</p>
    </header>
    ...
</body>
</html>

Header styles

  • Add the basic selector header to the main.css file.
* {...
}

html {...
}

header {... ๐Ÿ‘ˆ๐Ÿฝ
}

Header

  • Let's add the CSS declaration display: flex;, which transform the header element as a container and its childs h1, p as a flex items.
...

header {
    display: flex; ๐Ÿ‘ˆ๐Ÿฝ
}

Header - display: flex

  • Now, let's define the flex-direction property as column.
...

header {
    display: flex;
    flex-direction: column; ๐Ÿ‘ˆ๐Ÿฝ
}

Header - flex-direction: column

  • Define the height property of the container.
...

header {
    display: flex;
    flex-direction: column;
    height: 320px; ๐Ÿ‘ˆ๐Ÿฝ
}

Header - height

  • Align items around the center using the CSS declaration justify-content: center;.
...

header {
    display: flex;
    flex-direction: column;
    height: 320px;
    justify-content: center; ๐Ÿ‘ˆ๐Ÿฝ
}

Header - justify-content: center

  • Set the position property as relative, and align the text to the center using the CSS declaration text-align: center;.
...

header {
    display: flex;
    flex-direction: column;
    height: 320px;
    justify-content: center;
    position: relative; ๐Ÿ‘ˆ๐Ÿฝ
    text-align: center; ๐Ÿ‘ˆ๐Ÿฝ
}

Header . position & text-align

  • As last step with the container styles let's define the background and the text color using hexadecimal values.
...

header {
    background: #1abc9c; ๐Ÿ‘ˆ๐Ÿฝ
    color: #ffffff; ๐Ÿ‘ˆ๐Ÿฝ
    display: flex;
    flex-direction: column;
    height: 320px;
    justify-content: center;
    position: relative;
    text-align: center;
}

Header - background & color

  • By setting the font-size as 62.5% for the html, allow us to set specific element font-size and line-height in rem units easily.
...

header {...
}

header h1 {
    font-size: 3.2rem; ๐Ÿ‘ˆ๐Ÿฝ
    line-height: 3.4rem; ๐Ÿ‘ˆ๐Ÿฝ
}

header p {
    font-size: 1.8rem; ๐Ÿ‘ˆ๐Ÿฝ
    line-height: 2.2rem; ๐Ÿ‘ˆ๐Ÿฝ
}

Header - font-size & line-height

Link CSS with the media attribute

  • Add a new desktop.css file inside the styles folder.
header h1 {
    font-size: 4.8rem;
    line-height: 5rem;
}

header p {
    font-size: 3.4rem;
    line-height: 3.8rem;
}
  • Link the desktop.css file to the index.html.
<!DOCTYPE html>
<html lang="en">
<head>
    ...
๐Ÿ‘‰๐Ÿฝ  <link rel="stylesheet" href="./styles/desktop.css">
</head>
<body>...
</body>
</html>
  • Add the media attribute to the link tag.
<!DOCTYPE html>
<html lang="en">
<head>
    ...
    <link rel="stylesheet" href="./styles/desktop.css" media="screen and (min-width: 768px)">
</head>
<body>...
</body>
</html>
  • By setting the values screen and min-width: 768px means the styles inside the desktop.css file will apply only if the screen width is equal or bigger than 768 pixels.

Header - Desktop: font-size

CSS custom properties

  • Define custom properties at the top of the main.css file using the :root pseudo-class.
:root {
    /* Colors */
    --mountain-meadow: #1abc9c;
    --white: #ffffff;
}

...
  • Then replace the direct use of the hexadecimal values in both the background and color properties at the header selector by using the custom properties defined above.
...

header {
    background: #1abc9c; โŒ
    color: #ffffff; โŒ
    background: var(--mountain-meadow); ๐Ÿ‘ˆ๐Ÿฝ
    color: var(--white); ๐Ÿ‘ˆ๐Ÿฝ
    ...
}

...

website's People

Contributors

tadeobarranco avatar

Watchers

 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.