Figma To Real Website | Responsive Homepage | HTML, CSS & JavaScript | Part 4

GTCoding
15 Dec 202128:33

Summary

TLDRThis tutorial series guides viewers through converting a design into a functional website using HTML, CSS, and JavaScript. The script focuses on styling the header section, setting box-sizing, and customizing buttons with different colors and icons. It also covers positioning elements, styling the navigation bar, and adjusting the hero section with images and achievement cards. The instructor emphasizes responsive design adjustments and provides step-by-step CSS implementation.

Takeaways

  • 🌐 The tutorial series focuses on converting a sigma design into a functional website using HTML, CSS, and JavaScript.
  • πŸ“ The previous video covered HTML structure creation, while the current video is about styling with CSS.
  • πŸ”§ The initial step in CSS is setting the box-sizing to border-box for all elements to simplify width and height calculations with padding and borders.
  • 🎨 Custom color variables are created for consistent theming throughout the site.
  • πŸ”² The default margin and font settings are reset for the body to establish a clean styling foundation.
  • πŸ”„ A systematic approach is used to style elements such as buttons, using properties from a design tool (Figma) to match the design accurately.
  • πŸ”„πŸ”„ Buttons are differentiated into 'dark' and 'light' variants, each with specific background colors pulled from predefined variables.
  • πŸ–±οΈ CSS pseudo-selectors are utilized to add icons to buttons and position them appropriately within the button elements.
  • πŸ“ The 'wrapper' class is used to constrain the width of page content and center it horizontally.
  • 🏠 Header elements, including the logo and navigation menu, are styled to match the design, with considerations for layout and typography.
  • 🌟 The hero section of the website is styled with flexbox to arrange content effectively, paying attention to height, alignment, and spacing.
  • πŸ“Š Achievement cards are initially hidden and will be styled later, indicating a phased approach to development and styling.
  • πŸ–ΌοΈ Image elements within the hero section are adjusted for visual balance, considering browser UI elements like the address bar and tabs.
  • ✨ Z-index is used to layer elements, ensuring that certain components like the navigation menu stay above others when scrolling.

Q & A

  • What is the main focus of the tutorial series mentioned in the script?

    -The main focus of the tutorial series is to convert a sigma design into a real website using HTML, CSS, and JavaScript.

  • What was covered in the previous video of the series?

    -In the previous video, the tutorial covered how to write the HTML for the design.

  • What is the first CSS property discussed in the video?

    -The first CSS property discussed is 'box-sizing', set to 'border-box' for all elements to include padding and border in the element's width and height.

  • Why is the 'box-sizing: border-box' property useful?

    -The 'box-sizing: border-box' property is useful because it simplifies layout modeling by including padding and border widths in the element's total width and height, eliminating the need for extra calculations.

  • What default margin and padding are removed from the body element in the CSS?

    -The default margin is set to zero, and the body's padding is not explicitly mentioned but is typically reset to zero as well in CSS.

  • What is the purpose of setting the 'font-family' to 'Poppins, sans-serif'?

    -Setting the 'font-family' to 'Poppins, sans-serif' establishes a default font for the website, enhancing consistency in text appearance and providing a fallback font if 'Poppins' is not available.

  • How are the buttons in the video styled?

    -The buttons are styled by setting common properties like padding, border-radius, text color, and display type. Additionally, specific styles for 'btn.dark' and 'btn.light' classes are applied to differentiate the button colors.

  • What is the significance of using the ':before' pseudo-element in the 'enroll' button?

    -The ':before' pseudo-element is used to insert an icon (enroll icon) into the 'enroll' button without altering the HTML structure, providing a way to add decorative content.

  • How is the 'wrapper' class used in the video?

    -The 'wrapper' class is used to set a maximum width for the content and center it horizontally, ensuring that the layout is contained and balanced.

  • What is the purpose of setting the 'position' property of the 'nav' element to 'fixed'?

    -Setting the 'position' property of the 'nav' element to 'fixed' makes the navigation bar stay in the same place even when the page is scrolled, improving the user experience by keeping the navigation accessible.

  • How are the 'achievement cards' initially handled in the video?

    -The 'achievement cards' are initially set to 'display: none' in the CSS, meaning they are hidden from view until they are styled and ready to be displayed.

  • What is the method used to vertically center the 'icon' in the button?

    -The method used to vertically center the icon involves setting the button's position to 'relative' and the icon's position to 'absolute', then using 'transform: translateY' to adjust the icon's vertical position.

  • How is the 'hero section' of the website styled in the video?

    -The 'hero section' is styled using flexbox to arrange child elements side by side, setting a 100% height to fill the viewport, and using 'align-items' and 'justify-content' to center and space the elements appropriately.

  • What adjustments are made to the image in the 'hero section'?

    -The image's height is adjusted to fit the browser window, which may be smaller than the full screen height due to the address bar and other UI elements. The image is also positioned at the bottom using 'align-self: flex-end' and 'vertical-align: middle'.

  • How are the 'achievement cards' positioned relative to the 'hero section'?

    -The 'achievement cards' are positioned absolutely relative to the 'hero section', with specific 'left' and 'top' values to place them in the desired locations on the page.

  • What is the final step mentioned in the video for styling the 'achievement cards'?

    -The final step mentioned is adjusting the positioning, minimum width, and potentially other styles of the 'achievement cards' to ensure they are displayed correctly and aesthetically on the page.

Outlines

00:00

🎨 CSS Styling Introduction

This paragraph introduces the process of converting a design into a functional website using HTML, CSS, and JavaScript. The focus is on beginning CSS styling, starting with the header section. The speaker discusses setting up box sizing, adjusting body margins, and setting the font family to Poppins. They also cover styling buttons with different classes, using Figma to inspect properties and copy necessary CSS values such as padding, border radius, and text color. The paragraph concludes with the basic styling of buttons, including removing underlines and setting display properties.

05:02

πŸ”¨ Advanced Button and Icon Styling

The speaker continues with advanced button styling, including adding icons to buttons using the ':before' pseudo-element and positioning them centrally. They explain how to adjust the position of the icon and text within the button by using absolute positioning and transformations. The paragraph also covers styling the wrapper element with a maximum width and centering it horizontally. The speaker then moves on to styling the header element, setting its background color, height, and width, and ensuring it covers the full browser window height.

10:02

πŸ“˜ Nav Element Styling and Logo Properties

This section delves into styling the navigation (nav) element, including aligning the logo and menu items using flexbox properties. The speaker details how to style the logo with specific font properties and colors, and how to adjust the list items within the nav element for a uniform appearance. They also discuss removing default margins and bullets from the menu items, setting text decoration to none, and ensuring the nav element remains fixed during scrolling with a higher z-index for visibility above other elements.

15:03

πŸ† Hero Section and Image Positioning

The speaker begins styling the hero section of the website, setting up the layout with flexbox to position elements side by side and vertically centered. They address the need to adjust the height of the hero section's image to accommodate the browser's address bar and other UI elements. The paragraph also covers the process of positioning the image at the bottom of the hero section and aligning it vertically in the center, using properties such as 'align-self' and 'vertical-align'.

20:04

πŸŽ–οΈ Achievement Cards and Absolute Positioning

The paragraph discusses the styling of achievement cards, which are positioned absolutely within the hero section. The speaker describes setting the position, background color, border radius, padding, and other styles for the achievement cards. They also detail the process of positioning each card at specific coordinates and adjusting the styling of headings and paragraphs within the cards. The paragraph concludes with adding a background rectangle with a linear gradient to the achievement cards and adjusting z-index values for proper layering.

25:06

🌟 Final Touches on Achievement Cards and Hero Section

In the final paragraph, the speaker makes final adjustments to the positioning and styling of the achievement cards, ensuring they are correctly aligned and spaced. They address issues with centering text and adjust the layout of the star image within the cards. The speaker also talks about setting minimum widths for the cards and making sure all elements are visible and styled as intended. The video concludes with a reminder for viewers to ask questions, like, and subscribe for updates.

Mindmap

Keywords

πŸ’‘HTML

HTML, or HyperText Markup Language, is the standard language for creating web pages and web applications. In the video, HTML is used as the foundational structure of the website being developed. The script mentions writing the HTML of the design, which involves creating elements and sections that will later be styled with CSS and made interactive with JavaScript.

πŸ’‘CSS

CSS, or Cascading Style Sheets, is a stylesheet language used for describing the presentation of a document written in HTML or XML. The video's theme revolves around styling a website using CSS. The script discusses setting up box-sizing, margins, font families, and various other properties to visually enhance the HTML elements, such as buttons, headers, and sections.

πŸ’‘JavaScript

JavaScript is a programming language that allows interactive web pages and is an essential part of web applications. Although not extensively covered in the script, JavaScript is mentioned as one of the technologies used alongside HTML and CSS to convert a design into a functional website.

πŸ’‘Box-sizing

The box-sizing property in CSS is used to alter the default CSS box model, allowing for more control over element sizing in layout designs. In the script, setting box-sizing to 'border-box' for all elements ensures that padding and border are included within the element's specified width and height, simplifying layout calculations.

πŸ’‘Flexbox

Flexbox is a layout mode in CSS that provides an efficient way to distribute space among items in a container, even when their size is unknown or dynamic. The script describes using Flexbox to align elements in the navigation bar and the hero section, enabling a responsive and adaptable design.

πŸ’‘Poppins Font

Poppins is a geometric sans-serif typeface that is mentioned in the script as the default font family for the website's body. It is chosen for its modern and clean appearance, which contributes to the overall aesthetic of the site being styled.

πŸ’‘Button Styling

Button styling in the script refers to the CSS properties applied to the buttons on the website, including padding, border-radius, text color, and background color. The video discusses creating visually appealing and functional buttons with different styles for light and dark themes.

πŸ’‘SVG Icon

SVG, or Scalable Vector Graphics, is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation. The script mentions adding an SVG icon to a button using the CSS 'before' pseudo-element, enhancing the button's visual appeal and functionality.

πŸ’‘Linear Gradient

A linear gradient in CSS is a type of gradient that transitions colors along a straight line. The script describes applying a linear gradient as a background to the header element, creating a smooth transition between two colors and adding visual depth to the design.

πŸ’‘Z-index

The z-index property in CSS controls the stack order of an element, which determines which element appears on top when elements overlap. In the script, z-index is used to ensure that the navigation bar remains above other elements when scrolling, maintaining its visibility.

πŸ’‘Media Query

Media queries are CSS techniques used to apply different style rules for different devices based on characteristics such as screen size, resolution, or orientation. Although not explicitly mentioned in the script, the concept of adjusting styles for different viewport sizes is implied in the discussion of responsive design.

Highlights

Introduction to the tutorial series on converting a design into a website using HTML, CSS, and JavaScript.

Explanation of setting box-sizing to border-box for all elements to simplify width and height calculations.

Removing default margin from the body and setting the default font-family to Poppins.

Styling buttons with different classes 'btn', 'dark', and 'light', including padding, border-radius, and text color.

Using Figma to inspect and copy CSS properties for accurate styling.

Handling inline elements' padding and margin issues by setting display to inline-block.

Styling the navigation bar with flex properties to align logo and menu items.

Setting the background color and height for the header element using CSS.

Styling the logo with specific font properties and removing default list styles from navigation menu items.

Adding padding, margin, and display properties to style the hero section's layout.

Using comments in CSS to organize and separate sections of code for better maintainability.

Styling the achievement cards with absolute positioning and setting background properties.

Adjusting the hero section's image height to fit the browser window size.

Aligning the achievement cards' content using flex properties and adjusting their positions.

Adding z-index to layer elements properly and ensure the navigation bar stays on top.

Final adjustments to the hero section's layout and styling to achieve the desired design.

Encouraging viewers to ask questions in the comments and subscribe for updates.

Transcripts

play00:00

hi everybody welcome to gt coding in

play00:01

this tutorial series we are converting

play00:03

this sigma design into a real website

play00:05

using html css and javascript now in the

play00:08

previous video i showed you how to write

play00:09

the html of our design now in this video

play00:12

we will start writing the css so we will

play00:14

style this header section in this video

play00:16

let's get started

play00:17

[Music]

play00:23

all right this is our progress as of now

play00:24

we can see that we have written the html

play00:26

of our website

play00:27

and

play00:29

we have also linked our css file over

play00:31

here

play00:32

so let's go to our style.css file and

play00:34

let's start styling this now we already

play00:36

created some variables for the colors

play00:39

now the first thing we will do is that

play00:41

we will set the box sizing to border box

play00:44

for all the elements so just tap

play00:46

asterisk to select all the elements and

play00:48

i'll also select the after and the

play00:49

before selectors

play00:51

so just type asterisk column column

play00:53

after

play00:54

and asterisk column current before

play00:57

and here we just type box sizing and set

play00:59

it to border box

play01:01

now when you add this line of chord box

play01:02

sizing border box it will include the

play01:04

padding and the border of the element

play01:06

inside the width and the height of the

play01:08

element so we won't have to calculate

play01:10

the width and the height of the element

play01:11

after the padding and the border is

play01:13

added right now let's remove the default

play01:15

margin that we have in the body so i'll

play01:17

just type body

play01:18

and i'll set the margin to zero

play01:21

and by default we will set the font

play01:23

family to

play01:24

pop-ins so i'll just have poppins

play01:28

and sans serif

play01:30

now let's go to our design

play01:32

and here you can see the font has

play01:33

changed and also we don't have any

play01:35

margin for the body right now the next

play01:37

thing we will do is style these buttons

play01:40

so let's go back to our css and

play01:42

here we'll just add the selector of the

play01:44

button

play01:45

so if you go to the html we can see that

play01:47

for the button we have a class of btn

play01:50

and we have two types of buttons we have

play01:52

a dark button with a class of dark

play01:54

and we also have a light button with a

play01:57

class of light

play01:58

so here we can see we have the light

play02:00

button

play02:01

so let's target the btn class so let's

play02:04

type dot btn

play02:06

right now let's go to our figma file

play02:08

and let's double click on this button

play02:11

and here we can see the properties of

play02:12

the button so if you go over here to

play02:14

this tab called inspect

play02:16

and if we scroll down we can see that we

play02:18

have the css displayed over here

play02:20

so let's copy some of the css that we

play02:22

need so what we need from this are the

play02:25

padding and the border radius so you can

play02:27

just copy this from here or i'll just go

play02:28

back to our css and i'll just type it

play02:30

over here so i just have padding and we

play02:32

have a padding of 16 pixels and 32

play02:34

pixels so this type 16

play02:37

and 32 and we have a border radius of 24

play02:40

pixels so i just have border ranges

play02:42

24 pixels

play02:44

and for the button we have a text color

play02:46

of white

play02:48

so let's set the text color to white

play02:52

now this button is basically an anchor

play02:54

tag so here we can see this is an anchor

play02:55

tag

play02:56

now anchor tags are inline elements by

play02:59

default now when you have an inline

play03:00

element there can be problems with the

play03:02

padding and the margin of the element

play03:04

so i'll just set the display to inline

play03:06

block

play03:07

and let's go back to our figma file and

play03:08

if we double click over here in this

play03:10

text

play03:11

we can see that the properties of the

play03:13

text are displayed over here

play03:15

so we have the font size set to 18

play03:17

pixels we have the font weight set to

play03:19

bold so let's copy these

play03:22

and let's paste it over here

play03:25

now the next thing we will do is we will

play03:26

style the dark and the light buttons so

play03:28

for the light button we need to have an

play03:30

orange color

play03:32

so here we can see this is the light

play03:33

button and for the dark button we need

play03:35

to have this dark blue color

play03:38

so let's go back

play03:39

and here we just type btn.dark

play03:43

and make sure that you don't have any

play03:44

space between these two classes because

play03:46

we're gonna have these two classes in

play03:48

the same element

play03:49

let's set the background color of this

play03:51

button to a variable that we created so

play03:54

if we scroll up we can see that we have

play03:55

created this variable called dark blue

play03:57

color so we're gonna add this color to

play03:59

the button so here i'll just tab var

play04:02

and here let's tap dark blue color

play04:05

and for the light button let's add the

play04:07

orange color so i'll just type btn.light

play04:10

and for the orange color we have a

play04:12

variable called orange color

play04:14

so let's add this over here so let's

play04:16

type background

play04:17

and var

play04:19

orange color

play04:20

right now let's go to chrome and let's

play04:22

see how it looks

play04:23

so here we can see we have the buttons

play04:25

and the colors are being displayed over

play04:27

here now we also want to remove these

play04:29

underlines from the buttons

play04:31

so here i'll just type

play04:33

text decoration and set it to

play04:35

none

play04:37

now the next thing we will do is we need

play04:38

to add an icon for this button so if you

play04:40

go back to our figma file we can see

play04:42

that for this button we have this icon

play04:45

so for that let's go to our code and

play04:47

let's go to the html

play04:49

and let's go to the button

play04:51

so this is the button enroll now now

play04:53

here in this button i'll just add a

play04:54

class called enroll icon

play04:57

and let's save this and let's go back to

play04:59

our style.css file

play05:01

and now let's style the enroll icon

play05:04

button

play05:05

so let's type btn

play05:07

dot enroll icon

play05:11

and we're going to use a before selector

play05:13

for adding the icon so i'll just type

play05:14

colon colon before

play05:17

and here i'll just type content and here

play05:20

in the content i'll just add the link of

play05:22

the unroll icon

play05:23

so here in the images we have this

play05:26

svg called enroll icon dot svg so just

play05:29

type url and here i'll just provide the

play05:32

link so just type images forward slash

play05:34

enroll now icon dot

play05:37

and now if you go back to our chrome

play05:39

we can see that the icon is displayed

play05:41

over here now we want this icon to be

play05:43

displayed in the center vertically so

play05:45

for that let's position this before

play05:46

selector

play05:47

relative to this button

play05:50

so for that let's go back to our button

play05:51

and here i'll just tap position

play05:53

relative

play05:55

and here for the before selector let's

play05:58

set the position to absolute

play06:00

now this before selector will be

play06:02

positioned relative to this button

play06:04

right now let's set the top position to

play06:06

50

play06:08

and let's say the left position to 32

play06:11

pixels

play06:12

and now if we go back to our chrome

play06:15

we can see that the icon starts from the

play06:17

50 mark

play06:19

so we also have to move it 50 of itself

play06:22

to the top

play06:23

so let's tap transform

play06:25

translate y and set it to negative 50

play06:29

and now we can see that the icon and the

play06:30

text are in the same place so let's add

play06:33

some padding left to this button so

play06:34

let's go back

play06:36

and here i'll just type

play06:38

btn.enroll

play06:40

icon

play06:41

and let's set the padding left to

play06:44

60 pixels

play06:46

and now we can see that it looks all

play06:48

right all right that's it with the

play06:49

button

play06:50

so everywhere we can see that the button

play06:52

is being styled

play06:56

so here i'll just add a comment and just

play06:59

tab

play07:00

buttons and now the next thing we will

play07:02

do is we will style the wrapper so if

play07:05

you go back to our html we can see that

play07:07

we have added this division with the

play07:08

class of wrapper now we are using this

play07:11

to add a maximum width to our elements

play07:13

so if we go back to our figma file we

play07:16

can see that we have a maximum width set

play07:18

for the contents of this header so i'll

play07:21

just double click over here

play07:22

and here on the right we can see we have

play07:24

a width of 1134 pixels

play07:27

so this is going to be the max width of

play07:29

our wrapper so let's go back

play07:32

and let's go to our style.css file

play07:34

and i'll just add the styles for the

play07:36

wrapper over here just after the body so

play07:38

i just tap dot wrapper

play07:40

and let's set a max width of

play07:44

1134 pixels

play07:46

and we also need to bring it to the

play07:48

center so i'll start margin 0 for top

play07:50

and bottom

play07:51

and auto for left and right now if you

play07:53

go back to our chrome we can see that we

play07:55

have a max width let's add a background

play07:57

color and

play07:58

let's see whether it is being applied

play08:01

so here we can see we have a max width

play08:03

of 1134 pixels and also the wrapper is

play08:06

in the center so let's go back and let's

play08:08

remove this background color

play08:10

all right now the next thing we will

play08:11

style is the header element so if you go

play08:13

back to our html we can see that we have

play08:15

created this header element over here

play08:18

so let's go over here to our style.css

play08:20

file

play08:21

and here i'll just add a comment so

play08:23

let's type header

play08:24

and here we just type header

play08:27

and let's go back to our figma file

play08:30

and first of all let's select this

play08:31

background rectangle

play08:33

and if we go over here to inspect and

play08:35

scroll down

play08:36

we can see that the css is displayed

play08:38

over here so i'll just copy this

play08:39

background color

play08:42

so just copy it from here so let's go

play08:44

back to our css and i'll just paste it

play08:45

over here

play08:46

and we need to set the height of this

play08:48

header to 100 report height which is 100

play08:52

width of the browser window

play08:54

and let's set the width to 100 percent

play08:56

right now let's go back to our website

play08:58

and here we can see we have this linear

play09:00

gradient background color added all

play09:02

right now the next thing we will do is

play09:04

style this nav so if we go back to our

play09:06

html we can see that we have created

play09:08

this nav element

play09:10

and in that we have the logo and the ul

play09:12

for the menu items so let's go back to

play09:14

our style.css file and let's

play09:17

style the nav so i'll just type nav

play09:20

now we want the elements of the nav to

play09:22

be displayed one next to the other

play09:24

so right now we can see that the logo is

play09:26

at the top and we have the menu items at

play09:27

the bottom now we want the logo to be on

play09:29

the left and the menu items to be on the

play09:31

right

play09:33

so here we just set the display to flex

play09:36

and justify content to space between

play09:41

so now if you go back to our design we

play09:43

can see that the logo is at the left and

play09:45

we have all these menu items at the

play09:47

right

play09:48

now the next thing we will do is style

play09:49

this logo so let's go back

play09:52

and for the logo we have a class of logo

play09:56

so let's style this

play09:58

so just type

play09:59

nav

play10:00

logo

play10:02

and let's go to our sigma file and let's

play10:03

see what are the properties so let's

play10:04

double click over here in the logo

play10:06

and if you go to inspect and scroll down

play10:09

we can see these are the properties for

play10:10

the logo so we need to set the color to

play10:13

white we need to set the font size to 40

play10:15

and the font weight to 900 and also the

play10:17

font family to railway so i'll just copy

play10:20

all of this from here

play10:21

and let's go back to our css

play10:24

and i'll just paste it over here

play10:26

now here for the railway we'll also add

play10:28

a backup font so here i'll just type

play10:31

send serif

play10:33

and we don't need to have this font

play10:34

style so i'll just delete this line of

play10:36

code

play10:37

and we also don't need to have this line

play10:39

height so i'll just delete this and also

play10:41

this comment

play10:42

all right let's go back to our chrome

play10:45

and here we can see that the logo is

play10:47

styled correctly now the next thing we

play10:48

will do is style these

play10:51

list items inside the ul now we want all

play10:53

these menu items to be displayed one

play10:55

next to the other so for that let's go

play10:57

back to our css and let's target the

play10:59

unordered list inside the nav so here we

play11:01

can see

play11:02

we have this ul inside the nav

play11:06

so here i'll just tap nav ul

play11:09

and let's set the display to flex so

play11:11

that the elements will be one next to

play11:12

the other now we need to align them to

play11:15

the center so i just have align items to

play11:16

the center

play11:17

and let's go back to our figma file and

play11:19

let's see what is the spacing that we

play11:21

need to have

play11:22

so let's double click over here and here

play11:25

we can see we have a spacing of 60

play11:27

pixels

play11:28

so let's go back to our css

play11:32

and here i'll just type

play11:34

gap and set it to 60 pixels

play11:38

now if you go back to our

play11:40

chrome we can see we have these menu

play11:42

items displayed over here and we'll also

play11:44

remove these bullets from here so let's

play11:45

go back

play11:47

and let's type list style and set it to

play11:50

none

play11:51

now the next thing we will do is style

play11:53

these menu items

play11:55

so let's go back

play11:57

and for the menu items we have anchor

play12:00

tags

play12:01

so here we'll just type nav

play12:03

uli a

play12:05

and let's go back to our figma file

play12:08

and

play12:09

let's double click over here and

play12:11

here we can see in the inspect we have

play12:12

the css

play12:14

so let's copy some of this from here

play12:17

i'll just copy everything and we'll just

play12:18

delete

play12:19

things that we don't want

play12:21

let's go back to our css and i'll just

play12:22

paste it over here

play12:25

and we don't need to have the line

play12:26

height

play12:28

and we also don't need to have

play12:31

the font style

play12:33

and here for pop-ins we will add a

play12:34

fallback font

play12:36

so just type sensorif

play12:38

and we also need to remove these

play12:40

underlines so i'll just type text

play12:42

decoration

play12:43

and set it to none

play12:45

now here we can see for the ul we have

play12:47

some default margin at the top

play12:50

so let's go back to our css and let's go

play12:52

to the ul and here i'll just type margin

play12:55

and set it to zero

play12:56

and now we can see we don't have any

play12:58

margins

play12:59

and we'll also center align this logo

play13:01

vertically so let's go back and

play13:04

let's go to the nav

play13:06

and here let's type align items to the

play13:08

center

play13:09

and now we can see everything looks all

play13:11

right now the next thing we will do is

play13:13

we will set this uh

play13:15

nav element to fixed

play13:17

so when we scroll up or down it should

play13:19

always be positioned at the same place

play13:21

so for that let's go back and here i'll

play13:23

just type

play13:25

position and set it to fixed

play13:29

and now we can see that the width has

play13:30

changed so for that we have to set the

play13:33

width back to

play13:34

1134 pixels and from the top we will

play13:37

have a spacing of let's say

play13:40

36 pixels so just up top

play13:43

36 pixels

play13:47

all right now we can see when we scroll

play13:48

down the nav element stays there

play13:51

and we'll also set the z index of the

play13:53

nav to something higher because we can

play13:55

see when we scroll down the nav is below

play13:58

the other elements

play13:59

so let's set as the index so i'll just

play14:01

type z index

play14:04

and let's set it to

play14:06

100

play14:07

and now we can see it is above all the

play14:08

other elements

play14:12

right now let's start styling this hero

play14:14

section so let's go back to our

play14:16

vs code

play14:17

and let's create a comment so just type

play14:21

hero section

play14:24

and

play14:25

let's go back to our index.html file and

play14:27

for the hero section we have a division

play14:29

with the class of heroes section

play14:31

so here we'll just type hero section

play14:36

and let's set the display to flex so

play14:38

that the elements will be one next to

play14:40

the other so we want the left division

play14:41

to be on the left and the right to be on

play14:43

the right

play14:44

and we'll also set the height to 100

play14:47

report height

play14:49

and the width to 100 percent

play14:52

and we'll also bring it to the center

play14:54

vertically so i'll just type align items

play14:55

to the center and we'll also type

play14:57

justify content to space between so that

play15:01

both the left and right divisions are on

play15:02

the extreme left and right now let's go

play15:04

back to chrome

play15:06

and here we can see our elements are

play15:08

displayed over here for now we'll just

play15:10

hide these achievement cards so let's go

play15:12

back

play15:13

and for the achievement cards we have

play15:15

a class

play15:17

of achievement cards

play15:19

so let's target this here let's type

play15:23

achievement cards and here let's type

play15:25

achievement cards

play15:29

and let's set the display to none

play15:31

we will style it later right now let's

play15:33

style this heading

play15:34

so here i'll just type

play15:37

hero section

play15:38

and for the left part we have a division

play15:40

with a class of

play15:42

left so let's target that i'll just type

play15:44

left

play15:45

and in that we have the h1 for the

play15:47

heading

play15:48

so let's tap h1

play15:50

right now let's go to our figma file

play15:53

and let's double click over here on this

play15:56

heading

play15:57

and let's go to inspect and scroll down

play16:01

and here we can see the css for the

play16:03

heading so let's copy all of this

play16:05

and let's paste it over here in the css

play16:09

and let's remove this font style

play16:12

and let's also remove this comment and

play16:15

here we'll also add sensative so i'll

play16:17

just type

play16:19

comma and add sans serif over here let's

play16:22

go back to our design

play16:24

and here we can see this is how our

play16:25

heading looks we'll also remove the

play16:27

margin bottom from here

play16:29

so here i'll just type

play16:32

margin

play16:33

bottom and let's set it to zero

play16:36

right now the next thing we will do is

play16:38

style this paragraph so let's go back to

play16:41

our figma file

play16:43

and

play16:44

for the paragraph we have

play16:46

these styles over here

play16:47

so let's copy all of this

play16:49

and let's go back and let's go to our vs

play16:52

code and here we just type hero section

play16:57

left p

play17:00

and let's paste the css over here

play17:02

and i'll just add sign serif over here

play17:06

and i'll just remove this font style

play17:09

and

play17:10

we'll also set the color of the text to

play17:13

white

play17:14

now the next thing we will do is we will

play17:16

set a fixed width for this left division

play17:19

so if you go back to our figma file

play17:21

we can see we have a width of

play17:24

here we can see 457 pixels and even for

play17:27

the heading we have 457 pixels of width

play17:30

so let's go back and let's add a width

play17:33

to the left division

play17:34

so here let's type hero section

play17:37

left

play17:38

and

play17:39

let's set the width to 457 pixels

play17:45

right now let's add some margin between

play17:46

this button and this paragraph so here

play17:49

for this paragraph i'll just type margin

play17:50

bottom

play17:52

and we'll just set it to 30 pixels

play17:55

and i feel that the font size of these

play17:57

buttons are a bit too large

play17:59

so let's go to our vs code

play18:01

and let's go to the styles for the

play18:02

button

play18:04

and let's set the font size to 16 pixels

play18:09

let's go back

play18:10

i think this looks alright

play18:12

now we'll also add a little bit of

play18:14

padding top for this hero section

play18:16

because we have this navigation menu

play18:18

over here so that's why this content

play18:20

doesn't look like it is in the center so

play18:22

let's go back and for the hero section

play18:25

let's add a padding top

play18:29

and let's set it to

play18:31

let's try 60 pixels

play18:34

i think that looks alright

play18:36

right now let's style this image so

play18:37

let's go back to our figma file

play18:40

and for the image we have a height of

play18:44

582 pixels so

play18:46

let's add this and let's see how it

play18:48

looks so let's copy this from here and

play18:51

let's go to our vs code and

play18:53

here in the html we can see for the

play18:55

image we simply have an image inside the

play18:57

right division

play18:59

so here i'll just type hero section

play19:02

right img and let's paste the height

play19:04

over here

play19:06

let's go back to our chrome and i think

play19:08

we need to decrease the height a little

play19:09

bit because in the browser we also have

play19:11

this address bar we also have this tab

play19:13

and all of this take up some space so we

play19:16

don't have the full height of the screen

play19:18

now in our figma file we had designed it

play19:20

with the full height and width of the

play19:22

screen in mind so we have to make some

play19:24

changes to the height of the elements in

play19:27

the real website so let's go back and

play19:29

let's change the height to

play19:32

let's try 520 pixels

play19:34

and i think that looks alright now the

play19:36

next thing we need to do is we need to

play19:37

position this image at the bottom so

play19:39

right now it is at the center

play19:41

so let's go back and let's target the

play19:44

right division

play19:45

so here just type hero section right

play19:48

and here we need to type align self

play19:51

so it will align itself

play19:53

and you need to type flex end which will

play19:56

align itself to the end

play19:58

and we can see we still have a little

play20:00

bit of gap over here

play20:01

at the bottom so for that we have to go

play20:03

over here to the image and we have to

play20:05

add a line of code which is

play20:08

vertical align

play20:09

and set it to middle

play20:11

and now we can see everything looks

play20:12

alright right now the next thing we will

play20:14

do is style the achievement cards so

play20:16

let's go back and

play20:18

let's remove this line of code and we

play20:21

need to position these achievement cards

play20:23

relative to the hero section now we need

play20:25

to set the position of the achievement

play20:27

card to absolute so if you go back to

play20:30

our html

play20:31

we can see for the achievement card we

play20:33

have this division of the class of

play20:34

achievement card so let's style that

play20:37

here i'll just type achievement card

play20:41

and i think we can delete this for now

play20:43

all right for the achievement card we

play20:44

will set the position to absolute now in

play20:47

the achievement card we have this

play20:48

division with the class of content

play20:50

so in the content we have this heading

play20:53

and this paragraph

play20:54

so let's style the content

play20:56

so here i'll just tab achievement card

play20:59

content

play21:00

and let's go back to our figma file and

play21:02

here we can see for the background color

play21:04

we have a white color

play21:06

and we also have a border radius of 24

play21:09

pixels

play21:10

so let's add these tiles here let's type

play21:13

border radius

play21:14

24 pixels

play21:16

and background color of

play21:19

white

play21:21

we'll also add a padding of 8 pixels top

play21:23

and bottom and 32 pixels left and right

play21:26

here we can see our achievement card is

play21:27

displayed over here on the right now

play21:29

let's position these achievement cards

play21:31

over here on the left so here for the

play21:33

first one we have a class of students

play21:36

enrolled so let's target that i'll just

play21:38

type achievement card

play21:41

dot students enrolled

play21:45

and we'll set the left position to 47

play21:48

and we'll set the top position to

play21:50

330 pixels

play21:52

and here we can see the students

play21:54

enrolled achievement card is displayed

play21:56

over here now let's style the heading of

play21:58

this achievement card so here let's type

play22:01

achievement card and for the heading we

play22:03

have an s3 so let's tap s3

play22:07

and for this let's go back and let's see

play22:10

what are the styles so let's double

play22:11

click over here and here in the inspect

play22:13

let's scroll down

play22:14

and let's

play22:16

copy these styles

play22:18

so let's copy all of this

play22:19

and let's go back and paste it over here

play22:23

and we'll just remove the font style and

play22:25

the line height and this comment and

play22:28

let's add sans serif over here

play22:32

and for the color we will change this to

play22:34

our variable so we have a variable

play22:36

called dark blue color so i'll just type

play22:38

var

play22:39

dark blue color

play22:41

and let's go back to chrome

play22:43

and we need to remove the margins so

play22:46

here just type margin

play22:48

0

play22:50

and we'll text align it to the center

play22:53

and now let's style this paragraph

play22:55

so we have a paragraph over here

play22:58

so let's type achievement card p

play23:01

and let's go back to our figma file

play23:03

and let's copy all of this

play23:06

and let's paste it over here and let's

play23:08

remove all of this the line height and

play23:10

the font style and we'll change this to

play23:14

sans serif

play23:16

and we'll change the color to

play23:19

the dark variable so var

play23:21

dark blue color

play23:23

we'll also decrease the margin top over

play23:25

here so we will add a negative margin

play23:28

so just tap margin top and let's set it

play23:30

to negative 8 pixels and for margin

play23:33

bottom we will have 8 pixels

play23:39

now let's style the background rectangle

play23:40

for this

play23:42

achievement card so if you go back to

play23:43

our figma file we can see we have this

play23:45

rectangle over here

play23:47

so let's go back and if you go back to

play23:48

our html for that we have a division

play23:51

with the class of bg

play23:52

so let's style that so here i'll just

play23:55

type achievement card bg

play23:58

now we need to position this relative to

play23:59

the achievement card so i'll just start

play24:01

position absolute

play24:03

and let's set the height and the width

play24:05

200 percent of the achievement card

play24:09

and we also need to have a linear

play24:11

gradient background

play24:12

so let's select this and

play24:14

let's copy this color and we'll also

play24:17

copy this border radius

play24:19

so let's copy these two lines of code

play24:21

and let's paste it over here

play24:23

and now we need to move this a little

play24:25

bit to the right and to the bottom so

play24:27

let's go back so here just tap top and

play24:29

i'll just set it to 8 pixels and left

play24:32

and i'll just set it to 8 pixels as well

play24:36

let's go back to chrome

play24:37

and we need to add some z index over

play24:39

here so for this background bg we will

play24:42

add a z index of 1

play24:45

and for the content

play24:48

i'll just add a z index of

play24:50

let's say 10

play24:52

and we'll also need to add a position

play24:54

over here so just a position relative

play24:58

because we have a position of absolute

play25:00

over here so we need to add some

play25:01

position over here for the z index to

play25:03

work and now we can see that it is being

play25:05

displayed correctly

play25:06

right now let's position this

play25:08

achievement card so

play25:10

for that we have a class of

play25:12

overall rating so i'll just type

play25:15

achievement card

play25:17

dot overall rating

play25:21

and let's set the left position to

play25:24

45 percent

play25:25

and

play25:26

i just set the top position to

play25:28

520 pixels let's see how it looks and we

play25:32

also need to style the star image so

play25:34

let's go back

play25:35

and in the html we can see that we have

play25:38

a division and in that we have the s3

play25:40

and the image

play25:41

so let's style this division so here

play25:43

i'll just type

play25:44

achievement card

play25:46

content

play25:47

div

play25:49

and we'll set the display to flex so

play25:50

that the elements will be one next to

play25:52

the other and we'll also align items to

play25:54

the center

play25:56

and we'll have a gap of 12 pixels

play26:00

and now we can see this

play26:01

heading is not in the center so let's

play26:03

right click over here and click on

play26:04

inspect

play26:05

and let's see what's the problem so

play26:07

here for the s3 we don't have the full

play26:10

width

play26:11

so let's add a width of 100 percent and

play26:14

let's see whether it works

play26:17

and we can see it works so let's do that

play26:20

let's go back

play26:22

to our

play26:23

vs code and here for the s3 i'll just

play26:26

type width of 100

play26:29

and now we need to move this image to

play26:30

the right a little bit

play26:32

so for that we will increase the width

play26:33

of the left division and

play26:35

let's go back and here we can see for

play26:37

the left division we had added a width

play26:40

of 457 pixels

play26:42

so i'll just remove this from here and

play26:44

let's add this to the paragraph and here

play26:46

for the left i'll just set the flex to

play26:48

one

play26:49

so that it takes up all the space that

play26:51

it can and now we can see it looks all

play26:53

right let's also reposition these two

play26:55

achievement cards so let's right click

play26:57

over here and click on inspect

play26:59

and let's play with the left and the top

play27:01

values

play27:02

so let's select the first achievement

play27:05

card and i think we can decrease the top

play27:07

value a little bit

play27:09

we can also increase the left value a

play27:11

little bit

play27:13

and i think this looks alright so let's

play27:15

copy these two lines of code and let's

play27:18

paste it in the students enrolled

play27:19

achievement card

play27:22

so it is right here

play27:24

and for the next one let's select it

play27:28

and let's decrease the top value

play27:31

i think this looks alright and let's

play27:34

increase the left value

play27:37

so i think this looks alright we'll also

play27:38

add some minimum width for these

play27:41

achievement cards

play27:42

so let's type min width and let's start

play27:45

with 200

play27:46

pixels but that looks alright so let's

play27:49

add these three lines of code and let's

play27:51

paste it over here

play27:53

in the second one

play27:55

and i'll just remove this line of code

play27:57

and paste it over here in the

play27:58

achievement card

play28:01

and that looks alright so that's

play28:02

basically it with the hero section of

play28:04

our website all right that's it for this

play28:06

video if you have any doubts you can ask

play28:08

in the comments below and if you like

play28:09

this video please click on the like

play28:11

button and subscribe to this channel to

play28:12

get the latest video updates thanks a

play28:14

lot for watching have a nice day

play28:18

[Music]

play28:32

you

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
Web DevelopmentHTML CodingCSS StylingJavaScriptDesign ConversionTutorial SeriesWebsite BuildingFigma IntegrationResponsive DesignCoding Tutorial