Or are you saying just don't use pixels? That I can understand.
So something like this would work without pixels.
.foo{
position: absolute;
left: 50%;
width: 80%;
margin-left: -40%;
}
Make sure the parent has position: relative.
--
Jordan Dobson
(425) 444-8014
http://Twitter.com/JordanDobson
On Jul 24, 2010, at 2:21 PM, Jesse MacFadyen <[email protected]> wrote:
> -1
> Do NOT use absolute values, use margin auto and make sure the parent element
> is width 100% plus text-align center. Your solution will then work in any
> browser.
>
>
> On 2010-07-24, at 1:08 PM, Alex Zylka <[email protected]> wrote:
>
>> @Jordan: Your suggestion works perfectly, although I would still like
>> to know if percents in CSS are from the body, the viewport, or the
>> containing element.
>>
>> Thanks,
>> Alex Zylka
>> http://www.zylka.us
>>
>> On Jul 24, 2:30 pm, Remi Grumeau <[email protected]> wrote:
>>> +1 !
>>> don t forget to put text-align: center to body and to left to the targeted
>>> div.
>>>
>>> Remi Grumeauhttp://www.remi-grumeau.com
>>>
>>> Le 24 juil. 2010 à 19:28, Jordan Dobson <[email protected]> a écrit :
>>>
>>>> You'll likely want to use absolute positioning for this type of approach.
>>>
>>>> If the width is 300px you push it out 50% and then negative margin
>>>> back half the width.. so -150px.
>>>
>>>> That's a better way than using margin percentages.
>>>
>>>> --
>>>> Jordan Dobson
>>>
>>>> (425) 444-8014
>>>> http://Twitter.com/JordanDobson
>>>
>>>> On Jul 24, 2010, at 9:45 AM, Alex Zylka <[email protected]> wrote:
>>>
>>>>> Hi there again. Right now, I'm messing around with a way to
>>>>> automatically download updates (new cache manifest files) to webapps
>>>>> using a native-looking loading box like the one here (http://
>>>>> www.macnotes.de/gimages/saurik/cydia-nachladen.jpg). I was wondering
>>>>> if anyone knew if using a percent with margin-right/margin-left is a
>>>>> percent of the body width, or the screen width. I ask this because I
>>>>> am attempting to center the loading box on the page. I achieved this
>>>>> by adding margin-right: 18%; to loading.css (which deals with the
>>>>> loading box). This solution works just alright. The box looks centered
>>>>> on the screen. But, when you turn the iPhone/ iPod Touch and the
>>>>> screen rotates to landscape mode, the loading box is way too far to
>>>>> the right side and NOT centered.
>>>>> My test app is here (with the loading box continuosly showing for
>>>>> debugging):http://www.zylka.us/test
>>>
>>>>> Thanks,
>>>>> Alex Zylka
>>>>> http://www.zylka.us/
>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google Groups
>>>>> "iPhoneWebDev" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> For more options, visit this group
>>>>> athttp://groups.google.com/group/iphonewebdev?hl=en.
>>>
>>>> --
>>>> You received this message because you are subscribed to the Google Groups
>>>> "iPhoneWebDev" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group
>>>> athttp://groups.google.com/group/iphonewebdev?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "iPhoneWebDev" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/iphonewebdev?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "iPhoneWebDev" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/iphonewebdev?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/iphonewebdev?hl=en.