Expand and reposition other div boxes by manipulating the div box dimensions

For my current project, I am aiming for a three-box style page. However, I am facing an issue where the boxes float over each other when they auto-expand to fit the content inside. This is due to the positioning that I have set for them.

This is the HTML code:

<div class="content">
    <h2>Contact me</h2>
    <p>--content holder--</p>
</div>

<div class="content-bottom-left">
    <p>--content holder--</p>
</div>
<div class="content-bottom-right">
    <p>--content holder--</p>
</div>

Here is my CSS:

.content {
    background-color: 373737;
    top: 15%;
    width: 55%;
    right: 25%;
    position: absolute;
    overflow: hidden;
    margin-bottom: auto;
}

.content-bottom-left {
    background-color: 373737;
    width: 27%;
    left: 15%;
    top: 60%;
    position: absolute;
    overflow: hidden;
}

.content-bottom-right {
    background-color: 373737;
    width: 27%;
    right: 20%;
    top: 60%;
    position: absolute;
    overflow: hidden;
    }

Current Outcome: View Here

Answer №1

Make sure to incorporate the following CSS style into your Div elements:

display:inline-block;

Answer №2

Your current CSS is causing the elements to not align properly with the content above. To fix this issue, you can add the following code to both of the lower elements:

clear: both;

This will prevent any collisions with elements on their left and right, as mentioned by behnam bozorg in a previous comment. Additionally, consider removing the absolute positioning from the top element, as it is already being pushed down naturally.

.content-bottom-left {
    background-color: 373737;
    width: 27%;
    left: 15%;
    top: 60%;
    position: absolute;
    overflow: hidden;
}

.content-bottom-right {
    clear: both;
    display: inline-block;
    background-color: 373737;
    width: 27%;
    right: 20%;
    top: 60%;
    position: absolute;
    overflow: hidden;
}

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

Create a function that recursively maps data across multiple levels

Currently, I have a data mapping function that can take JSON data with up to four levels and transform it into a different format. The input JSON format looks like this: [{ "InventoryLevel2Id": "1234", "InventoryLevel2Information": "Test Data", ...

Retrieve image file from computer's hard drive

I have the following HTML Tags: <input id="bigPicture" name="bigPicture" type="file" value=""> <img src="test.png" id="test1"> User select file and I want to preview this file inside ...

Fading out, switching HTML, and fading back in

I'm encountering some challenges with a basic jQuery function that is supposed to fade an element out, switch the image inside it, and then fade back in. Here's how my function looks: function flipPage() { $("#leftPage").fadeOut("slow", ...

Developing apps using React Native on the Android Studio emulator

I am feeling a bit lost in the process. After visiting the React Native website, it seems like they are promoting Expo which I am not too keen on using right now. My search for information on setting up an Android simulator was futile. I have already insta ...

Is there a way to eliminate the lag time between hovering over this element and the start of the

https://jsfiddle.net/mrvyw1m3/ I am using CSS to clip a background GIF to text and encountering an issue. To ensure the GIF starts from the beginning on hover, I added a random string to the URL which causes a delay in displaying the GIF. During this dela ...

Counting the number of times a form is submitted using a submit button and storing the data

After researching for a few hours, I've gathered information on different techniques for storing data related to a submit button counter in a text file. <form action="/enquiry.php" method="post" name="form"> <label>Name *</label> &l ...

The Angular HTTP interceptor response function filters out the message parameter from the server's response

In my application, all server responses follow a structured format: response = { data: {}, status: STATUS_CODE, message: STRING_MESSAGE } I am exploring the use of Angular's HTTP response function to showcase specific response messages i ...

The functionality of the Angular JS Controller is hampered when integrated with a .js file

Having just started using Angular JS, I encountered an issue with a simple example I was working on. I wrote a script.js file with the following code:- var myApp = angular.module("myModule", []).controller("myController", function ($scope) { $scope.m ...

The pseudo element 'not' in CSS is currently not functioning as expected when applied to an anchor tag

When working with CSS, I encountered an issue while trying to apply a pseudo element on hover and active states of anchor tags. Unfortunately, my code was not producing the desired outcome. a:not(a[name="nobgcolor"]):hover{color:#ffff35;background-color:# ...

The recommended approach following the addition, removal, or modification of a record in the database

Let's consider a practical and logical question regarding React state management. Imagine we have a database with 10 users and 100 books in it. Now, let's say we have a simple application where we load all book information on the homepage using ...

Exploring the intricacies of .$on() in AngularJS

Recently, in a tutorial I came across the following code snippet: $rootScope.$on('abc',function(event, next, current){ }); This has raised some questions for me. Namely, what exactly does the .$on() function do? And why is it prefixed with a $ ...

Encountering compilation issues with Jest in Vue project, yet the tests are successfully passing

I'm currently facing an issue with my module building while using jest with vue.js for testing. The tests are running successfully, but the module building is failing unexpectedly. I have provided my code snippet below and would greatly appreciate any ...

Execute PHP script via hyperlink

Is there a way for me to have a small PHP script that only gets the current page URL and echoes it when a user clicks on a submit button? I'm struggling because there are no other form items on the page, making it difficult to trigger the script. I th ...

Text disappears from navbar after selecting anchor link

Recently, I've been experimenting with Twitter Bootstrap and have found it to be quite delightful. I managed to create a fixed navbar that sits at the top of my website. Inside this navbar, you'll find my logo, a header, a few links, and a dropd ...

loading preloaded fonts at the optimal moment

My webfonts are loaded using Webfontloader as shown below: <script src="//ajax.googleapis.com/ajax/libs/webfont/1.5.10/webfont.js"></script> <script> WebFont.load({ custom: { families: ['BlenderProBook' ...

What changes can I expect if I switch from inline to block display for a table?

Why are border-spacing and border-collapse still working even when I set the display property of the table element to block? I thought these properties only worked when the display was set to table, but it's still functioning. Why is that? I didn&apo ...

Display a PDF file within an IFrame using JavaScript and then print it

Why is it so challenging to achieve? I've dedicated 48 hours to research this, yet it seems impossible! Although recent Chrome versions allow the parent window to access PDFs in iframes, both FF and IE prevent any interaction with the iframe that dis ...

Establish a constant height while maintaining the original width dimensions

Is there a way to make an image maintain a specific height while also adjusting its width according to the user's screen size? Below is the CSS for the image: #cafe { max-width: 100%; height: 700px; } See the resulting output: https://i.sstatic ...

Adjust the width of an anchor tag

I have been experimenting with different solutions and unfortunately, I have not been successful in resolving the issue at hand. While working on a WordPress website, I encountered some challenges. Despite having some knowledge in this area, I am struggli ...

Ways to create a rounded pane for Highchart's Solidgauge

I've noticed that my arcs have rounded edges, but the pane is flat. Is there a way to make the pane rounded as well? I am currently using Highcharts v9.1.2. I tried using "stroke-linejoin: "round"", but it didn't work. https://i.sstati ...