Converting to tableless layout
I'm currently using 1 table to align 2 main portions of the site. It's causing problems for me now, so I'd like to use pure CSS.
I have a 205px wide navbar column on the left. Occupying the rest of the space on the right, I'd like to have a container (So on the right side of the screen, taking up screen width - 200 pixels) This container would not have a fixed height, but I want its top to be aligned with the top of the navbar.
Here's a demo of what I currently have .
I would like the solution to be similar to that, but not use tables, and have the top of the container aligned with the top of the sidebar.
I've made several attempts at doing this (before I started using the table, and after) but none of them even remotely worked. I've come here as a last resort, so I hope that someone could help.
html css css-tables
add a comment |
I'm currently using 1 table to align 2 main portions of the site. It's causing problems for me now, so I'd like to use pure CSS.
I have a 205px wide navbar column on the left. Occupying the rest of the space on the right, I'd like to have a container (So on the right side of the screen, taking up screen width - 200 pixels) This container would not have a fixed height, but I want its top to be aligned with the top of the navbar.
Here's a demo of what I currently have .
I would like the solution to be similar to that, but not use tables, and have the top of the container aligned with the top of the sidebar.
I've made several attempts at doing this (before I started using the table, and after) but none of them even remotely worked. I've come here as a last resort, so I hope that someone could help.
html css css-tables
That is a very common, very solved problem. CSS - Equal Height Columns?
– Madara Uchiha♦
Jul 29 '12 at 16:29
@Truth That is not what I am trying to do.
– fruitcup
Jul 29 '12 at 16:44
How is it different?
– Madara Uchiha♦
Jul 29 '12 at 16:55
@Truth I don't want them to be the same size, one of the columns is a fixed size and fixed position, and the right column is allowed to expand farther down.
– fruitcup
Jul 29 '12 at 16:57
So, I've FINALLY come up with a solution that works perfectly cross-browser, doesn't use tables, and doesn't use javascript. (I feel so proud :3) Rather than explaining it, you can view my completed fiddle demo here: jsfiddle.net/af9L5
– fruitcup
Jul 30 '12 at 21:01
add a comment |
I'm currently using 1 table to align 2 main portions of the site. It's causing problems for me now, so I'd like to use pure CSS.
I have a 205px wide navbar column on the left. Occupying the rest of the space on the right, I'd like to have a container (So on the right side of the screen, taking up screen width - 200 pixels) This container would not have a fixed height, but I want its top to be aligned with the top of the navbar.
Here's a demo of what I currently have .
I would like the solution to be similar to that, but not use tables, and have the top of the container aligned with the top of the sidebar.
I've made several attempts at doing this (before I started using the table, and after) but none of them even remotely worked. I've come here as a last resort, so I hope that someone could help.
html css css-tables
I'm currently using 1 table to align 2 main portions of the site. It's causing problems for me now, so I'd like to use pure CSS.
I have a 205px wide navbar column on the left. Occupying the rest of the space on the right, I'd like to have a container (So on the right side of the screen, taking up screen width - 200 pixels) This container would not have a fixed height, but I want its top to be aligned with the top of the navbar.
Here's a demo of what I currently have .
I would like the solution to be similar to that, but not use tables, and have the top of the container aligned with the top of the sidebar.
I've made several attempts at doing this (before I started using the table, and after) but none of them even remotely worked. I've come here as a last resort, so I hope that someone could help.
html css css-tables
html css css-tables
edited yesterday
Brian Tompsett - 汤莱恩
4,1631337100
4,1631337100
asked Jul 29 '12 at 16:26
fruitcup
50731231
50731231
That is a very common, very solved problem. CSS - Equal Height Columns?
– Madara Uchiha♦
Jul 29 '12 at 16:29
@Truth That is not what I am trying to do.
– fruitcup
Jul 29 '12 at 16:44
How is it different?
– Madara Uchiha♦
Jul 29 '12 at 16:55
@Truth I don't want them to be the same size, one of the columns is a fixed size and fixed position, and the right column is allowed to expand farther down.
– fruitcup
Jul 29 '12 at 16:57
So, I've FINALLY come up with a solution that works perfectly cross-browser, doesn't use tables, and doesn't use javascript. (I feel so proud :3) Rather than explaining it, you can view my completed fiddle demo here: jsfiddle.net/af9L5
– fruitcup
Jul 30 '12 at 21:01
add a comment |
That is a very common, very solved problem. CSS - Equal Height Columns?
– Madara Uchiha♦
Jul 29 '12 at 16:29
@Truth That is not what I am trying to do.
– fruitcup
Jul 29 '12 at 16:44
How is it different?
– Madara Uchiha♦
Jul 29 '12 at 16:55
@Truth I don't want them to be the same size, one of the columns is a fixed size and fixed position, and the right column is allowed to expand farther down.
– fruitcup
Jul 29 '12 at 16:57
So, I've FINALLY come up with a solution that works perfectly cross-browser, doesn't use tables, and doesn't use javascript. (I feel so proud :3) Rather than explaining it, you can view my completed fiddle demo here: jsfiddle.net/af9L5
– fruitcup
Jul 30 '12 at 21:01
That is a very common, very solved problem. CSS - Equal Height Columns?
– Madara Uchiha♦
Jul 29 '12 at 16:29
That is a very common, very solved problem. CSS - Equal Height Columns?
– Madara Uchiha♦
Jul 29 '12 at 16:29
@Truth That is not what I am trying to do.
– fruitcup
Jul 29 '12 at 16:44
@Truth That is not what I am trying to do.
– fruitcup
Jul 29 '12 at 16:44
How is it different?
– Madara Uchiha♦
Jul 29 '12 at 16:55
How is it different?
– Madara Uchiha♦
Jul 29 '12 at 16:55
@Truth I don't want them to be the same size, one of the columns is a fixed size and fixed position, and the right column is allowed to expand farther down.
– fruitcup
Jul 29 '12 at 16:57
@Truth I don't want them to be the same size, one of the columns is a fixed size and fixed position, and the right column is allowed to expand farther down.
– fruitcup
Jul 29 '12 at 16:57
So, I've FINALLY come up with a solution that works perfectly cross-browser, doesn't use tables, and doesn't use javascript. (I feel so proud :3) Rather than explaining it, you can view my completed fiddle demo here: jsfiddle.net/af9L5
– fruitcup
Jul 30 '12 at 21:01
So, I've FINALLY come up with a solution that works perfectly cross-browser, doesn't use tables, and doesn't use javascript. (I feel so proud :3) Rather than explaining it, you can view my completed fiddle demo here: jsfiddle.net/af9L5
– fruitcup
Jul 30 '12 at 21:01
add a comment |
2 Answers
2
active
oldest
votes
Fiddle
.container{height: 100%; border: 1px solid #0f0; display: table;}
#sidebar{
width:40%; height: 100%; display: table-cell; background: #ccc;
}
#sidebar2{
width:60%; height: 100%; display: table-cell; background: #f00;
}
body, html {
height:100%;
}
HTML
<div class="container">
<div id="sidebar">links and whatnot go here</div>
<div id="sidebar2">this is the container (but its top is not aligned with the sidebar as I would like)</div>
</div>
Note: table-cell property is supported by supports IE8+
EDIT:
If you can't use table-cell then you have to use some jquery to calculate height. Check this Fiddle
I would still like the sidebar to be fixed on the left and vertically centered, as in my original fiddle. Plus this is nearly the same as using tables (so any peace of mind I gain from not using tables is negated)
– fruitcup
Jul 29 '12 at 16:47
@dragonmoray please check the edit
– Dipak
Jul 29 '12 at 17:02
add a comment |
I would do something like this:
. HTML:
<div id="container">
<aside id="sidebar">Links and whatnot</aside>
<section id="content">Content and whatnot</section>
</div>
. CSS:
html, body {
width: 100%;
height: 100%;
}
div#container {
height: 100%;
}
aside#sidebar {
background-color: #f00;
width: 205px;
min-height: 100%;
float: left;
}
section#content {
background-color: #0f0;
min-height: 100%;
}
You can see it working in this fiddle.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11710879%2fconverting-to-tableless-layout%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Fiddle
.container{height: 100%; border: 1px solid #0f0; display: table;}
#sidebar{
width:40%; height: 100%; display: table-cell; background: #ccc;
}
#sidebar2{
width:60%; height: 100%; display: table-cell; background: #f00;
}
body, html {
height:100%;
}
HTML
<div class="container">
<div id="sidebar">links and whatnot go here</div>
<div id="sidebar2">this is the container (but its top is not aligned with the sidebar as I would like)</div>
</div>
Note: table-cell property is supported by supports IE8+
EDIT:
If you can't use table-cell then you have to use some jquery to calculate height. Check this Fiddle
I would still like the sidebar to be fixed on the left and vertically centered, as in my original fiddle. Plus this is nearly the same as using tables (so any peace of mind I gain from not using tables is negated)
– fruitcup
Jul 29 '12 at 16:47
@dragonmoray please check the edit
– Dipak
Jul 29 '12 at 17:02
add a comment |
Fiddle
.container{height: 100%; border: 1px solid #0f0; display: table;}
#sidebar{
width:40%; height: 100%; display: table-cell; background: #ccc;
}
#sidebar2{
width:60%; height: 100%; display: table-cell; background: #f00;
}
body, html {
height:100%;
}
HTML
<div class="container">
<div id="sidebar">links and whatnot go here</div>
<div id="sidebar2">this is the container (but its top is not aligned with the sidebar as I would like)</div>
</div>
Note: table-cell property is supported by supports IE8+
EDIT:
If you can't use table-cell then you have to use some jquery to calculate height. Check this Fiddle
I would still like the sidebar to be fixed on the left and vertically centered, as in my original fiddle. Plus this is nearly the same as using tables (so any peace of mind I gain from not using tables is negated)
– fruitcup
Jul 29 '12 at 16:47
@dragonmoray please check the edit
– Dipak
Jul 29 '12 at 17:02
add a comment |
Fiddle
.container{height: 100%; border: 1px solid #0f0; display: table;}
#sidebar{
width:40%; height: 100%; display: table-cell; background: #ccc;
}
#sidebar2{
width:60%; height: 100%; display: table-cell; background: #f00;
}
body, html {
height:100%;
}
HTML
<div class="container">
<div id="sidebar">links and whatnot go here</div>
<div id="sidebar2">this is the container (but its top is not aligned with the sidebar as I would like)</div>
</div>
Note: table-cell property is supported by supports IE8+
EDIT:
If you can't use table-cell then you have to use some jquery to calculate height. Check this Fiddle
Fiddle
.container{height: 100%; border: 1px solid #0f0; display: table;}
#sidebar{
width:40%; height: 100%; display: table-cell; background: #ccc;
}
#sidebar2{
width:60%; height: 100%; display: table-cell; background: #f00;
}
body, html {
height:100%;
}
HTML
<div class="container">
<div id="sidebar">links and whatnot go here</div>
<div id="sidebar2">this is the container (but its top is not aligned with the sidebar as I would like)</div>
</div>
Note: table-cell property is supported by supports IE8+
EDIT:
If you can't use table-cell then you have to use some jquery to calculate height. Check this Fiddle
edited Jul 29 '12 at 17:01
answered Jul 29 '12 at 16:35
Dipak
10.1k12228
10.1k12228
I would still like the sidebar to be fixed on the left and vertically centered, as in my original fiddle. Plus this is nearly the same as using tables (so any peace of mind I gain from not using tables is negated)
– fruitcup
Jul 29 '12 at 16:47
@dragonmoray please check the edit
– Dipak
Jul 29 '12 at 17:02
add a comment |
I would still like the sidebar to be fixed on the left and vertically centered, as in my original fiddle. Plus this is nearly the same as using tables (so any peace of mind I gain from not using tables is negated)
– fruitcup
Jul 29 '12 at 16:47
@dragonmoray please check the edit
– Dipak
Jul 29 '12 at 17:02
I would still like the sidebar to be fixed on the left and vertically centered, as in my original fiddle. Plus this is nearly the same as using tables (so any peace of mind I gain from not using tables is negated)
– fruitcup
Jul 29 '12 at 16:47
I would still like the sidebar to be fixed on the left and vertically centered, as in my original fiddle. Plus this is nearly the same as using tables (so any peace of mind I gain from not using tables is negated)
– fruitcup
Jul 29 '12 at 16:47
@dragonmoray please check the edit
– Dipak
Jul 29 '12 at 17:02
@dragonmoray please check the edit
– Dipak
Jul 29 '12 at 17:02
add a comment |
I would do something like this:
. HTML:
<div id="container">
<aside id="sidebar">Links and whatnot</aside>
<section id="content">Content and whatnot</section>
</div>
. CSS:
html, body {
width: 100%;
height: 100%;
}
div#container {
height: 100%;
}
aside#sidebar {
background-color: #f00;
width: 205px;
min-height: 100%;
float: left;
}
section#content {
background-color: #0f0;
min-height: 100%;
}
You can see it working in this fiddle.
add a comment |
I would do something like this:
. HTML:
<div id="container">
<aside id="sidebar">Links and whatnot</aside>
<section id="content">Content and whatnot</section>
</div>
. CSS:
html, body {
width: 100%;
height: 100%;
}
div#container {
height: 100%;
}
aside#sidebar {
background-color: #f00;
width: 205px;
min-height: 100%;
float: left;
}
section#content {
background-color: #0f0;
min-height: 100%;
}
You can see it working in this fiddle.
add a comment |
I would do something like this:
. HTML:
<div id="container">
<aside id="sidebar">Links and whatnot</aside>
<section id="content">Content and whatnot</section>
</div>
. CSS:
html, body {
width: 100%;
height: 100%;
}
div#container {
height: 100%;
}
aside#sidebar {
background-color: #f00;
width: 205px;
min-height: 100%;
float: left;
}
section#content {
background-color: #0f0;
min-height: 100%;
}
You can see it working in this fiddle.
I would do something like this:
. HTML:
<div id="container">
<aside id="sidebar">Links and whatnot</aside>
<section id="content">Content and whatnot</section>
</div>
. CSS:
html, body {
width: 100%;
height: 100%;
}
div#container {
height: 100%;
}
aside#sidebar {
background-color: #f00;
width: 205px;
min-height: 100%;
float: left;
}
section#content {
background-color: #0f0;
min-height: 100%;
}
You can see it working in this fiddle.
edited yesterday
tiagoperes
2,20521734
2,20521734
answered Jul 29 '12 at 16:45
Viktor
1122421
1122421
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11710879%2fconverting-to-tableless-layout%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
That is a very common, very solved problem. CSS - Equal Height Columns?
– Madara Uchiha♦
Jul 29 '12 at 16:29
@Truth That is not what I am trying to do.
– fruitcup
Jul 29 '12 at 16:44
How is it different?
– Madara Uchiha♦
Jul 29 '12 at 16:55
@Truth I don't want them to be the same size, one of the columns is a fixed size and fixed position, and the right column is allowed to expand farther down.
– fruitcup
Jul 29 '12 at 16:57
So, I've FINALLY come up with a solution that works perfectly cross-browser, doesn't use tables, and doesn't use javascript. (I feel so proud :3) Rather than explaining it, you can view my completed fiddle demo here: jsfiddle.net/af9L5
– fruitcup
Jul 30 '12 at 21:01