Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Struggling with CSS layout!

Posted on 2015-02-03
6
109 Views
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!
HTML
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="test.css">
</head>
<body>
<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>
	<div id="lhs4">Bottom Bit</div>
</div>
</body>
</html>

Open in new window

CSS
#lhs_container{
	height: 100%;
	background-color: red;
	width: 300px;
}
#lhs1{
	height:30px;
	background-color: yellow;
	width:270px;
}
#lhs2{
	height:30px;
	background-color: purple;
	width:270px;
}
#lhs3{
	background-color: orange;
	width:270px;
}
#lhs4{
	height:30px;
	background-color: blue;
	width:270px;
}
#rhs1{
	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.

Thanks,

James
0
Comment
Question by:jatkin
6 Comments
 
LVL 19

Expert Comment

by:Montoya
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?
0
 
LVL 4

Author Comment

by:jatkin
ID: 40586221
Hi,

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!
0
 
LVL 143

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:
http://css-tricks.com/snippets/css/a-guide-to-flexbox/
simpler than floating...
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 52

Accepted Solution

by:
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>
<html>
<head>
  <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; }

  </style>
</head>
<body>

  <div class="container">

    <div class="rhs">
    </div>

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

  </div>

Open in new window

0
 
LVL 53

Expert Comment

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

Cd&
0
 
LVL 4

Author Closing Comment

by:jatkin
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?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS: How do I override in-line styling 11 25
ASP server side get value 15 35
Html value of radio 14 28
GET error with Font Awesome 3 14
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

860 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