Expanding responsive div overlaps another div

I am struggling to make a div on the right disappear as the view gets smaller, leaving the left div to take up the entire parent container. I have tried using absolute positioning but it causes the div to pop out of the parent. Transition and z-index did not work either. Any suggestions?

.box {
background-color: #F28B20;
border-radius: 5px;
height: auto;
margin-bottom: 150px;
width: 80%;
display: inline-block;
box-shadow: 10px 10px 5px #888888;
background-image: url("../Images/logo_faded_background.png");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.sidebar {
float: right;
width: 29%;
margin-left: 0;
margin-right: 3%;
text-align: left;
color: #171581;
}
.whiteBoxHalf {
float: left;
width: 54%;
background: rgba(255, 255, 255, 0.6);
border-color: #000000;
border-width: 1px;
border-style: solid;
margin-left: 3%;
margin-right: 5%;
margin-bottom: 15px;
padding: 15px;
}
@media (max-width: 1019px) {
.header {
font-size: small;
}

.header li a {
padding: 20px 10px;
}

.sidebar {
display: none;
}

.whiteBoxHalf {
width: 95%;
}
}
<div class="box">
<div class="row">
<div class="whiteBoxHalf"></div>
<div class="sidebar"></div>
</div>
</div>

Answer №1

If you're looking to achieve a layout like this, utilizing display:table-row and overflow:hidden could be the way to go. Explore more in this detailed JSFiddle demo.

.box, .whiteBoxHalf {
    min-width: 300px;
}
.box {
    background-color: #F28B20;
    border-radius: 5px;
    margin-bottom: 150px;
    width: 80%;
    box-shadow: 10px 10px 5px #888888;
    overflow: hidden;
}
.row {
    display: table-row;
}
.sidebar {
    display: table-cell;
    margin-left: 0;
    margin-right: 3%;
    text-align: left;
    color: #171581;
    background: green;
}
.whiteBoxHalf {
    display: table-cell;
    background: rgba(255, 255, 255, 0.6);
    border-color: #000000;
    border-width: 1px;
    border-style: solid;
    margin-left: 3%;
    margin-right: 5%;
    margin-bottom: 15px;
    padding: 15px;
    width: 60%;
    box-sizing: border-box;
}
<div class="box">
    <div class="row">
        <div class="whiteBoxHalf">
            <p>
Here is a creatively populated area where imaginative content can be placed for readers' delight. Feel free to express your ideas while showcasing design skills with CSS tricks.
            </p>
        </div>
        <div class="sidebar">
            <p>
This sidebar segment provides additional information that complements the main content. It's the spot to include any supplementary details relevant to the primary message.
            </p>
        </div>
    </div>
</div>

To customize the layout further based on screen sizes, consider employing media queries. This snippet exemplifies how to adjust the visibility of the sidebar at specific resolutions:

.sidebar {
    display: none;
}
@media (min-width: 800px) {
    .sidebar {
        display: block;
    }
}

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

Enhance your Coda experience with custom Jade and Stylus syntax highlighting!

Has anyone successfully tried using both Haml and Less? I attempted to use them since they are similar, but unfortunately had no luck. The Less one appeared in modes, while the Haml one didn't even show up. I also added the file type in the preferenc ...

Error encountered when submitting HTML form containing file input: ERR_CONNECTION_RESET

I'm encountering an issue while trying to upload an image using an HTML form. Once I submit the form, after approximately 3-5 seconds, I receive the following error on the browser: ERR_CONNECTION_RESET The problem seems to arise with images larger ...

Plan a website refresh using Dreamweaver

As the website manager for a resort, it's crucial to keep the activities section updated daily. However, there are days when activities run late and I'm not available to make updates. Is there a feature in Dreamweaver CS 5.5 that allows me to sc ...

Is there a way to transition an element from a fixed layout position to an absolute layout position through animation?

I am looking to create a dynamic animation effect for a button within a form. The goal is for the button to move to the center of the form, while simultaneously undergoing a horizontal flip using a scale transform. During the midpoint of this animation, I ...

Understanding how to extract a specific value key from a JSON object in Typescript while utilizing Angular can greatly

I'm currently facing a challenge in Typescript with Angular where I need to retrieve a specific value from a JSON constant. While I am aware of the performance implications, I am wondering if there is a more efficient way to access this value within t ...

Issue with error handling while using HTML5 geolocation in Chrome browser

I have a basic map that is supposed to load centered on the user's current location if they allow HTML5 geolocation. There is a fallback function in place for users who choose not to share their location, but it seems to be malfunctioning. Here is th ...

Automatically update div content using jQuery including an AJAX request for loading

I have successfully implemented a method for loading output from now_playing.php (shoutcast now playing content) using a jQuery include ajax call, as recommended in this answer on Stack Overflow. Here is my code: <script> $(function(){ $("#now_ ...

Can the font-weight of FontAwesome icons be altered?

Is there a method to decrease the weight of one of the FontAwesome icons on my website? It appears much heavier than the font style I am currently utilizing. Here is how it currently displays: : Not very appealing, right? I attempted adjusting the font-w ...

What might be causing the invisibility of a particular div element?

Here is the layout in the div element: <div class=" wrap clear"> <div class="block pink float"></div> <div class="block blue float"></div> <div class="block orange float"& ...

Having trouble with the WordPress style file not functioning properly

I'm currently facing an issue while trying to upload a CSS file and a JavaScript file to a custom theme on WordPress. When I open the webpage, nothing appears and there are no elements displayed. However, when I delete the functions.php file, the webp ...

Incorporate a share (contact) feature for WhatsApp and various messaging platforms on your website

Is there a way to include a share button on my website's page? I found that we can add a send SMS feature to mobile HTML pages using the following code: <a href="sms:?body=...">title</a> How can we implement this code for sharin ...

What could be causing a CSS transition to fail when hovering over a different image source?

Looking to change the image source of an <a> tag when hovering over it, while also incorporating a transition effect. It seems that the transition effect is effective with the background-image property for a <div> tag, but not with the conten ...

Using PHP variables within the writeHTML() function in TCPDF

I'm attempting to include 3 different HTML strings in a PDF using TCPDF I have 3 variables that hold HTML strings. However, the code below only writes the value of $var3 to the PDF. Is there a way to display the values of all 3 variables in the PDF ...

Utilizing C# ASP.NET to Extract Data from a Web Page Post JavaScript Execution

Looking to extract all links from a web page in order to review where cookies are being set for compliance with UK legislation. In an effort to streamline the process, I am exploring automation options to save time. However, a challenge I am facing is tha ...

jscrollpane does not work properly in Firefox, but it functions correctly in Chrome

I am currently utilizing jScrollpane to display a combination of images and a div in a horizontal format. While I have successfully implemented it on Chrome, it appears that Firefox is not applying the CSS correctly to prevent images from wrapping, resulti ...

The border-radius property in Bootstrap buttons causes unwanted white border artifacts to appear

Strange anomalies in the borders of my Bootstrap buttons caught my attention recently. Upon further investigation, I realized that this issue is not linked to my custom styles or theme, as the artifacts can also be seen on the Bootstrap button documentatio ...

Top Tip for conditionally rendering a styled component inside or outside a wrapper, depending on the screen width

Can anyone help me with this coding question? I'm currently trying to determine the most efficient way to conditionally place the code inside or outside of the wrapper. However, I am unsure what the best practice for this would be. This process seems ...

Transform HTML invoices into emails

I am currently working on developing an ERP system. I have an HTML invoice that needs to be converted into a PDF and sent via email. My question is regarding how to construct the invoice using jQuery & AJAX, convert it into a PDF format, and then send it ...

What is the method for placing a title in the initial column with the help of v-simple-table from Vuetify.js?

I am interested in using the v-simple-table UI component from Vuetify.js to create a table similar to the one shown below. https://i.sstatic.net/QNdpJ.png After creating the code in codesandbox and previewing the output, I noticed that the title is not a ...

Switch the hue when altered

My document contains various input elements such as text, radio buttons, and checkboxes. I want each of these elements to change color when a change is made. This is the method I am currently using: $("document").on('click', 'change', ...