Question

Using 'em' for a column width in a resizable layout

Asked by: rstaveley

I have a 2-column display. The left column is a navigation column and the right is content.

I have sized the width of the left column in 'em', so that it scales with font height when you zoom. This is good enough, because the navigation text zooms with the text when you Ctrl-[+]. The right column should take the remaining available space.

However, I can't figure out how to make the size of the right hand column take all of the available remaining space. The total width is not known (i.e. "liquid" layout) and using % takes the %age of the parent DIV. As thinks stand, by right column keeps dropping below the left nav, when my zoom is too high.

/* Left column - Navigation area */ 
div.left-column-wrapper {
	text-align: left;
	float: left;
	width: 12em;	/* Width proportional to font height works OK for me */
	padding: 5px;   /* I know these px values would be better in em too */
}
div.left-column-container {
	border: 1px dotted #b5c780;
	margin: 0;
	padding: 5px;
} 
/* Right column - Content area */ 
div.right-column-wrapper {
	float: left;
	display: inline;
	text-align: left;
	clear: none;
	padding: 5px;
	width: 36em;	/* <- I'd like this to use the rest of the available width in my resizeable window */
}
div.right-column-container {
	padding: 5px;
	margin: 0;
	border: 1px dotted #b5c780;
}

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-02 at 13:20:41ID24865241
Tags

css

,

em

,

liquid

Topic

Cascading Style Sheets (CSS)

Participating Experts
1
Points
500
Comments
9

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Resizable Fonts
    For some reason, some of my styles resize based upon the viewer setting the font size preferences in Internet Explorer or Mozilla. Other fonts seem unaffected by the selections made by the user. Here is my css: a:link { color: #000000 } .main { font-family: Ar...
  2. divs
    I want to use javascripts with divs stuffs but my whole layout is in tables is there an easy way so they are all converted into divs?? <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="Connections/spring_temp.asp" --> <% ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: dachusaPosted on 2009-11-02 at 14:53:46ID: 25724630

try using width:auto on the right container

 

by: rstaveleyPosted on 2009-11-02 at 15:29:50ID: 25724879

That makes it go underneath the left column.

 

by: dachusaPosted on 2009-11-02 at 15:33:00ID: 25724896

is the parent of the left and right column containers set to 100% width?  also can you post the html model you are using to see the way you have it nested

 

by: rstaveleyPosted on 2009-11-02 at 15:46:04ID: 25724980

Oh I see - make the left-margin of the right column equal to the left column width.

/* Left column - Navigation area */ 
div.left-column-wrapper {
	float: left;
	text-align: left;
	width: 12em;			/* Using em for liquid layout */
	padding: 5px;
}
div.left-column-container {
	border: 1px dotted #b5c780;
	margin: 0;
	padding: 5px;
} 
/* Right column - Content area */ 
div.right-column-wrapper {
	text-align: left;
	margin-left: 12em;
	padding: 5px;
}
div.right-column-container {
	padding: 5px;
	margin: 0;
	border: 1px dotted #b5c780;
}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:

Select allOpen in new window

 

by: rstaveleyPosted on 2009-11-02 at 15:55:20ID: 25725029

I'd be interested if you reckon this is portable.

Here it is in full:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Test"/>
<meta name="keywords" content="test"/>
<title>Test</title>
<meta name="generator" content="Test-0.1" />
<meta name="robots" content="noindex, nofollow" />
<link rel="shortcut icon" href="img/favicon.ico" />
<style type="text/css"> 
/* Site wrapper and container */ 
html * {
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
}
body {
	margin: 0;
	padding: 10px;
	font-family: "Segoe UI", Tahoma, Geneva, Verdana, Arial, Helvetica;
	color: #555555;
	background-color: #555555;
	text-align: center;
} 
/* Site fills the page */ 
div.site-wrapper {
	width: 100%;
	margin: 0px;
	display: table;
	padding: 5px;
	background-color: #ffffff;
} 
div.site-container {
	width: 100%;
	margin: 0px;
	border: 1px solid #b5c780;
	padding: 10px;
	display: inline;
	float: left;
} 
/* Top area for titles */ 
div.top-wrapper {
	clear: both;
}
div.top-container {
	background: #ffffff url(../img/logo.png) no-repeat top left;
	margin: 0;
	padding: 5px 5px 15px 5px;	/* Top, right, bottom, left */
} 
/* Middle area for content and sidebars */ 
div.middle-wrapper {
	clear: both;
}
div.middle-container {
	margin: 5px 10px 5px 10px;	/* Top, right, bottom, left */
	text-align: left;
} 
/* Left column - Navigation area */ 
div.left-column-wrapper {
	float: left;
	text-align: left;
	width: 12em;			/* Using em for liquid layout */
	padding: 5px;
}
div.left-column-container {
	border: 1px dotted #b5c780;
	margin: 0;
	padding: 5px;
} 
/* Right column - Content area */ 
div.right-column-wrapper {
	text-align: left;
	margin-left: 12em;
	padding: 5px;
}
div.right-column-container {
	padding: 5px;
	margin: 0;
	border: 1px dotted #b5c780;
} 
/* Bottom area for copyrights etc */ 
div.bottom-wrapper {
	clear: both;
}
div.bottom-container {
	margin: 0;
	padding: 5px 5px 5px 5px;	/* Top, right, bottom, left */
} 
h1,h2,h3,h4,h5 {
	color: #7aa543;
}
h1 {
	font-size: 1.5em;
}
h2 {
	font-size: 1.2em;
} 
/* Horizontal rule */ 
hr {
	color: #7aa543;
	background-color: #555555;
	height: 1px;
} 
/* Anchors handling */ 
a {
	color: #7aa543;
	text-decoration: none;
}
a:hover {
	color: #555555;
} 
p.footer {
	font-size: 0.7em;
} 
span.lighter {
	font-weight: lighter;
} 
span.heavier {
	font-weight: bolder;
} 
span.invisible {
	color: #ffffff;
} 
ul.nav {
	margin: 0;
	padding: 0;
	list-style: none;
	text-align: left;
} 
ul.nav li {
	clear: left;
	display: block;
	margin: 0;
	padding: 0;
} 
ul.nav li.selected {
	background-color: #7aa543;
	color: #ffffff;
} 
</style>
</head>
<body> 
<!-- Site begin -->
<div class="site-wrapper"><div class="site-container"> 
<!-- Top begin -->
<div class="top-wrapper"><div class="top-container"> 
<h1>Test <span class="lighter">- Test</span></h1><hr/> 
</div></div>
<!-- Top end --> 
<!-- Middle area begin -->
<div class="middle-wrapper"><div class="middle-container"> 
<!-- Left column begin -->
<div class="left-column-wrapper"><div class="left-column-container"> 
<h2>Navigate</h2> 
<!--
<p>Select an option.</p>
--> 
<ul class="nav">
	<li class="selected">&nbsp;<span class="heavier">&raquo;</span> Main</li>
	<li>&nbsp;<a href="main.html" title="Manage orders"><span class="heavier">&raquo;</span> Orders</a></li>
	<li>&nbsp;<a href="main.html" title="Manage products"><span class="heavier">&raquo;</span> Products</a></li>
	<li>&nbsp;<a href="main.html" title="Managage categories"><span class="heavier">&raquo;</span> Categories</a></li>
	<li>&nbsp;<a href="main.html" title="Manage sources"><span class="heavier">&raquo;</span> Sources</a></li>
	<li>&nbsp;<a href="main.html" title="Manage discount codes"><span class="heavier">&raquo;</span> Discount Codes</a></li>
</ul> 
</div></div>
<!-- Left column end --> 
<!-- Right column begin -->
<div class="right-column-wrapper"><div class="right-column-container"> 
<h2>Main</h2> 
<p>Welcome to the test.</p> 
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> 
</div></div>
<!-- Right column end --> 
</div></div>
<!-- Middle area end --> 
<!-- Bottom begin -->
<div class="bottom-wrapper"><div class="bottom-container"> 
<hr/> 
<p class="footer">
All rights reserved &copy; 2009 Sample Ltd.
</p> 
</div></div>
<!-- Bottom end --> 
</div></div>
<!-- Site end -->
</body>
</html>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:

Select allOpen in new window

 

by: rstaveleyPosted on 2009-11-02 at 23:51:59ID: 25726773

Maybe its is my lack of familiarity with CSS, but I'm uncomfortable with the  idea that the left and right columns overlap and only by virtue of 'margin-left' is the right column's content kept out of the left's area.

It is more intuitive to have the right column's DIV 'float: left' and follow on from the left's. I have a solution with the approach above, but it feels wrong. Could I have done it with 'float: left' on the right column with automatic width? When I tried, it dropped the right column beneath the left.

 

by: dachusaPosted on 2009-11-03 at 06:53:44ID: 25729483

What I was saying is to make middle-container width 100%, then left column wrapper the width you want, then make right column wrapper auto.  both the left and right containers will need to be 100% width.

 

by: rstaveleyPosted on 2009-11-03 at 07:58:49ID: 25730228

Oh, I'm with you. That makes perfect sense. Thanks for sticking with me.

 

by: rstaveleyPosted on 2009-11-03 at 07:59:23ID: 31649091

Thanks for taking the time to see this through! :-)

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...