/    Sign up×
Community /Pin to ProfileBookmark

My main content is floating but not even to my left sidebar

I’m just playing around with some CSS – a little bit more difficult than what I expected.

Anyway, I’m just creating a fixed layout webpage and I have a left sidebar (I didn’t float this but is in the natural flow) but my main content – I would like to have it right next to my sidebar. My main content does float to the right – but the problem is, it doesn’t come up right underneath the menu. The top of the main content comes up to the bottom of my left sidebar. I know I’m missing something – not sure what it is.

Here is my code:

<html>

<head>
<style>

.container {
width: 1020px;
margin: 0px auto;

}

.header {

background-color: #000;
height: 100px;
width: 1020px;
color: white;
margin-top: 20px;
border-radius: 5px;

}

.menu {

background-color: grey;

height: 40px;
color: purple;

}

.leftsidebar {

background-color: blue;
height: 650px;
width: 100px;

}

.main {
float: right;
width: 920px;
height: 650px;
background-color: red;

}

</style>

<body>

<div class=”container”>

<div class=”header”>

</div>

<div class=”menu”>

</div>

<div class =”leftsidebar”>

</div>

<div class=”main”>

</div>

</div>

</body>
</html>

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@bigcat1967authorOct 05.2016 — Never mind everyone. I went ahead and floated both divs left - and it worked.

thx anyway. ?
Copy linkTweet thisAlerts:
@jedaisoulOct 05.2016 — Hi and welcome to the site. I'm glad that you solved your problem. I'd just mention something that can help avoid annoying discrepancies in div placement and similar issues: i.e. a simple "general reset" that can be placed at the beginning of your CSS code...

<i>
</i>* {
margin: 0;
padding: 0;
border: none;
}
input, select {
border: 1px solid grey;
}
Copy linkTweet thisAlerts:
@bigcat1967authorOct 06.2016 — Hi and welcome to the site. I'm glad that you solved your problem. I'd just mention something that can help avoid annoying discrepancies in div placement and similar issues: i.e. a simple "general reset" that can be placed at the beginning of your CSS code...

<i>
</i>* {
margin: 0;
padding: 0;
border: none;
}
input, select {
border: 1px solid grey;
}
[/QUOTE]


I learned that in a tutorial and totally forgot about it. Thx so much for the reminder.

I'm sort of new to CSS so there is so much to learn - but also a lot to forget. LOL!

Thx again!
×

Success!

Help @bigcat1967 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...