Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS column layout

Tags:

html

css

I'm going round in circles with a CSS layout. I basically want it like:

<-------><-------------->
         <------><------>
  400px    50%      50%

So its 3 colums, one fixed size, and the other two taking up 50% each of the remaining space. I cant seem to make the second and third take up 50% of the remaining space.

Any help would be greatly appreciated, thanks very much :)


1 Answers

I tried a couple of variations. Below works in Chrome 2, Firefox 3.5 and IE8:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
<head>
<title>NLR</title>
<style type="text/css">
html, body, div { margin: 0; border: 0 none; padding: 0; }
div { height: 500px; border-collapse: collapse; }
#wrapper { padding-left: 400px; }
#nav { width: 400px; margin-left: -400px; float: left; background: yellow; }
#main { overflow: hidden; background: blue; }
#left { float: left; width: 50%; background: red; height: 300px; }
#right { float: right; width: 50%; background: green; }
</style>
</head>
<body>
<div id="wrapper">
<div id="nav"></div>
<div id="main">
  <div id="left"></div>
  <div id="right"></div>
</div>
</div>
</body>
</html>
like image 56
cletus Avatar answered Aug 03 '26 13:08

cletus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!