For the current SASS code. How to change the height from the content div but when we are…
- User
For the current SASS code. How to change the height from the content div but when we are on the mobile breakup from the following SASS code.
@use 'sass:map'; @import 'variable'; @import 'typography_mixins'; @import 'fonts';
// Mixins for responsiveness @mixin mobile { @media (max-width: 768px) { @content; } }
@mixin tablet { @media (min-width: 769px) and (max-width: 1024px) { @content; } }
// Reset and base styles
- { margin: 0; padding: 0; box-sizing: border-box; }
body { line-height: 1.6; color: white; background-color: black; font-family: $font-family-base; @include font-size('base'); @include font-weight('regular');
}
// Navbar and Burger Menu .navbar { position: fixed; top: 0; left: 0; width: 100%; z-index: 100; display: flex; justify-content: space-between; align-items: center; padding: 1rem 5%; background-color: rgba(0,0,0,0.9); box-shadow: 0 2px 4px rgba(0,0,0,0.1);
.navbar-brand { display: flex; align-items: center; justify-content: space-between; width: 100%; } .navbar-brand a { text-decoration: none; color: $background-color; font-size: 1.5rem; font-weight: bold; font-family: $font-family-logo; } .burger-menu { display: none; flex-direction: column; cursor: pointer; z-index: 200; @include mobile { display: flex; } .bar { width: 25px; height: 3px; background-color: $primary-color; margin: 3px 0; transition: 0.4s; &.active:nth-child(1) { transform: rotate(-45deg) translate(-5px, 6px); } &.active:nth-child(2) { opacity: 0; } &.active:nth-child(3) { transform: rotate(45deg) translate(-5px, -6px); } } } .nav-menu { display: flex; align-items: center; list-style: none; @include mobile { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; background-color: rgba(255, 255, 255, 0.95); flex-direction: column; justify-content: center; align-items: center; transform: translateX(100%); transition: transform 0.3s ease-in-out; z-index: 150; &.active { transform: translateX(0); } .nav-item { margin: 20px 0; font-size: 1.5rem; a { text-decoration: none; color: $primary-color; transition: color 0.3s; &:hover { color: darken($primary-color, 10%); } } } } .nav-item { margin: 0 15px; a { text-decoration: none; color: $background-color; transition: color 0.3s; &:hover { color: $primary-color; } } } }}
// Adjust hero section for fixed navbar .hero { padding-top: 70px; // Height of the navbar position: relative; height: 100vh; overflow: hidden;
.video-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; video { width: 100%; height: 100%; object-fit: cover; } .video-control { position: absolute; bottom: 20px; right: 20px; background: rgba(0,0,0,0.5); color: white; border: none; padding: 10px; cursor: pointer; } } .hero-content { position: relative; z-index: 2; color: white; text-align: center; padding-top: 20%; & a{ position: absolute; left: 50%; transform: translate(-50%, 50%); text-decoration: none; color: white; background-color: $primary-color; border-radius: 5px; transition: background-color 0.3s; } } .btn-primary { background-color: $primary-color; text-decoration: none; color: $background-color; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; transition: background-color 0.3s; &:hover { background-color: darken($primary-color, 10%); } }}
// Adjust sponsor logos
.sponsored-by { text-align: center; }
#stats { padding: 2rem; text-align: center;
h2 { margin-bottom: 2rem; font-size: 2rem; color: $background-color; } .stats-grid { display: grid; gap: 2rem; //Desktop Layout: Horizontal Distribution grid-template-columns: repeat(4, 1fr); justify-content: center; align-items: center; @include tablet { grid-template-columns: repeat(2, 1fr); } @include mobile { gap: 1.5rem; grid-template-columns: 1fr; //Single column on mobile } } .stat-item { background-color: black; padding: 1.5rem; text-align: center; transition: background-color 1s, height 1s; border: 1px solid white; .content { display: none; } &:hover { background-color: white; height: 500px; border: 5px solid #5A4FF0; .content { display: block; } h3,p { color: black; } p { font-size: 16px; } } video { width: 100%; margin-bottom: 1rem; } h3 { margin: 0.5rem 0; font-size: 1.5rem; color: $background-color; } p { font-size: 1.5rem; color: $background-color; } }}
- Assistant
If you want to change the
heightfor the.contentdiv only on the mobile breakpoint, you can leverage your definedmobilemixin in the SASS file.Here's how you can update your code to achieve this:
.stat-item { background-color: black; padding: 1.5rem; text-align: center; transition: background-color 1s, height 1s; border: 1px solid white; .content { display: none; } &:hover { background-color: white; height: 500px; border: 5px solid #5A4FF0; .content { display: block; } h3, p { color: black; } p { font-size: 16px; } } video { width: 100%; margin-bottom: 1rem; } h3 { margin: 0.5rem 0; font-size: 1.5rem; color: $background-color; } p { font-size: 1.5rem; color: $background-color; } // Adjust content height specifically for mobile view @include mobile { height: auto; // Set height for mobile devices .content { display: block; // Ensure the content is visible on mobile } &:hover { height: auto; // Prevent hover effect from being awkward on mobile } } }Key Additions/Changes:
- Using the
@include mobilemixin: Inside the.stat-item, we target the mobile breakpoint using the@mediasettings from the mixin. - Adjusting the
heightfor mobile: You can set a specific height (e.g.,auto, or a pixel value like300px) for the mobile breakpoint. In this case, if you want different behavior on mobile, set it within this block. - Ensuring
.contentvisibility on mobile: You can set.contentto be visible (display: block) on mobile if it needs to show up without hover interactions.
Outcome:
- The hover effect handling
height: 500pxwill not apply on mobile. Instead, the height will be adjusted to a static or different value as per your requirements when the viewport width is768pxor less. - On desktop and tablet, the original hover effect will apply unless otherwise modified.
Let me know if you need further clarification or modifications!
- Using the