/    Sign up×
Community /Pin to ProfileBookmark

Display:table-cell responsive layout

Display:table-cell responsive layout

Hi all

I’m trying to create a responsive layout with a fixed width side column on the left and a fluid content column on the right.

When the window resizes I need the side column to drop below the content.

I’m trying to use display:table-cell to create the columns

[url]http://www.ttmt.org.uk/forum/table-cel.html[/url]

This creates the columns but to get the side bar on the left the code for the side bar has to come before the content column

This means when the window resizes the sidebar goes above the content column.

Is there anyway to use display:table-cell so the sidebar is on the left but still falls below the content when the window is resized.

[CODE]
<!DOCTYPE html>
<html>
<meta charset=”UTF-8″>
<meta name=”description” content=””>
<meta name=”keywords” content=””>
<meta name=”robots” content=””>
<title>Title of the document</title>

<style type=”text/css”>

*{
margin:0;
padding:0;
}
html, body{
background:#eee;
height:100%;
}
#wrapper{
min-height:100%;
max-width:800px;
margin:0 auto;
background:#fff;
border-left:20px solid #eee;
border-right:20px solid #eee;
overflow:auto;
position:relative;
}

#sidebar{
background:yellow;
width:200px;
display:table-cell;

}
#content{
background:red;
display:table-cell;
}

@media only screen and (max-width:500px){

#sidebar{
display:block;
}
#content{
display:block;
}
}
</style>

</head>

<body>

<div id=”wrapper”>

<div id=”sidebar”>
<h1>Sidebar</h1>
</div>

<div id=”content”>
<h1>Content</h1>
<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.</p>
</div>

</div><!– #wrappper –>

</body>

</html>

[/CODE]

to post a comment
CSS

0Be the first to comment 😎

×

Success!

Help @ttmt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...