Join Regular Classroom : Visit ClassroomTech

CSS – codewindow.in

Related Topics

HTML

Introduction
Html page 1
Html page 2
Html page3
Html page4

HTML Elements and structure
Html page 5
Html page 6
Html page 7

HTML Headings and Paragraphs
Html page 8
Html page 9
Html page 10

HTML Lists and Tables
Html page 11
Html page 12
Html page 13

HTML Forms and Input Fields
Html page 14
Html page 15
Html page 16

HTML Images and Media
Html page 17
Html page 18

HTML Links and Anchors
Html page 19
Html page 20
Html page 21

HTML Styles and Formatting
Html page 22

HTML Semantic Elements
Html page 23
Html page 24

HTML Attributes
Html page 25
Html page 26

HTML JavaScript Integration
Html page 27
Html page 28
Html page 29
Html page 30

HTML Document and Browser Support
Html page 31
Html page 32

HTML5 New Elements and Attributes
Html page 33
Html page 34
Html page 35
Html page 36

HTML Accessibility and Web Standards
Html page 37
Html page 38
Html page 39

HTML Responsive Design and Mobile Devices.
Html page 40
Html page 41
Html page 42

CSS

<header class="header">
  <h1 class="logo">Logo</h1>
  <nav class="navigation">
    <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Services</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
  </nav>
</header>

CSS:

.header {
  background-color: #333;
  color: #fff;
  padding: 20px;
}

.logo {
  font-size: 32px;
}

.navigation ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.navigation li {
  display: inline-block;
  margin-right: 10px;
}

.navigation a {
  color: #fff;
  text-decoration: none;
  font-size: 16px;
}

/* Media query for smaller screens */
@media (max-width: 600px) {
  .logo {
    font-size: 24px;
  }
  
  .navigation a {
    font-size: 14px;
  }
}

In the above example, the header is represented by the .header class, the logo by the .logo class, and the navigation by the .navigation class.

By default, the logo is set to font-size: 32px, and the navigation links are set to font-size: 16px.

Within the media query @media (max-width: 600px), we target screens with a maximum width of 600 pixels. In this media query, we override the logo and navigation link font sizes to make them smaller, using font-size: 24px for the logo and font-size: 14px for the navigation links.

This example demonstrates a simple implementation, but you can customize the styles further to fit your specific design requirements. The media query allows you to adjust the header’s appearance and font sizes based on different screen sizes, providing a responsive experience for users across various devices.

<div class="container">
  <h1 class="heading">Heading</h1>
  <p class="content">Content</p>
  <button class="cta">Call to Action</button>
</div>

CSS:

.container {
  /* Styles for the container */
}

.heading {
  /* Styles for the heading */
}

.content {
  /* Styles for the content */
}

.cta {
  /* Styles for the call-to-action button */
}

/* Media query to hide the button on smaller screens */
@media (max-width: 768px) {
  .cta {
    display: none;
  }
}

/* Media query to hide the heading on larger screens */
@media (min-width: 1200px) {
  .heading {
    display: none;
  }
}

In the above example, we have a container with a heading, content, and a call-to-action button. We use media queries to hide certain elements based on screen size:

  1. Media query to hide the button on smaller screens:

    • The @media (max-width: 768px) media query targets screens with a maximum width of 768 pixels.

    • Within this media query, we set the display property of the .cta class to none, effectively hiding the call-to-action button on smaller screens.

  2. Media query to hide the heading on larger screens:

    • The @media (min-width: 1200px) media query targets screens with a minimum width of 1200 pixels.

    • Within this media query, we set the display property of the .heading class to none, effectively hiding the heading on larger screens.

By using media queries and adjusting the display property, you can selectively hide or show elements based on the screen size or viewport dimensions. This allows you to create responsive designs where certain elements are hidden or displayed to optimize the user experience across different devices.

      

Popular Category

Topics for You

HTML

Introduction
Html page 1
Html page 2
Html page3
Html page4

HTML Elements and structure
Html page 5
Html page 6
Html page 7

HTML Headings and Paragraphs
Html page 8
Html page 9
Html page 10

HTML Lists and Tables
Html page 11
Html page 12
Html page 13

HTML Forms and Input Fields
Html page 14
Html page 15
Html page 16

HTML Images and Media
Html page 17
Html page 18

HTML Links and Anchors
Html page 19
Html page 20
Html page 21

HTML Styles and Formatting
Html page 22

HTML Semantic Elements
Html page 23
Html page 24

HTML Attributes
Html page 25
Html page 26

HTML JavaScript Integration
Html page 27
Html page 28
Html page 29
Html page 30

HTML Document and Browser Support
Html page 31
Html page 32

HTML5 New Elements and Attributes
Html page 33
Html page 34
Html page 35
Html page 36

HTML Accessibility and Web Standards
Html page 37
Html page 38
Html page 39

HTML Responsive Design and Mobile Devices.
Html page 40
Html page 41
Html page 42

Go through our study material. Your Job is awaiting.

Recent Posts
Categories