Delete the 'position: absolute' style in the media query

I have set the display property to flex for a container (.zone-container) to organize its children. However, I have used position: absolute on one of the children (#camp-zone) to stack it on top of the other children. In my media query, I want to remove the position: absolute from this child element and apply the same style as the other children (excluding background-color). I attempted to change the position to static in the media query for both the child with position: absolute and the parent container with position: relative, but the child element still appears differently compared to the rest. How can I reset the specific styling in the media query?

.header {
  background-color: navy;
  min-height: 7vh; 
  display: grid;
}

.header h2 {
  color: white;
  text-align: center;
  font-size: 45px;
  font-weight: inherit;
  font-family: arial;
}

.game-area {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  background-color: navy;
  height: 100%;
  min-height: 1000px;
}

.activity-zone-container {
  display: flex;
}

.zone-container {
  display: flex;
  flex-wrap: wrap;
  max-width: 120vh;
  position: relative;
  max-height: 95vh;
  margin: 0%;
}

.zone {
  min-width: 32vh;
  min-height: 27vh;
  margin: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 44%;
  height: 33%;
  max-height: 300px;
}

.zone p {
  color: white;
  text-align: center;
  margin-bottom: 15px;
  font-family: arial;
}

#concentration-zone {
  background-color: orange;
}
#communication-zone {
  background-color: yellow;
}
#communication-zone p {
  color: black;
}
#collaboration-zone {
  background-color: #3260a8;
}
#chill-out-zone {
  background-color: pink;
}
#chill-out-zone p {
  color: black;
}
...

@media (max-width: 768px) {

  .game-area {
    min-height: 150vh;
  }

  .header h2 {
    margin: 15px;
    font-size: 30px;
  }

  .zone {
    width: 220px;
    height: 180px;
  }

  #camp-zone {
    position: static;
    width: unset;
    height: unset;
    margin-top: unset;
    justify-content: unset;
    justify-self: unset;
    z-index: unset;
    bottom: unset;
    right: unset;
    width: unset;
    height: unset;
    min-width: unset;
    min-height: unset;
    margin-left: unset;
    margin-right: unset;
    margin-bottom: unset;
    left: unset;
    top: unset;
  }

<html lang
<body>
    <div id="app">
        <section class="header">
            <h2>Click on an activity box to see which area it belongs to</h2>
        </section>
        <section class="game-area">
            <div class="activity-zone-container">
                <div class="zone-container">
                    <div class="zone" id="concentration-zone">
                        <p>Concentration</p>
                    </div>
                    <div class="zone" id="communication-zone">
                        <p>Communication</p>
                    </div>
                    ...

                    ...
                    
                    <button class="activity" activitytype="chillout">
                        <p>Networking</p>
                    </button>
                </div>
           </div>
        </section>
    </div>
    <script src="index.js" type="text/javascript"/>
    <script src="/static/js/bundle.js"/>
    <script src="/static/js/0.chunk.js"/>
    <script src="/static/js/main.chunk.js"/>
</body>
</html>

Answer №1

It is advised to modify your CSS according to the following guidelines. The code snippet within @media (min-width: 767px){} will only affect screens larger than 767px, while smaller screens like @media (max-width: 768px){} will simply disregard it.

.header {
    background-color: navy;
    min-height: 7vh; 
    display: grid;
}

.header h2 {
    color: white;
    text-align: center;
    font-size: 45px;
    font-weight: inherit;
    font-family: arial;
}

.game-area {
   ...
    // Remaining CSS properties and rules as provided
   ...
}


@media (min-width: 767px)  {
   ...
    // Depicting how certain elements should adjust on larger screens
   ...
}

@media (max-width: 768px)  {
    .game-area {
        min-height: 150vh;
    }

    .header h2 {
       ...
        // Adjustments for header fonts and margins on smaller screens
       ...
        
    }

    .zone {
       ...
        // Customizations for zones at lower resolutions
       ...
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Button triggering an onclick event

Can you design a feature where clicking on each button reveals specific images with text and heading? The initial image is hidden and when another button is clicked, the previous image disappears and new one appears in its place. We would like to achieve t ...

accordions that are supposed to adapt to different screen sizes are

My custom responsive accordions are not functioning as expected. The requirement is to display headings and content for desktop view, but switch to accordions on smaller devices. I have managed to do this, however, when resizing the window, the functionali ...

CSS vertical alignment: Getting it just right

I am currently using Bootstrap and below is a snippet of the code I have implemented. <div class="row"> <div class="col-lg-6"><img src="#" alt=""></div> <div class="col-lg-6"> <h2>Heading</h2> ...

The appearance of a printed webpage is strikingly distinct from its digital counterpart

Currently, I am working on setting up online invitations and one of the options for sending them out is through print. However, despite having the invitations perfectly designed on the web page, the outcome after printing is not what I expected. You can vi ...

What is the best way to ensure that deck.gl and react-map-gl are displaying properly on my screen?

Check out this code sandbox example that demonstrates my attempt to display a map within a specific component. However, I'm facing an issue where the deck.gl and react-map-gl elements are overflowing outside their parent container and extending to the ...

I would like to smoothly fade in and out the text within the anchor tag, creating a subtle and gentle effect

My bootstrap navigation bar has icons that transition to text when hovered over, but the change is too abrupt. I would like it to appear more smoothly and gradually, similar to the effect on this website This is an example of my HTML code: <nav cla ...

Incorporating personalized CSS and JavaScript into Shopify

Currently, my project involves integrating vertical tabs into a Shopify page that is utilizing the 'Atlantic' theme. Since this particular theme doesn't come with vertical tabs built-in, I have incorporated external JS and CSS files known as ...

Creating a sleek dark-themed table using Bootstrap's HTML

While browsing through https://getbootstrap.com/docs/4.0/content/tables/, I came across a table with a really dark background towards the bottom of the page. I tried copying the code into an HTML document, but it didn't seem to work. After tinkering w ...

What is causing my mobile version not to resize and adjust to fit the screen properly?

Currently utilizing Bootstrap 4 along with the viewport meta tag, %meta{:content => "width=device-width, initial-scale=1, shrink-to-fit=no", :name => "viewport"}/ Even after hiding all images with .hidden-xs-up, the display on Chrome mobile appear ...

Ordering data in a dynamic table using JavaScript

After receiving an array of objects in the form of a JSON file and using AJAX to display specific key-value pairs in a table, I am now faced with the task of sorting the rendered table. However, I am uncertain about the steps to take next. <div id=" ...

Tips on Creating a Responsive Absolutely Positioned Div for Various Screen Sizes

I'm currently working on a website and I've come across an issue regarding the responsiveness of an absolutely positioned div across various screen sizes. Let me provide some context and share what I have attempted so far: Issue: Within the head ...

Vue.js transition-group does not apply the *-move class

As I dive into learning Vue, I find myself wondering if I may have overlooked something fundamental or stumbled upon a bug. Despite multiple readings of the documentation at https://v2.vuejs.org/v2/guide/transitions.html#List-Move-Transitions, I still can& ...

Moving a button to the right side in HTML/CSS without creating any gaps

Currently, I'm working on developing a simple idle browser game. I'm facing a challenge in positioning a button on the right-middle of the box. I attempted using position: relative along with adjusting the bottom and left parameters, but I still ...

Maximizing the use of default top positioning for absolutely positioned elements

After observing that an element with position:absolute can have its default top value determined based on its immediate parent's position, regardless of whether it is set to relative or not, BoltClock explained that in such cases, it remains in a stat ...

`Is there a way to manage date formats across all components using a single method in Angular?`

I need assistance with controlling the date format of dates displayed in different components using one typescript file. How can I achieve this? app.ts import { Component } from '@angular/core'; @Component({ selector: 'app-root', ...

Viewport height-responsive image not functioning as expected in Firefox browser

Is there a way to set an image to the 100% height of the browser window, with a small padding at the bottom, and have it centered on the page? I created an example in codepen that works well in Chrome and Safari, but not in Firefox. In Firefox, the image ...

Blurred background images following the upgrade to Internet Explorer 11

This morning, I received an automatic update to IE 11 and noticed that some of my background images appeared blurry. After confirming that the images were not the issue, I opened Chrome and saw that they were crisp again. This left me completely puzzled. ...

Tips for aligning 2 divs in the same position?

I am working on a slider feature that includes both videos and pictures. I need to ensure that the videos are hidden when the device width exceeds 600px. Here is the HTML code snippet: <video class="player__video" width="506" height="506" muted preloa ...

Challenges in customizing the bootstrap navigation bar links

Having an issue with the bootstrap navbar link displaying on small devices. Here is the template I'm using: https://i.sstatic.net/jSy1b.png The last item is displaying in two lines. ...

What steps should I take to translate the design of Facebook's iOS homescreen into HTML and CSS?

While it's known that Facebook utilizes the Three20 library for its icons on the homescreen, I'm curious if there is a way to replicate this effect using only HTML and CSS. I assume that some form of positioning like tables would be necessary fo ...