Edit: it seems that the easy solution is to take the #menu div out of the container, but from how I was just taugh css-tables, I thought it would make more sense to put it inside the container and give it it's own row. I still don't understand why that does not work.
I am learning how to arrange my page in tables with CSS and HTML and I've run into an odd problem that I don't understand.
I want the #menu div in a row of its own and stretching to the length of the header. It does so perfectly, but when I add a new row underneath it with my #content and #sidebar divs that I also want to stretch to the length of the header, the #menu width gets cut off and the #content and #sidebar divs also do not stretch all the way horizontally like I would like them to.
If it sounds confusing just preview the code and it should be pretty obvious what I'm trying to do.
I feel like there is some simple thing that I am missing. I am trying to do this without using absolute positioning but strictly the table-layout.
Can someone see what I'm doing wrong here?
Thanks in advance.
html, body {
margin: 0;
}
header {
height: 200px;
margin: 10px 10px 0px 10px;
background-color: green;
}
#tablecontainer {
display: table;
border-spacing: 10px;
width: 100%;
}
.row {
display: table-row;
}
#menu {
display: table-cell;
background-color: green;
padding: 60px;
vertical-align: top;
}
#sidebar {
display: table-cell;
background-color: green;
vertical-align: top;
width: 50%;
}
#content {
table-cell;
background-color: green;
vertical-align: top;
width: 50%;
}
footer {
background-color: green;
height: 200px;
margin: 0px 10px 10px 10px;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<header>
sdf Lorem ipsum
</header>
<div id="tablecontainer">
<div class="row">
<div id="menu">sdf Lorem ipsum dolor sit amet,</div>
</div>
<div class="row">
<div id="sidebar">sdf 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. sdf 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. Except
</div>
<div id="content">sdf 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
</div>
</div>
</div>
<footer>asdas</footer>
</body>
</html>