CSS: The relative positioned element now functions correctly with the inclusion of overflow-x

  1. Is there a way to ensure that the images in the day_time_block cover the title class?

  2. I would also like all contents within the day_time_block to be displayed using overflow-x. However, when I add overflow-x: auto; to the scroll div, the images in the day_time_block end up being covered by the title div. How can I resolve this issue?

HTML:

<html>
      <body>
        <div>
          <div class="daily_content">
            <div class="title">
              <img src="https://www.google.com.hk/images/srpr/logo11w.png" class="img_title"/>
              <div class="daily_title">Title</div>
            </div>
            <div class="scroll">
              <div class="day_time_block">
                <div class="day_time_text">Sunday</div>
                <img src="https://www.google.com.hk/images/srpr/logo11w.png" class="daily_img"/>
              </div>
              <div class="day_time_block">
                <div class="day_time_text">Monday</div>
                <img src="https://www.google.com.hk/images/srpr/logo11w.png" class="daily_img"/>
              </div>
              <div class="day_time_block">
                <div class="day_time_text">Tuesday</div>
                <img src="https://www.google.com.hk/images/srpr/logo11w.png" class="daily_img"/>
              </div>
              <div class="day_time_block">
                <div class="day_time_text">Wednesday</div>
                <img src="https://www.google.com.hk/images/srpr/logo11w.png" class="daily_img"/>
              </div>
              <div class="day_time_block">
                <div class="day_time_text">Thursday</div>
                <img src="https://www.google.com.hk/images/srpr/logo11w.png" class="daily_img"/>
              </div>
            </div>
          </div>
        </div>
      </body>
    </html> 

CSS:

<style>
          body {
            margin: 0px;
          }
          .title {
            background: #ED3632;
            height: 25px;
          }
          .img_title {
            width: 30px;
            height: 20px;
            float: left;
            margin-left: 15px;
            margin-right: 5px;
          }
          .daily_title {
            color: #f6ff52;
            font-size: 1em;
            
          }
          .daily_content {
            background: #000000;
            height: 3000px;

          }
          .scroll {
            color: #ffffff;
            font-size: 1em;
            width: 480px;
            overflow-x: auto;
            white-space: nowrap;
            background-color: aqua;
            border: 1px red solid;
            display: flex;
          }

          .day_time_block {
            float: left;
            color: #ffffff;
            font-size: 1em;
            padding-left: 8px;
          }

          .day_time_text {
            font-size: 1em;
            display: inline-block;
          }

          .daily_img {
            width: 30px;
            height: 20px;
            margin-left: 10px;
            position: relative;
            top: -10px;
          }
</style>

Answer №1

When using display:block, overflow works fine...however, if you prefer to use display:flex, it's recommended to create a parent div for it, set its display property to block, and then apply the overflow on the parent div.

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

The CSS file that is defined first in the node.js HTML is the only one being utilized

Currently, I am incorporating CSS and JS files into my node.js/express application with the help of the ejs templating engine. Interestingly, while the JavaScript files are being successfully implemented, only the first included CSS file seems to be affect ...

Is there a way to compel the browser or JavaScript to delete/disregard a cached file?

I've encountered an issue with my Javascript program that extracts data from a text file and displays it in a table. The problem arises when I update the text file - the changes don't reflect on the table because the browser is caching the file. ...

The background image within Bootstrap theme layouts appears to be missing from both the styles and divs

Encountering a peculiar dilemma here. Attempted to apply a background image to a custom style in order to override/extend a bootstrap column style. Additionally, tried embedding a style directly in the div attribute. Strangely, neither method seems to be e ...

Personalizing Material-UI's select component: A step-by-step guide

Desired Outcome: https://i.stack.imgur.com/khNHn.png https://i.stack.imgur.com/dQzVz.png Progress So Far: https://i.stack.imgur.com/CUixn.png Struggling to Position SVG Icon Next to Text: https://i.stack.imgur.com/4GFtA.png Issue with Black Line Whe ...

CSS: Fixed item at the bottom of a container that scrolls horizontally

I am working on creating a sticky footer within a horizontally scrolling element. I want the sticky footer to be positioned at the bottom, adjust its height based on the content inside it, and match the width of the scrollable parent (in this case 200px). ...

Retrieve the background color using code-behind

Despite its humorous appearance, I am having trouble with the Syntax :( I have a background color in my code behind file and need to correct the syntax here so that my Table displays the correct background color: <Table style="background-color:" &apos ...

The Owl carousel slide vanishes unexpectedly after resizing the window

My Owl-carousel slides are disappearing after resizing the browser window. You can see the issue in action here: . The website where this problem occurs is: . I suspect it has to do with the CSS animation within the items, as disabling the fade animation r ...

Update the text on a button using a different button

function modify_button_text(){ //update the word from cat to dog. } <button id="button_1_id" >Cat</button> <br><br><br><br> <button id="modify_button_text_btn" >Change the Text of Above Button</button> ...

Yii ReCaptcha for better mobile compatibility

Incorporating the extension from http://www.yiiframework.com/extension/recaptcha/ into my Yii project has been a successful endeavor thus far. However, in an effort to enhance the responsiveness of my website, I recently made some modifications to the cod ...

Sending JSON data to Python CGI script

I've successfully set up Apache2 and got Python running without any issues. However, I'm facing a problem with two pages - one is a Python Page and the other is an HTML page with JQuery. Could someone guide me on how to correctly make my ajax p ...

Extracting Data from Input Box Using Query

In my HTML setup, I have five <textarea> tags with IDs text1,text2,text3,text4, and one additional <textarea> tag with ID output. I want to query based on the values of text1,text2,text3,text4 (referred to as field1, field2, field3, field4). F ...

Combining GET and POST requests for CSRF attack

Imagine a scenario where a web application includes a delete button. When the button is clicked, the application initiates a GET request that returns a POST form containing a token key. The user is then prompted with a Yes or No question to confirm deletio ...

Adjust the DIV dimensions to fit the background image perfectly

My question involves a DIV element with a specific style applied to it. .vplayer-container .logo { position: absolute; bottom: 50px; right: 10px; background: url(../img/logo.png) no-repeat; border: 1px solid #000000; max-width: 50px; max-height: 50 ...

Accumulation of style from various directives in AngularJS on a single element

Currently, I am working on developing a component framework and find myself in need of a method to apply styles from multiple directives to an element in a way that they can accumulate. The priority of the styles should be determined by the directive creat ...

Why does the styling on my <a> tags in the footer only take effect when I apply padding to the form above?

It seems that when styling the <a> tag for the list in the footer, no changes occur even if correctly applying the style. However, adding padding to the form in the main part of the code causes the links in the footer to show the change. To see this ...

Acquiring inner HTML content with PHP

Looking to optimize meta tags for search and open graph. My goal is to dynamically generate the meta description tag by combining content from two specific elements in the HTML. For instance, let's say we have this snippet of code: <div class="r ...

Decorate the elements that do not contain a specific child class

I'm currently working on an angular project with primeng for the UI components. My focus at the moment is on customizing the p-menu component, specifically the appearance of list items that are not active. The challenge I'm facing is that the act ...

Tips on extracting the value from the chosen option in 2 separate rows with identical IDs

While looping through my table, each row is identified by the id="batchNo". I am trying to retrieve the selected value of each select option in every row. Although I attempted to achieve this with the provided code snippet, it only retrieves the selected ...

How can login errors be displayed in a Django application?

When I try to log into my website using the custom login page, entering the correct account details allows me access. However, if I input the wrong information, the page just refreshes with the username and password fields empty. Is there a way to display ...

Wrap the text within the contenteditable div with the <p> tag

By utilizing the code snippet below, I have managed to input text into a contenteditable div and instead of generating a new div on pressing the enter key, it generates <br> tags. Is there a way to enclose the text inside the contentedtiable div wit ...