Divs do not stack as expected, but rather overlap each other

I am encountering an issue where the right-column1 does not move under the left-column1 when the screen size is limited for both to display side by side. I have tried various overflow options and media queries, setting them to 100% when the browser or device cannot accommodate both columns horizontally, but the right column still overlaps the left one without shifting down as desired. This used to work flawlessly a few weeks ago, so I suspect that I may have unintentionally modified something in my code.

The setup involves the left column containing an image and the right column holding a link, but this configuration also fails to function properly.

Could it be that I am overlooking something in my code?

<div class="container1">

<div class="left-column1">

<p class="title">More Wallpapers</p>
<div id="wn">
    <div id="lyr1">
        <div id="inner1">

        </div>

    </div>
</div>  <!-- end wn div --></div>

<div class="right-column1"><div class="fb-facepile" data-href="https://www.facebook.com/Techagesite.Free.Mobile.Wallpapers" data-action="like" data-width="200" data-height="64" data-max-rows="2" data-colorscheme="dark" data-size="medium" data-show-count="true"></div></div>

</div>  

.container1 {
width: 100%;

}
.left-column1 {
width: 50%;
float:left;
}
.right-column1 {
width:50%;
float:left;
}

Answer №1

To solve the issue, simply remove the width: 50%; property from .left-column1.

Answer №2

The reason for this issue is that your image is expanding beyond the boundaries of your div element. To fix this problem, simply include the max-width property in your CSS code.

.left-column1 img{
    max-width: 100%;
}

Check out the DEMO here

Answer №3

Utilizing media queries, I successfully implemented a stacked layout.

@media (max-width: 768px) {
.left-column1 {
    width:100%;
}
.right-column1 {
    width:100%;
}
}

http://jsfiddle.net/J5Q4u/

Are you satisfied with this solution?

Answer №4

Set the image to have a maximum width and automatically adjust its height. Check out this example on jsFiddle.

.container1 {
  width: 100%;
}
.left-column1 {
  width: 50%;
  float:left;
}
.right-column1 {
  width:50%;
  float:left;
}
.left-column1 img { 
  max-width:100%; height:auto; 
}

To prevent text columns from becoming too small, use a media query:

@media (max-width: 300px) {
.container1 > div { width:100%; }
}

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

Drag a spinning cube using CSS and Jquery when the mouse is pressed

I'm attempting to develop a dynamic rotating cube that users can manipulate to their desired side by clicking and dragging on the cube. Currently, I have functionality where the cube moves as the mouse cursor moves across the screen, but this results ...

Utilize Jquery to locate and update the text of all div elements that have an empty id attribute

I need help with a task involving a list of divs, some with ids and some without. My goal is to identify all the divs within a specific class that have empty ids and change their inner text to say "no data available". Can this be done? My attempt using $( ...

Is there a way to integrate the distanceTo function from Leaflet into my own custom library that I am planning to develop?

I am currently incorporating leaflet into my project and I have encountered the distanceTo method which calculates the distance between two coordinates. My goal is to create a separate JS file with a function named getDistance() where I can house the logic ...

Activate the display by utilizing the getElementsByClassName method

In my design, I'd like to have the "Don't have an account?" line trigger the display of the .registrybox class when clicked. However, the script I've written doesn't seem to be working as intended. The script is meant to hide the .login ...

How can I perform a MySQL UPDATE using 2 parameters received from an AJAX request ($_POST)?

I am currently working on an AJAX call that updates a row in the database based on the ID (pid=38) and changes the value of a column to NULL depending on the button clicked (taskimg0). I have managed to make it work by hardcoding the value $_POST['dtf ...

Incorrect font displayed on Bootstrap button after inserting hyperlink

This section contains my HTML code snippet: <div class="panel panel-default"> <div class="panel-heading"> Records <button type="button" class="btn btn-xs btn-success pull-right" id="command-add" data-row-id="1"> ...

Tips for positioning a navigation bar in the center for various screen resolutions

After hours of searching, I still can't find a solution to my problem. I'm new to this, and on my main monitor, everything looks centered just fine. 1920x1080: View larger image But on my 1280x1024 monitor: View smaller image As you can see, i ...

Guide to creating a dynamic illumination using CSS, HTML, and JS

Can you help me create a unique lighting effect for a specific section of my webpage? I'm curious about the techniques needed to achieve a similar effect as seen on another webpage. Is it feasible to create this effect using only CSS and HTML, or are ...

Ways to display the values of angular variables within ng-bind-html

Converting HTML content from a database saved as varchar to front end JavaScript code can be tricky. The content is stored in a variable called vm.htmlContent and must be displayed as HTML on a web page. To achieve this, the ng-bind-html angular directive ...

Can you explain the significance of the "--" within CSS selectors?

My CSS skills are not the greatest and I stumbled upon a snippet of code that is puzzling to me. .grid-product__title.grid-product__title--body:hover { text-decoration: underline; } I checked MDN and it usually defines a reusable property, like a vari ...

What is the best way to develop a JavaScript function that divides the total width by the number of table headers (`th`)?

I recently came across this amazing scrollable table on a website, but I'm facing an issue with resizing the headers equally. Due to my lack of knowledge in JavaScript, I'm uncertain about how to tackle this problem. My intuition tells me that a ...

Is it conceivable that Rails may be rendering HTML at a slower rate compared to static

When using a Rails layout, you can include HTML tags to render images like this: <%= image_tag("logo.png", :alt => "Sample App", :class => "round") %> This will generate the following HTML code: <img alt="Sample App" class="round" src="/i ...

Changing the order on mobile devices in Bootstrap 4: A quick guide

Currently, I am working on a responsive layout using Bootstrap 4 with two columns. Each column contains a total of 9 divs - four in the first column and five in the second column. My goal is to rearrange the order of the divs within the columns when the vi ...

What's preventing my link from opening?

I've written this code for two tabs: <li> <a href="#gallery_place" role="tab" data-toggle="tab"> <i class="fa fa-picture-o"></i> <?php _e("Gallery", ET_DOMAIN); ?> </a> </li> <li> <a href ...

Customized content is delivered to every client in real-time through Meteor

I am currently working on creating a multiplayer snake game using three.js and meteor. So far, it allows one player to control one out of the three snakes available. However, there is an issue where players cannot see each other's movements on their s ...

Should data be stored in HTML5 using data-* attributes?

I have encountered a scenario like this: The screen contains numerous 'Rocks', each with attributes such as weight, points, and velocity. When a rock is clicked, its attributes are displayed. Currently, I have stored all the rocks' attribu ...

Python code to locate images within HTML source code

Searching for images in an html source code can be tricky. I prefer using regex over the html.parser method, but I'm open to learning if you can explain it simply like you would to a child. I wish I could use beautifulsoup, but mastering the hard way ...

The Dropdown Menu is displaying correctly in Chrome, but is being obscured by an image in Safari

While the Nav dropdown menu functions correctly in Chrome, an issue arises in Safari where the image covers the rest of the menu. This discrepancy between browsers is puzzling. Why does this problem only occur in Safari when it displays properly in Chrome? ...

Unexpected results from CSS nth-child selector

Creating a dynamic table and updating its cell values accordingly while handling asynchronous returns brings about some challenges. The number of columns can vary, but the rows remain constant within this section of the table (7 rows). When trying to upda ...

Is the latest version of three.js not compatible with Blender models?

In the past, I would export blender models to use them with three.js, starting from version r47. However, after updating to the latest release, r49, it seems that the same code that used to display the model in the browser no longer works. Should I rever ...