Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Absolute Position Fix
Old 08-11-2008, 05:10 PM Absolute Position Fix
Extreme Talker

Posts: 199
Trades: 0
Im trying to get an image to center in a div. It works as long as one part of my CSS is commented out. The issues is the part that is breaking it, is required for another script to run that I have not added in due to its vast amount of code. Can anyone tell me a workaround.. leaving the MUST have code in place. Im willing to add anything to the code, just not remove if possible.

Full Code
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>

<style type="text/css">
#image {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
    width:356px;
    height:356px;
    border:1px solid blue;
}
#image * {
    vertical-align: middle;
}
/*\*//*/
#image {
    display: block;
}
#image span {
    display: inline-block;
    height: 100%;
    width: 1px;
}
/**/
</style>
<!--[if IE]><style>
#image span {
    display: inline-block;
    height: 100%;
}
</style><![endif]-->

<style type="text/css">
#image img {position:absolute;}
</style>

</head>

<body>

<div id="image"><span></span><img src="http://www.google.com/logos/olympics08_rhythm.gif"></div>

</body>
</html>
Code that MUST stay in the CSS
Code:
#image img {position:absolute;}
Just to note, the rest of the code is for the most part an exact dup of the cross-browser image center in div code here, http://www.brunildo.org/test/img_center.html
empiresolutions is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-11-2008, 06:15 PM Re: Absolute Position Fix
FGU
FGU's Avatar
Super Talker

Posts: 116
Trades: 0
Not sure if this will help:
http://hostmonsterforums.com/showthread.php?t=3948
FGU is offline
Reply With Quote
View Public Profile
 
Old 08-11-2008, 06:18 PM Re: Absolute Position Fix
Extreme Talker

Posts: 199
Trades: 0
thanks for the suggestion, but it wont work in my account.
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 08-11-2008, 06:21 PM Re: Absolute Position Fix
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Could you set the image as a background on the div and center it that way

div#image {bacgkround: url("path-to-your-image") center;}
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 08-11-2008, 06:37 PM Re: Absolute Position Fix
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
If you want to center that image inside the div, you can do this:
1 - add display:block to #image img
2 - add margin: 0 auto; - that will center it inside the containing div.
Then get rid of the position:absolute.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Absolute Position Fix
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32128 seconds with 12 queries