What is the best way to create this specific layout using CSS?

Describing a layout with fixed lengths at the edges and a fluid main content container. I'm struggling to achieve it and can't figure out why.

Check out my jsfiddle http://jsfiddle.net/JyXtR/3/ for reference.

I aim to achieve this desired layout: https://i.sstatic.net/j7hpS.png

The goal is to make the main content and content on the right's containers have equal height regardless of their content length.

Is CSS not suitable for layouts like these, or am I just missing something crucial?

Answer №1

Check out the Demo here. Utilize display:inline-block;, and make adjustments to the width of both elements. I have manually set the height of the main div to 300px for better display. Keep in mind that your inner elements should not exceed height:100%, as it will prevent scrolling on the main container.

It might be feasible to assign a height attribute to a display:table-cell element, but the suggested solution should suffice for your needs.

Update available at: http://jsfiddle.net/22D4F/4/

Answer №2

Now is the time to take a look. However, there is an issue that cannot be fixed solely with CSS. The problem arises when the layout doesn't function correctly if the sidebar is longer than the content. This issue can only be resolved with JavaScript, so it is imperative that you establish a minimum height for the content div equal to the sidebar's content height. Check out this link for more information.

Answer №3

In order to achieve the desired layout, make sure to apply 'float:left' to your chat div and set the width of the online users div to 200px;
UPDATE: Don't forget to include overflow:auto for #main as well.

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

Do you want your image to appear visually pleasing on all screen sizes?

Currently, I am working on a mobile website and encountering an issue with the image banner. For tablets, it should look like this: However, when viewed on mobile, it needs to appear as follows: This is the code I have implemented so far: <div class ...

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

JSFiddle showcasing the Bootstrap grid system

I'm having trouble implementing bootstrap's grid system on jsfiddle. Check it out on jsfiddle I've tried using the example from the bootstrap documentation: <div class="row"> <div class="col-md-1">.col-md-1</div> ...

Showcasing an item hidden behind text and a dropdown menu

I have made changes to the background image in my Wordpress theme and now I want to display another image on top of the white content area. To achieve this, I used the following code: img style="position: absolute; top:244px; left: 220px;" src="http://ww ...

Styling unique text in an HTML text area

In the process of creating a web-based SQL editor, I am looking for a way to apply unique styling to certain SQL keywords (such as select, create, from) while a user is typing. Is there a way to achieve this using HTML alone? Alternatively, are there any ...

Can you explain the significance of the "style.css?ver=1" tag?

Recently, I noticed that certain websites incorporate a CSS tag such as style.css?ver=1. Can you explain the significance of this? What exactly is the purpose of adding ?ver=1 to the CSS tag? Could you provide instructions on how to implement this in cod ...

What could be causing the Php Media Gallery to malfunction?

I am currently working on setting up a video/image gallery to simplify the process of uploading videos/images. This gallery will include thumbnail images of the videos/images along with a brief description. When the thumbnail is clicked, the image/video wi ...

Scrolling the inner div with the main scrollbar before navigating through the rest of the page

In my hero div, I have a container div called right-col that contains two inner divs. These inner divs are sticky, creating the effect of cards sliding up when the container div is scrolled. This is the HTML structure: <!DOCTYPE html> <html lang= ...

Can we implement a variety of site designs based on the size of the window?

Utilizing media queries allows us to modify the CSS for various screen sizes. My inquiry is: can we switch to a completely different page layout (or View in MVC) when the window size, specifically when the width is less than 500? Assuming that the control ...

Creating space between columns without the use of left and right gutters

I needed to adjust the spacing between columns, but the solution I found caused an overflow issue. I want to fix this overflow problem without using overflow: hidden because it conflicts with other components: .row { margin: 0 -25px; } .col { paddi ...

the display:block property totally ruins my aesthetic

I'm facing an issue with filtering a table using an input box within one of the elements. Whenever I type something in the input box, the table automatically filters its rows based on the input. The strange thing is that when I try to use display:bl ...

Upon clicking on a different div, a div will elegantly slide down from above the footer

I'm struggling with sliding a div from the bottom of the page. Here is my JSFIDDLE Currently, when I click on the blue box (arrow-hover), the div slides up (box-main). However, to hide the div (box-main) again, I have to click inside the box-main d ...

How to make divs occupy the entire space of a parent div?

I've been scouring the website for a solution, but nothing I've found has been helpful. I'm attempting to create a grid within a containing div where a default (and eventually user-specified) number of divs will fill up the space. I'm t ...

The footer is refusing to show up at the bottom of the page

Why is my footer floating in the middle of the page? It's driving me crazy. I really hope it's a quick fix. I've searched online and all the solutions point to having a fixed footer, but I don't want that because it looks bad on smaller ...

Using the margin-top property in CSS will only take effect if a border has been declared

Greetings, I have been noticing a strange occurrence lately, and I finally decided to seek some answers. Below is a snippet of my basic HTML code: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Page Title< ...

``Look at that cool feature - a stationary header and footer that stay in place

I'm seeking advice on how to design a website with a fixed header and footer that remain consistent across all pages, with only the content area altering. I've come across a site as an example - , but couldn't figure out how it was done even ...

Creating two distinct SVG images without interfering with other div elements can be accomplished by properly structuring the HTML

I am working on a page layout that consists of three main sections. There is a top bar with buttons, a middle section that needs to load different pages using jQuery, and a bottom bar with additional buttons. On top of all this are floating windows that op ...

Issues with the functionality of Bootstrap

Upon loading the page, I am encountering an issue with a collapse on the 'main' id. It fails to collapse initially and only functions correctly after being clicked. I have not utilized 'collapse in', so I am unsure why this behavior per ...

Using a global CSS file in Angular can lead to large module bundles being emitted by Webpack

In our Angular application generated with angular-cli, we are utilizing various global styles and imports defined in the styles.scss file (which begins with /* You can add global styles to this file, and also import other style files */ if that sounds fami ...

What are the best methods for preserving paint color when changing wheel styles, and vice versa?

I posted this query about a year ago, but I did not have a fiddle prepared at that time and my question was not as well articulated as it could have been. Despite that, many people came forward to offer their help, and I am truly grateful for that. This ti ...