Creating a sturdy media object base with a main section that is elevated to perfectly showcase the content

Utilizing Zurb Foundation v6 for my project, I have implemented a media object on my page:


<div class="media-object stack-for-small">
  <div class="media-object-section">
    <img src= "{{ entry.topImage.first().getUrl('square') }}">
  </div>
  <div class="media-object-section main-section">
    <h4>{{ entry.title }}</h4>
    <p>{{ entry.summary | truncate('words', '50', ' ...', true) }}</p>
    <div class="date">
      <p>{{ entry.dateUpdated | date('j. F Y') }}</p>
    </div>
  </div>
</div>

To ensure that the date div is positioned at the bottom of the main-section, I used position: absolute and bottom: 1rem. However, a problem arises on small screens where text from {{ entry.summary }} overlaps with the date. I attempted adjusting the date's padding-top and margin-top, but no solution was effective. How can this issue be resolved?

This SCSS file provides the styling:


.results {
  height: 100%;
  background: $gray;

  .media-object {
    background: $white;
  }

  .results-title {
    padding-top: 2rem;
  }

  .query {
    padding-left: 1.8rem;
    padding-bottom: 2rem;
  }

  .media-object-section {
    width: 300px;

    img {
      max-width: 100%;
    }
  }

  .main-section {
    position: relative;
    padding-right: 1rem;

    .date {
      position: absolute;
      bottom: 1rem;

      p {
        margin-bottom: 0;
      }
    }

    h4, p {
      color: $black;
    }

    h4 {
      padding-top: 2rem;
      margin-bottom: 1rem;
    }
  }

  @include breakpoint(small only) {
    .main-section {
      padding: 1rem!important;
    }
  }
}

Answer №1

While it may seem like a small solution, using absolute positioning can remove the element from the document flow and cause issues. To address this on smaller screens, consider utilizing a media query to re-position the element relative once again. Here's an example:

@media screen and (max-width: 479px) {
    .element {
       position: relative !important;
    }
}

By reintroducing the element back into the document flow with this approach, you can ensure that the surrounding elements follow your intended design rules.

Best regards,

-B

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

Verify the fonts that are functioning correctly

Despite using the "dancing script" Google webfont and adding it through @font-face, font-family, I am unable to see it in the browser. I would like to know how to determine which fonts are correctly uploaded and rendering properly while viewing a website ...

Increase the width of paragraph by adding white-space padding

I am attempting to control the number of characters in a paragraph to a specific limit. If the text is shorter, I want to add whitespace padding, and if it exceeds the limit, I will truncate it with an ellipsis. All containers containing paragraphs should ...

Embedding SVG or image code within the </style> tags is a common practice in web development

Can anyone assist me in placing this code within </style>? I am unsure of how to proceed with this. I believe the best approach would be to start by moving most of it into </style>, and then I can decide what should remain there. I would grea ...

How can I use JavaScript to trigger a button click event inside an iframe element

Is there a way to retrieve the inner HTML contents of a clicked element in an iframe loaded content using JavaScript? This code uses jQuery: var elements = document.getElementsByTagName('iframe'); [].forEach.call(elements, function(elem ...

Words within a string are divided in the center, with JS and CSS involved

I'm currently working on developing a hangman game in JavaScript (I am new to web technologies) and I have come across my first challenge. The placeholder string for the word to be guessed, which consists of hyphens and spaces, is overflowing from the ...

Having trouble selecting a dynamically changing div element in Selenium with Java using a click action

Every time I navigate to www.reddit.com and enter a query in the Search field, then press enter to go to the first valid link within a subreddit, sorting options are presented. By default, it is set to BEST but I wish to change it to TOP. My test class cod ...

Facebook-Clone Chrome extension that automatically displays "User is listening to..."

I'm currently developing a Chrome Extension that will replace the chat input box with the music I'm listening to by simply pressing "´". It's worth noting that the chat is designed using react and does not use the traditional input/textarea ...

Tips for incorporating background-size and background-position within the background-image url()

My div currently has a background image set with background-image url(), but I am trying to achieve the following look: background-image url('example') cover center Here is my current code: div { background-image: url(example); background- ...

Failure to display sub menu upon hover

While exploring the website and visiting the "onze klanten" page, I noticed that when hovering over the menu, the submenu disappears behind the slider. Do you have any ideas on how to fix this issue? ...

"The issue of a malfunctioning selected option in a select dropdown within an AngularJS application

I've been experiencing some odd behavior with my Dropdown control in an AngularJS application. The selected="selected" attribute doesn't seem to be working, resulting in blank default selected values. Additionally, I'm having trouble with t ...

Assign the appropriate label to the HTML checkbox based on the value obtained from the function

I have managed to successfully initiate the HTML service and display the checkbox itself. However, I am facing a challenge in displaying text next to the checkbox as a label. My goal is to have this label text be the return value of a function in the .gs f ...

The CSS property input::-webkit-outer-spin-button adjusts the margin-left and is exclusively visible in Chrome browser

Strange things are happening... Let me share the code for my inputs: #sign_in input#submit { height: 56px; background-color: #88b805; font-weight: bold; text-decoration: none; padding: 5px 40px 5px 40px; /* top, right, bottom, left ...

How to vertically center the contents of two adjacent divs with automatic width?

I've experimented with a range of HTML elements and CSS styles in an effort to make this work, but without success. How can I achieve the following task? My goal is to have two side-by-side DIVs that automatically adjust their size based on the conte ...

Zoom in on a canvas-inserted image by clicking it, using a snippet of jQuery and HTML5

I'm currently working on a canvas image that allows zooming in and out after clicking the control button. The original size of the red ball is 128x128px. However, when zooming in too much, the image gets clipped by its own container. How can I resolv ...

Choosing an element that does not have a particular string in its colon attribute name

In my code, I have multiple elements structured like this: <g transform="matrix"> <image xlink:href="data:image/png" width="48"> </g> <g transform="matrix"> <image xlink:href="specific" width="48"> </g> <g tran ...

Transitioning classes in Vue elements

Is it achievable to create a smooth transition between two CSS classes with different background images? That's the challenge I'm currently facing. Here is the Vue code snippet I am working on: <div id="flip-list-demo" class="demo"> & ...

Rotating Images in Query and Chrome

My script for rotating images is functioning well in various browsers, however, it seems to be experiencing issues specifically with Google Chrome. In order to address this problem, I attempted a CSS3 workaround. Unfortunately, I have encountered difficul ...

What is the best way to intelligently cache specific segments of a page in PHP?

Issue: I am working on a website with over 50,000 pages, the majority of which are only updated once at the time of creation. I am in the process of implementing caching for these pages since they do not require frequent content changes. However, I am fa ...

Apply a class to a div element when the WooCommerce cart is devoid of any items

Is there a way to apply a class or style to an element that displays the cart count only when the cart is empty? Currently, I have the following code in my header.php file which shows the cart count correctly, but does not update the color: header.php ( ...

Adjust the positioning of elements within a expanded and toggled Bootstrap navbar

Seeking assistance with a responsive Bootstrap navbar design. When the navbar collapses, the "logout" button is not aligning properly. Need help to keep it in the top row on the right side next to the toggler icon or underneath the other items on the right ...