Content overflowing into a different divison

I am facing a problem with an absolutely positioned DIV. It is placed beside an image, and below it, there is another DIV. Everything looks good in fullscreen mode, but when I resize my browser window, the text spills into the lower DIV. What I really want is for the browser to create a horizontal scrollbar so that the text can continue in a line. You can check out the issue on Jfiddle here:

http://jsfiddle.net/9hpVT/

You need to adjust the width of your browser to observe the problem.

HTML

<div>
    <div id="d1">
        <img src="abc.jpg" />
    </div>
    <div id="d2">Here is a long line of text that will overlap the bottom portion. This is not desirable as it negatively impacts my design. Can someone assist me with this issue?</div>
    <div id="d3">I do not wish to be disturbed!</div>
</div>

CSS

#d1 {
    left:0;
    top:0;
}

#d2 {
    position:absolute;
    left:50px;
    top:0px;
}

Answer №1

The reason for this occurrence is due to the absolute positioning.
I suggest using float instead of position to resolve this issue. You can check out my Fiddle for reference.

#d1 {
    float: left;
}
#d2 {
    margin-left: 50px;
}

Answer №2

CLICK HERE FOR THE FIDDLE DEMO

No action is required for #d2 and #d3. Simply add the CSS rule float:left to the d1 element containing the image!

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

Troubleshooting Problem with Django and Bootstrap Styling

Currently, I am following some introductory Django tutorials to create a basic polling website. I have managed to get everything functioning properly, but I am struggling with the formatting on the "results" page for the polls. Here is how the page appear ...

Is there a way to showcase images next to each other within an array in Angular 8, like having 2 images in a row and then another 2 in the next row?

Here is the HTML code I created and tested: <div class="row"> <div *ngFor="let url of urls" class="col-md-6"> <img [src]="url" alt="Image not found" height="250px" width="350px" (click)="imageClick(url)"> </div> < ...

What is the best way to set the source of an image using JavaScript

On a recent project, I came across this function in PHP: foreach ($reports["included_reports"] as $index => $report_name ) { if (! in_array( $report_name, $reports["excluded_reports"])) { $optional_reports .= "<div class=\"la ...

Bootstrap fixed top navbar with a double color scheme

I would like to replicate the following image: using a navbar-fixed-top with Bootstrap. Currently, I have added the following custom CSS: navbar-fixed-top.css .navbar { background-color: #8CB5A0; background-image: none; } Here is the Bootstrap ...

Text that is curving around a D3.js pie chart

I am currently working on creating a 3D-Js chart and I would like the pie text to wrap around the pie itself. This is the exact effect that I am trying to achieve: https://i.sstatic.net/YOLdo.png I am facing two main issues: I am currently printi ...

Issue with custom leaflet divIcon not maintaining fixed marker position during zoom levels

After creating a custom marker for leaflet maps, I noticed that it shifts position drastically when zooming in and out of the map. Despite trying to adjust anchor points and positions, the issue persists. I have provided the code below in hopes that someon ...

Scrolling with jQuery just got a sleek upgrade with our new

Can anyone suggest a jQuery scrollbar that resembles the clean black bar found on the iPhone? I need a simple design without visible up or down buttons. Many scripts I came across offer more features than necessary for my project. My div element has a fi ...

Enhancing Bootstrap Slider Range with jQuery/Javascript

Currently, I have incorporated the Bootstrap slider into a webpage that features two sliders on a single page. The range of the second slider depends on the value of the first one. It is crucial for me to be able to update the range of the second slider af ...

The previously set display value remains unchanged when switching CSS files

I'm working on a project where I need to display three separate articles based on the screen size. Article 1 should only be visible when the screen width is less than 600 pixels Article 2 should be visible between 600 and 900 pixels Article 3 shoul ...

The tooltip function is not functioning properly on Internet Explorer when the button is disabled

I have been utilizing a similar solution found at http://jsfiddle.net/cSSUA/209/ to add tooltips to disabled buttons. However, I am encountering an issue specifically in Internet Explorer (IE11). The workaround involves wrapping the button within a span: ...

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 ...

Capture table screenshot using Selenium with unique font style

Below is a Python script that uses Selenium to load a specific page and capture a screenshot of the table on the page. from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from sel ...

What are the benefits of using PHP heredoc to create straightforward HTML code?

I've recently taken over the reins of a website and am looking to implement some changes. It's interesting because everything is structured using heredoc PHP scripts, yet there doesn't seem to be any actual PHP processing happening within th ...

What's the best way to increase vertical spacing between elements within a <div> when viewed on mobile devices?

Presently, I have designed a <div> that adjusts according to screen size. For wider screens: https://i.sstatic.net/0X6tq.png On mobile screens: https://i.sstatic.net/mYZxE.png I am looking to create vertical spacing between the two rows on mobil ...

Discovering the specific element that was clicked from a collection of elements

I'm dealing with a scenario where multiple divs share the same class. There is a dropdown that alters the background color of one of these divs when a certain option is selected (for example, option 2 changes div #2's background color). My dile ...

Tips for dividing a JPEG image into separate sections using HTML

Looking for guidance on slicing a JPEG image into HTML. Unsure about the div positioning, can anyone provide advice? The JPEG is attached with this question. Thanks, Umair ...

How to properly position a YouTube video frame in the center?

<section> <h3>Find out about us</h3> <p>British Airways Virtual is a leading virtual airline within the Infinite Flight community. Boasting a community of over 50 pilots, we offer a vibrant and engaging experience. Come and ...

Dynamic text input and selection menu with AJAX (PHP and JavaScript)

As a student who is new to Javascript and PHP, I am trying to create a login page for my website that can verify user input in the database using AJAX. For example, when a user enters their username and password, the system should automatically check if t ...

Do we actually need all of these DIVs?

Do you ever find yourself creating a div purely to house another element? Take for example, when designing a menu. You may create a div with specific styling and then place an unordered list within it. Alternatively, you could apply all the styling direc ...

How can I prevent scrolling in a Vue mobile menu?

In this scenario, the toggle for the menu is controlled by a checkbox with the id "check" below. I attempted to bind v-bind:class="[{'antiscroll': checkboxValue}]" to the body in HTML, and also in the main App.vue file, but it did not work as exp ...