Receiving the container's inherited height from its parent

After retrieving a dynamic number of elements from a database, I populate them into a list.

Below the list, there is a container that should fill up the remaining height of its parent container.

In the code snippet below, you can see my current layout. The div in #rightContent should occupy the entire remaining height, but I'm unsure how to achieve this.

Html:

<section>
        <aside>
            I'm a sidebar!
        </aside>
        <main>
            <article id="leftContent">
                <img src="http://fs1.directupload.net/images/150422/6x5qv8ik.png">
            </article>
            <article id="rightContent">
                <h1>Headline</h1>
                <hr>
                <ul>
                    <li>list1</li>
                    <li>list2</li>
                    <li>list3</li>
                </ul>
                <div>
                    <p>
                        a lot of text
                    </p>
                </div>
            </article>
        </main>
    </section>

CSS:

html, body {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
        }
        section {
            width: 100%;
            height: 100%;
        }
        section aside {
            position: fixed;
            right: 50px;
            width: 150px;
            background-color: firebrick;
            color: white;
            padding: 25px;
            height: 100%;
        }
        section main {
            position: relative;
            margin-right: 250px;
            left: 0;
            display: block;
            width: auto;
            border: 1px solid yellow;
        }
        section #leftContent {
            position: relative;
            display: block;
            border: 1px solid green;
            padding: 0;
            margin: 0;
            height: auto;
            width: 50%;
        }
        section #leftContent img {
            width: 100%;
            height: auto;
            display: block;
        }
        section #rightContent {
            position: absolute;
            display: inline-block;
            border: 1px solid blue;
            right: 0;
            margin-left: 50%;
            width: 49%;
            height: 100%;
            top: 0;
        }
        section #rightContent div {
            border: 1px solid violet;
            position: relative;
            margin-bottom: 0;
        }

http://jsfiddle.net/kzkpLg11/

The image provided illustrates the desired layout.

Answer №1

If you're looking to achieve this effect, consider following this approach: http://jsfiddle.net/kzkpLg12/1/

This method includes a few additional elements, but the browser compatibility should be satisfactory. The key lies in this specific CSS code snippet. I recommend examining the fiddle for further clarification.

.table {
    display: table;
    width: 100%;
    height: 100%;
}

.row {
    display: table-row;

}
.cell {
    display: table-cell;
}

Alternatively, you can address this issue using Flexbox. However, it may pose a slightly greater challenge.

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

Show off markdown formatting without the need for v-html

I run a unique type of platform that allows users to publish their own blog posts using a WYSIWYG editor, and then share them on the site. My top priority is to ensure security against XSS attacks, which is why I am looking for alternatives to using v-htm ...

Discovering the XPath for a Tag containing both span and div attributes

Can anyone assist me in finding the XPath for this specific element: <a class="channel_code" href="javascript:void(0)" oldtitle="<span style="text-decoration: underline; margin: 4px">CID:</span><div style="margin: 8px 4px 4px;">channe ...

Can multiple background images be handled by Firefox/Opera when positioned?

Encountering difficulties with certain background images not showing in Firefox and Opera, while all other browsers are working as expected (except IE, which always presents its own challenges). As of now, Opera is refusing to accept multiple background i ...

Looking to implement an underline effect using CSS for the active tab that mimics the hover effect already applied

How can I ensure that the underline on active tabs (Domov) matches the hover effect on other tabs? The border-bottom currently creates a border that is lower than the hover effect, resulting in inconsistent underlines as seen on this page - (try moving ...

When the li is clicked, replicate it and display it in a separate div

When a list item is clicked, I want to clone it and display it in a separate div. If another list item is clicked, the previously displayed item should be replaced with the newly clicked one. Below is my code along with a link to the codepen where you can ...

Receiving input in a "textbox" rather than using an alert message

Hey there! I managed to get this jquery code that displays the number of Facebook likes: <script> $.getJSON("https://graph.facebook.com/TuamadreLeggenda?callback=?", function(data) { alert("Likes: " + data.likes); }); </script> Is there ...

The NG8002 error has occurred, as it is not possible to connect to 'matDatepicker' because it is not a recognized attribute of 'input'

I've come across an issue while working on my Angular 15 application with Angular Material. I'm trying to incorporate a date picker, but after adding the code snippet below, I encountered an error. <mat-form-field appearance="outline" ...

Issue with Flexbox alignment: Second row does not line up with first row

When dealing with a flex container that has 4 items and you want 3 per row while keeping the container centered, it can be tricky. Using justify-content to center the container may result in the fourth item on the second row also being centered. To address ...

Do you have any ideas for enhancing this CSS?

Is there a more efficient method to select this? Essentially, the <div> has an id of cat1 and contains an <a> element with a matching class of cat1. I am looking for a better way to target the <a> element with the same class name as its ...

Implementing a configuration file into a client-side web application using asynchronous methods

Currently, I am facing a challenge with an SPA that is being developed using various custom components from different sources. The main issue at hand is how to initialize certain settings (such as Endpoint URLs) using a settings file that can be configure ...

Move the element to the top within the navigation bar

I am currently enhancing the appearance of my navbar by adding two "Stripes" on top. I am using bootstrapv4 as a base, but facing an issue where bootstrap centers my decorations. How can I prevent this? Below is a simplified version of my code: HTML: &l ...

Optimizing websites for search engines with multilingual capabilities

I am managing a multilingual website in German and English. http://www.example.com/en/posts/1 http://www.example.com/de/posts/1 When users visit the website without specifying the language in the URL http://www.example.com/posts/1, I use their browser l ...

Determining the presence of an HTML element in the correct manner

Is there a correct method for verifying the existence of an HTML element on a webpage? This is how I usually approach it: if (document.getElementById('container') !== null) {doThis()} What are your thoughts on this approach? Are there alte ...

The Vue instance methods provide a way to access and manipulate formatted properties

I am looking to implement a method that will generate the appropriate email format to be used as the href value in an anchor tag. This method should return the formatted string in the following format: "mailto:[email protected]". var facultyInformat ...

How can I disable the background color in Chrome autocomplete? Is there a way to make the background

There's a form on my website where the autocomplete feature shows a blue background color. The form itself has a semi-transparent white background. I managed to change the autofill color to white using this CSS property: -webkit-box-shadow: 0 ...

Upon submission of an HTML form, the user will be redirected to a specific page based on the value of the

I am looking to create a form that redirects to a specific page based on the value of a radio button selected upon submission. The challenge here is that I also need to pass input values onto the URL. For instance: (1) Initially, start on the form page w ...

Creating a responsive website using Tailwind and React

I have created a blog and I want to ensure it is responsive. My aim is to have a dropdown menu on the right side for mobile devices, featuring options for new profile and logout. On desktop mode, I prefer to have the about, new, and profile options in the ...

Tips for iterating through a collection of images

I am interested in creating a loop to iterate over the images folder and display them on the screen, similar to the code snippet below: <section id="photos"> <a target="_blank" href="images/1.jpg"> <img src="images/1.jpg ...

Is there a tool available to monitor the assets being loaded by a website?

During my site review of one of our properties, I noticed it is quite messy. The .js folder alone contains 123 files, and I am unsure of how many are actually being used since each page on the site calls specific dependencies in its own header. I am curio ...

Breaking the line within a text area field

Currently, I am working on a PHP form that includes a textarea where users can input data. This data is sent to the script using $_POST and then stored in a database. One issue I have encountered is that if a user populates the textarea but does not press ...