/    Sign up×
Community /Pin to ProfileBookmark

float over background color mystery….

I just noticed a strange behaviour which got me stuck almost 30 minutes.

I just wraped around a floating div element over a colored background. But the color will not show.
Only if I put Div after the class it will then show

examples

[CODE]
<head
<style type=”text/css”>
.back {background:yellow; width:50px; height:50px}
.left {float:left;}
</style>
</head>
<body>
<div class=”back”>
<div class=”left”>bla bla</div>
</div>
</body>
[/CODE]

Having it like this, as any normal logical human would do, I guess. Then it would create a yellow background under the float div. But it does not

If you put an extra div after the .back like this

[CODE]
.back [COLOR=Red]div[/COLOR] {background:yellow;}
[/CODE]

Then it will show the yellow background.

Just interesting to know why it acts like this

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyJul 19.2005 — Showed for me both ways on IE and FF. But I also fixed your <head> tag.
×

Success!

Help @Siddan 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 4.28,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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