CSS Programming Fundamentals | Web Development

Introduction

In this lab, we will be exploring the fundamentals of CSS programming. The purpose of this lab is to help you gain a solid understanding of CSS syntax, selectors, properties, and values. By completing this lab, you will be abl…


This content originally appeared on DEV Community and was authored by Labby

Introduction

MindMap

In this lab, we will be exploring the fundamentals of CSS programming. The purpose of this lab is to help you gain a solid understanding of CSS syntax, selectors, properties, and values. By completing this lab, you will be able to style HTML elements and create visually appealing web pages.

Hamburger Button

index.html and style.css have already been provided in the VM.

To create a hamburger menu that transitions to a cross button on hover, follow these steps:

  1. Use a .hamburger-menu container div which contains the top, bottom, and middle bars.
  2. Set the container to display: flex with flex-flow: column wrap.
  3. Add distance between the bars using justify-content: space-between.
  4. Use transform: rotate() to rotate the top and bottom bars by 45 degrees and opacity: 0 to fade the middle bar on hover.
  5. Use transform-origin: left so that the bars rotate around the left point.

Here's the corresponding HTML code:

<div class="hamburger-menu">
  <div class="bar top"></div>
  <div class="bar middle"></div>
  <div class="bar bottom"></div>
</div>

And here's the CSS code:

.hamburger-menu {
  display: flex;
  flex-flow: column wrap;
  justify-content: space-between;
  height: 2.5rem;
  width: 2.5rem;
  cursor: pointer;
}

.hamburger-menu .bar {
  height: 5px;
  background: black;
  border-radius: 5px;
  margin: 3px 0px;
  transform-origin: left;
  transition: all 0.5s;
}

.hamburger-menu:hover .top {
  transform: rotate(45deg);
}

.hamburger-menu:hover .middle {
  opacity: 0;
}

.hamburger-menu:hover .bottom {
  transform: rotate(-45deg);
}

Please click on 'Go Live' in the bottom right corner to run the web service on port 8080. Then, you can refresh the Web 8080 Tab to preview the web page.

Summary

Congratulations! You have completed the Hamburger Button lab. You can practice more labs in LabEx to improve your skills.

🚀 Practice Now: CSS Fundamentals for Web Styling

Want to Learn More?


This content originally appeared on DEV Community and was authored by Labby


Print Share Comment Cite Upload Translate Updates
APA

Labby | Sciencx (2024-07-31T03:23:56+00:00) CSS Programming Fundamentals | Web Development. Retrieved from https://www.scien.cx/2024/07/31/css-programming-fundamentals-web-development/

MLA
" » CSS Programming Fundamentals | Web Development." Labby | Sciencx - Wednesday July 31, 2024, https://www.scien.cx/2024/07/31/css-programming-fundamentals-web-development/
HARVARD
Labby | Sciencx Wednesday July 31, 2024 » CSS Programming Fundamentals | Web Development., viewed ,<https://www.scien.cx/2024/07/31/css-programming-fundamentals-web-development/>
VANCOUVER
Labby | Sciencx - » CSS Programming Fundamentals | Web Development. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/31/css-programming-fundamentals-web-development/
CHICAGO
" » CSS Programming Fundamentals | Web Development." Labby | Sciencx - Accessed . https://www.scien.cx/2024/07/31/css-programming-fundamentals-web-development/
IEEE
" » CSS Programming Fundamentals | Web Development." Labby | Sciencx [Online]. Available: https://www.scien.cx/2024/07/31/css-programming-fundamentals-web-development/. [Accessed: ]
rf:citation
» CSS Programming Fundamentals | Web Development | Labby | Sciencx | https://www.scien.cx/2024/07/31/css-programming-fundamentals-web-development/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.