Struggling with responsive design and the challenges of absolute positioning

Currently in the process of creating a page for case studies, where a main banner image is followed by 3 rows of 3 sub-images. Each image is added through the background-image property to maintain consistent div heights. The divs have a hover container on top that should always remain above the content, but I am facing challenges when it comes to ensuring this on smaller screens (850px and below) without relying on specific pixel values. Is there a more efficient way to achieve this?

Below is the basic HTML structure I am using:

<div class="study-list">
<a href="#">
    <div class="study-block left">
        <div class="left-case-cover">
            <div class="case-study-title">A Bridge For Kids Raises Scholarship Funds For Students Using Dxxx's Fundraising Software</div>
            <div class="case-study-cta">Click here to read more</div>
        </div>
        <div class="study study1"></div>
    </div>
</a> 
<a href="#">
    <div class="study-block center">
        <div class="center-case-cover">
            <div class="case-study-title">A Bridge For Kids Raises Scholarship Funds For Students Using Dxxx's Fundraising Software</div>
            <div class="case-study-cta">Click here to read more</div>
        </div>
        <div class="study study2"></div>
    </div>
</a> 
<a href="#">
    <div class="study-block right">
        <div class="right-case-cover">
            <div class="case-study-title">A Bridge For Kids Raises Scholarship Funds For Students Using Dxxx's Fundraising Software</div>
            <div class="case-study-cta">Click here to read more</div>
        </div>
        <div class="study study3"></div>
    </div>
</a> 

My assumption is that the issue lies in the absolute positioning of the covers over the case-studies. Is there an alternative approach or solution that could help me overcome this? Everything looks fine on screens larger than 851px, I just need to address the mobile display aspect.

Check out this Fiddle to see the current problem, it might be helpful to view it in fullscreen.

Thank you for your assistance!


Attempts I have made:

• Attempted to set a specific width for the container holding the cover and used overflow:hidden to hide the excess hover, but this did not yield the desired outcome.

• Tried using precise pixel values, but this approach also proved to be unsuccessful.

Answer №1

To optimize the appearance of the cover DOM, consider including the CSS property position: relative; in its parent element. It is also important to ensure that the cover begins at top: 0, left: 0 and extends to bottom:0 and right:0.

To prevent undesired overlapping of successive DOM elements, a clearfix may be necessary for proper alignment. This precaution is specifically recommended for resolutions under 850px, as implementing it in generic HTML could negatively impact desktop resolution.

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

Take away the CSS class from an element after reCAPTCHA verification is complete in Next.js

I'm struggling with removing the CSS class btn-disabled from the input button element upon successful verification of a form entry. I have implemented a function called enableForm to remove the btn-disabled CSS class when reCAPTCHA is verified. Howe ...

What could be causing this issue with my JavaScript code?

Here is the code I have: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <script type="module"> import * a ...

Tweaking the placement of the dropdown menu in the subnavigation area

Just getting back into coding after a long hiatus - I've dabbled in the past but it's been about 6 years since I've worked with any code. Currently, I'm working on replicating a website for practice. I have created a nav bar and a drop ...

Modifying the display property of an element using JavaScript

Hello, I'm encountering an issue with a section of my javascript code. I am attempting to make the #showAddress element display as block when the deliverservice radio button is clicked or checked. I have tried searching for solutions on Stack Overflow ...

Tips for displaying form data in a boostrap modal

One issue I am facing involves a form that collects a user's first and last name, along with a button that activates a bootstrap modal. When the button is clicked, the goal is to display the inputted data from the form within the modal window. The use ...

What could be causing my Bootstrap (3) grid to not display responsively?

It seems like there may be a simple oversight in my code, as I'm unable to make my Bootstrap grid responsive. I have successfully passed item data through Node and am able to display a grid of item thumbnails with captions in rows of 4. However, when ...

The table value is only updated once with the onclick event, but the updated value is not displayed when the event is clicked again

I am facing an issue with updating names in a table through a modal edit form. The first name update works perfectly, but the second update does not reflect in the table. I want every change made in the modal edit form to be instantly displayed in the tabl ...

What are some techniques for ensuring a CSS div remains stable and intact when adjusting the browser size?

Is there a way to prevent the entire website from resizing when you minimize or maximize your browser? I want the website size to adjust in proportion to your resize without reorganizing everything. How can this be achieved while maintaining the site lengt ...

What impact does setting a variable equal to itself within a Dom Object have?

Within my code example, I encountered an issue with image sources and hrefs in a HTML String named tinymceToHTML. When downloading this html String, the paths were set incorrectly. The original image sources appeared as "/file/:id" in the String. However, ...

Attempting to alter an image with a click and then revert it back to its original state

I'm currently working on a feature that toggles an image when a specific class is clicked. The code I have so far successfully switches from 'plus.png' to 'minus.png' upon clicking, but I need it to switch back to 'plus.png&ap ...

Is it possible to apply styles to javascript elements without relying on img class? Additionally, how can I incorporate an onclick button while maintaining a fully functional navigation bar?

My current project involves creating an interactive collage where users can click around and have pictures pop up at the clicked location. The functionality works as intended, but now I'm facing issues with the navigation bar not being clickable. Addi ...

How to interact with a C# List using JavaScript

Our internship project entails creating a business application using Unity WebGL. However, we're facing a challenge when it comes to retrieving a list from C# to populate a Select element on our webpage. We've successfully communicated and retrie ...

Duplicate the image from a specific div to another div, ensuring that only one clone is created

I'm trying to replicate an image in multiple spots within a frame, but I can only manage to get one instead of many. Can someone please tell me what I'm doing wrong? I am creating a map of terrain where I need to clone images from one div to anot ...

Reasons why Custom CSS won't function simultaneously with Bootstrap 5

I recently designed a dashboard using bootstrap 5. While working on this project, I found myself in need of a custom CSS style in addition to the default bootstrap styles. However, I encountered an issue where my custom CSS would not apply properly unles ...

Guide on how to retrieve a clicked element

When I click on the <ul> inside this div, I want to retrieve the id="nm". <div id="suggestionTags"> <ul> <li class="nm">Commonwealth</li> <span class="cty"> x GB</span> <li class="hse">C ...

Updating a class within an AngularJS directive: A step-by-step guide

Is there a way to change the class (inside directive) upon clicking the directive element? The current code I have updates scope.myattr in the console but not reflected in the template or view: <test order="A">Test</test> .directive("test", ...

Issues with iFrame Alignment

I recently created a digital catalog using FlipHTML5 and realized it needed to be more mobile-friendly. To address this issue, I included the following CSS: .size { width: 85vw; height: 75vh; Although this adjustment made the catalog display correctly on ...

When attempting to execute the delete script, some errors were encountered

The following error has occurred: An issue with the SQL syntax has been detected; please refer to the manual specific to your MySQL server version for guidance on the correct syntax to use near ''sarojini'_bookings WHERE date=2014-07-24 A ...

What is the best way to transfer form input data from a child component to the parent component in React?

Recently delving into the world of React, I decided to experiment with forms. My project idea was straightforward - create a form component with input fields that, upon clicking submit, would pass the input values to the parent component ('App') ...

What's the Reason Behind the Ineffectiveness of Footer Background Color in HTML CSS3?

Having some trouble setting the background color for my footer to something other than white. I've been able to successfully change the background of other layout elements, but the footer is giving me issues. Check out the code below: <footer> ...