Struggling with CSS layout!

Posted on 2015-02-03
Last Modified: 2015-02-04
Hi all,

I am trying to create a menu on the left-hand side of a web page.
The menu should contain a number of sections laid out as follows:
LayoutDepending on the overall height of the 4 stacked panels on the left (the 3rd one could grow quite tall) the right one needs to grow to the entire height.
This is fairly straightforward as a table, but it looks like DIV and CSS is the correct way to go.
I have got so far and struggling with the right column!
<!DOCTYPE html>
    <link rel="stylesheet" type="text/css" href="test.css">
<div id="lhs_container">
	<div id="rhs1">X</div>
	<div id="lhs1">Top Bit</div>
	<div id="lhs2">Another Top Bit</div>
	<div id="lhs3">Area that contains a dymamic menu
<br />This may get quite tall
<br />This may get quite tall
<br />This may get quite tall
<br />This may get quite tall
<br />This may get quite tall
	<div id="lhs4">Bottom Bit</div>

Open in new window

	height: 100%;
	background-color: red;
	width: 300px;
	background-color: yellow;
	background-color: purple;
	background-color: orange;
	background-color: blue;
	height: 100%;
	background-color: green;
	width: 20px;
	left: 280px;

Open in new window

I have tried several combination of CSS but can't get it right :-(

Any help would be appreciated.


Question by:jatkin
LVL 19

Expert Comment

ID: 40586179
when you say you're having trouble with it, what exactly is wrong?
It is growing with your content as it is, but I suspect you're looking for something else?

Author Comment

ID: 40586221

Thanks for the comment...

I'd like the right hand column (rhs1) to be the full height of the 4 on the left (as the image)
The code above actually shows rhs1 at the top.

I have played around with floating the panels, but I can't get them to interact correctly with the parent container.

I guess I am missing something silly, but I can't see it!
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 200 total points
ID: 40586243
I think you may check out the  "display: flex", see this one:
simpler than floating...
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

LVL 52

Accepted Solution

Carl Tawn earned 300 total points
ID: 40586257
Based on your image, I would use something like the following for the basic structure:
<!doctype html>
  <style type="text/css" rel="stylesheet">

    html, body { height: 100%; padding: 0; margin: 0; }

    .container { height: 100%; width: 100%; background-color:red; }
    .rhs { width: 20%; height: 100%; float: right; overflow: auto; background-color: yellow; }

    .lhs1 { height: 10%; background-color: orange; }
    .lhs2 { height: 70%; background-color: green; }
    .lhs3 { height: 10%; background-color: blue; }
    .lhs4 { height: 10%; background-color: silver; }


  <div class="container">

    <div class="rhs">

    <div class="lhs1">
    <div class="lhs2">
    <div class="lhs3">
    <div class="lhs4">


Open in new window

LVL 53

Expert Comment

ID: 40586629
Actually the cleaner way to do it is to make rhs1 the last element in the container, and then float it left in stead of right.  You should also allow for 3 or 4 pixels of slack to account for the minor rendering differences in browsers.  If you want it non-responsive then pixels is fine but for responsive you should probably use vh/vw as the unit of measure, though em might also be an option.  Using percentages will make it adaptive, but not responsive.


Author Closing Comment

ID: 40588333
Thanks for the input.
I think Carl's answer will suit what I need for now, but Guy's suggestion of using Flex looks like a sensible direction.
I will look into this one further, but for now I hope splitting the points is okay?

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
HTML button disabled 11 36
Hovering effect 9 29
Urgent Help with HTML CSS Positioning 9 20
Printing a Google Form 2 3
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now