Support Forums

Old 05-12-2008, 05:20 PM   #1
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default Floating centered Div

Maybe Im just tired or maybe it cant be done.

Is there anyway to keep a div, or any other element for that matter, centered on a screen even if you scroll down? The question may seem a little crazy and why would I want to etc, but its something I desperatly need to do without using frames.
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline   Reply With Quote
Old 05-12-2008, 07:00 PM   #2
Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,424
Rep Power: 42
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Default

Assign the div to a class in CSS. Define the margins as auto for the left and right and that should do it.

-Mike
__________________
Mike-N-Tosh
v3.1.10 Developer IndianaPC.org - A community website
Sandbox v4.0.9, 4.1
Templates, Mods & Docs for sale | My blog with much content for 68 Classifieds.
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline   Reply With Quote
Old 05-12-2008, 07:15 PM   #3
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default

nope I thought about that one, doesnt do it.
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline   Reply With Quote
Old 05-12-2008, 07:37 PM   #4
Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,424
Rep Power: 42
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Default

Hmmm.... That doesn't make any sense, because that is the equivalent of center for CSS. Is this div located within any other HTML elements or inline with any other CSS classes or id's? The latter has screwed me before many times, because the center will be based from the borders of the other CSS elements it is inline with.
__________________
Mike-N-Tosh
v3.1.10 Developer IndianaPC.org - A community website
Sandbox v4.0.9, 4.1
Templates, Mods & Docs for sale | My blog with much content for 68 Classifieds.
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline   Reply With Quote
Old 05-12-2008, 08:34 PM   #5
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default

I need it absolute, so its not relative to anything else on the page.
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline   Reply With Quote
Old 05-13-2008, 12:09 AM   #6
Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,424
Rep Power: 42
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Default

I think that I misread your original post...

You want something centered in the WINDOW, both vertically and horizontally.

Try this in your CSS sheet: (This would work with an image that is 100px by 100px)
.centered {
position: fixed;
top: 50%;
left: 50%;
margin-top: -50px; // half the height of your object
margin-left: -50px; // half the width of your object
}

Add a z-index if you want it to be behind or in front of other items.

Hope that helps,
-Mike
P.S. I gotta see this when you're done!
__________________
Mike-N-Tosh
v3.1.10 Developer IndianaPC.org - A community website
Sandbox v4.0.9, 4.1
Templates, Mods & Docs for sale | My blog with much content for 68 Classifieds.
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline   Reply With Quote
Old 05-13-2008, 12:35 AM   #7
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default

maldito position fixed!!! I knew this, its just been so long since I used it. Thanks mike, works a treat! You will see what this is for soon!
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline   Reply With Quote
Old 05-13-2008, 10:58 PM   #8
Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,424
Rep Power: 42
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Default

No problem, Maffo. I'm glad that worked for you.

I just thought of something though and looked it up to refresh my memory. The fixed declaration doesn't work for IE6. You may need to change it to "absolute".

Cheers,
Mike
__________________
Mike-N-Tosh
v3.1.10 Developer IndianaPC.org - A community website
Sandbox v4.0.9, 4.1
Templates, Mods & Docs for sale | My blog with much content for 68 Classifieds.
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline   Reply With Quote
Old 05-14-2008, 12:11 AM   #9
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,400
Rep Power: 44
Maffo is just really niceMaffo is just really nice
Default

yes I read up on that and there were a lot of workarounds for it, and then I thought, why should I bother! A: I dont have IE6 to check it against, B: I hate Internet Explorer & C: We should be programming for the future, not the past. If it doesnt look correct on an old browser, maybe it will be an incentive for the user to upgrade to a modern version, or even take a leap of faith away from microsoft.
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
floating nav thecarsales v3.1 Modules & Modifications 3 06-01-2006 09:31 AM


All times are GMT -4. The time now is 07:56 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0