Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-18-2012, 02:51 AM   PM User | #1
PaulC2K
Regular Coder

 
Join Date: Jul 2005
Posts: 110
Thanks: 13
Thanked 0 Times in 0 Posts
PaulC2K is an unknown quantity at this point
Using :before with a relative setting

I thought I was doing something fairly simple, but im having trouble getting my head around it.

I have a div which is a big white box, and i want to add a box below it, equal length, same height, in blue.
I thought i could just give it a relative value and work from the bottom and i'd be all set.

Code:
.box 		{ width:500px; height:200px;background-color: white;}
.box:after      { content:''; background-color: blue; width: 500px; height:200px; bottom: 10px; left: 10px; position: relative; }
The specifics of the above are irrelevant, except understanding how to use the relative value.

Anyone know what im doing wrong here? I've stripped all other code and just using that, and it still being a PITA. using a fixed value is fine, but not the relative one, and ive tried a few other things but with no success.


Well, i feel like an idiot now Remembered years ago (like 8) i'd messed with absolute & relative positions and probably still had it, and i did.
So ive figured it out, and for the sake of possibly answering the problem if someone searches (god i hate it when people just reply 'figured it out' without bothering to tell anyone who might be looking!) i'll explain how it should be:

The box needs the relative position, the :after needs an absolute position, which will be based on the 'relative' one earlier
From there, just needs co-ords based on the bottom -height of the ':after'

what a numpty

Last edited by PaulC2K; 09-18-2012 at 03:00 AM..
PaulC2K is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:41 PM.


Advertisement
Log in to turn off these ads.