469,271 Members | 954 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

how many px equal to 100% width?

mao
Hi,

if I set my body element width to be 100%, how many px value equal to
this 100% width?
In other words,

<html>
....
<body>
....
</body>
</html>

In above html codes, my original CSS is
body {width: 100%;}

if I want my CSS use px unit, what is the X value in the following
code to have the same result as the one using width:100%?
body {width: Xpx;}

Dec 15 '07 #1
13 26519
"mao" <kc**********@gmail.comwrote in message
news:a4**********************************@i29g2000 prf.googlegroups.com...
Hi,

if I set my body element width to be 100%, how many px value equal to
this 100% width?
In other words,

<html>
...
<body>
...
</body>
</html>

In above html codes, my original CSS is
body {width: 100%;}

if I want my CSS use px unit, what is the X value in the following
code to have the same result as the one using width:100%?
body {width: Xpx;}
There is no 1:1 ratio for converting from % to px. It depends on the
viewport size of your browser. It is different for different people,
depending on their screen resolution, whether their browser is maximised or
not, how much chrome/toolbars etc. there are in the browser and a whole
bunch of other things.

Dec 15 '07 #2
Nik Coughlin wrote:
"mao" <kc**********@gmail.comwrote in message
news:a4**********************************@i29g2000 prf.googlegroups.com...
<snip>
>if I want my CSS use px unit, what is the X value in the following
code to have the same result as the one using width:100%?
body {width: Xpx;}

There is no 1:1 ratio for converting from % to px. It depends on the
viewport size of your browser. It is different for different people,
depending on their screen resolution, whether their browser is maximised
or not, how much chrome/toolbars etc. there are in the browser and a
whole bunch of other things.
Agree. It is a "How many angels can dance on the head of a pin?" type
question. So as Jukka would bluntly say, "Stop wanting that".

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Dec 15 '07 #3
In article
<a4**********************************@i29g2000prf. googlegroups.co
m>,
mao <kc**********@gmail.comwrote:
Hi,

if I set my body element width to be 100%, how many px value equal to
this 100% width?
In other words,

<html>
...
<body>
...
</body>
</html>

In above html codes, my original CSS is
body {width: 100%;}

if I want my CSS use px unit, what is the X value in the following
code to have the same result as the one using width:100%?
body {width: Xpx;}

If you do not put in a width on body or if you, unnecessarily,
put in a width of 100%, and if the body has a background colour
of red, the red will stretch as wide as the browser window. No
matter how wide the window.

But as you change the window size on even one screen, you
necessarily change the amount of red pixels. The pixels are a
fixed size and depend on the nature of the screen. The browser
window is variable and covers as many or as few pixels as you
have got.

Thus there is no px equivalence to a % in this matter.

--
dorayme
Dec 15 '07 #4
In article <33***************************@NAXS.COM>,
"Jonathan N. Little" <lw*****@centralva.netwrote:
Nik Coughlin wrote:
"mao" <kc**********@gmail.comwrote in message
news:a4**********************************@i29g2000 prf.googlegroups.com...

<snip>
if I want my CSS use px unit, what is the X value in the following
code to have the same result as the one using width:100%?
body {width: Xpx;}
There is no 1:1 ratio for converting from % to px. It depends on the
viewport size of your browser. It is different for different people,
depending on their screen resolution, whether their browser is maximised
or not, how much chrome/toolbars etc. there are in the browser and a
whole bunch of other things.

Agree. It is a "How many angels can dance on the head of a pin?" type
question.
I think of a "head of the pin" type question as rather more where
there is a feint chance of an answer in a debate with rather ill
defined terms.

But in this case there is no sense to the question itself. In the
former, it is not a matter of simple conceptual confusion but
rather a mistaken assessment of determinacy. In the case of
thinking that there is an equivalence between % and px, it is a
total misconception, the debate cannot even begin.

--
dorayme
Dec 15 '07 #5
rf

"mao" <kc**********@gmail.comwrote in message
news:a4**********************************@i29g2000 prf.googlegroups.com...
Hi,

if I set my body element width to be 100%, how many px value equal to
this 100% width?
Fourty two.

--
Richard.
Dec 15 '07 #6
In article <XB*******************@news-server.bigpond.net.au>,
"rf" <rf@invalid.comwrote:
"mao" <kc**********@gmail.comwrote in message
news:a4**********************************@i29g2000 prf.googlegroups.com...
Hi,

if I set my body element width to be 100%, how many px value equal to
this 100% width?

Fourty two.
That is brief prattle. I thought this was not allowed?

--
dorayme
Dec 15 '07 #7
rf wrote:
Fourty two.
Not everyone's cellphone is as tiny as mine.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Dec 15 '07 #8
dorayme wrote:
In article <XB*******************@news-server.bigpond.net.au>,
"rf" <rf@invalid.comwrote:
>"mao" <kc**********@gmail.comwrote in message
news:a4**********************************@i29g200 0prf.googlegroups.com...
>>Hi,

if I set my body element width to be 100%, how many px value equal to
this 100% width?
Fourty two.

That is brief prattle. I thought this was not allowed?
I've heard of briefs by Pierre Cardin and Fruit of the Loom, but never
of brief Prattle. In any case, I'm sure that they are all allowed.

Dec 15 '07 #9
In article <Ra******************************@golden.net>,
Gus Richter <gu********@netscape.netwrote:
dorayme wrote:
In article <XB*******************@news-server.bigpond.net.au>,
"rf" <rf@invalid.comwrote:
"mao" <kc**********@gmail.comwrote in message
news:a4**********************************@i29g2000 prf.googlegroups.com...
Hi,

if I set my body element width to be 100%, how many px value equal to
this 100% width?
Fourty two.
That is brief prattle. I thought this was not allowed?

I've heard of briefs by Pierre Cardin and Fruit of the Loom, but never
of brief Prattle. In any case, I'm sure that they are all allowed.
I am sure they are. I momentarily forgot not to pull rf's chain,
there is something about an Australian that makes it hard to
resist. I do hope he does not take it the wrong way. He is VERY
sensitive where I am concerned. Actually his remark was quite
good and it has a particular pedigree:
http://en.wikipedia.org/wiki/Answer_...verse,_and_Eve
rything

<g>

--
dorayme
Dec 15 '07 #10
mao wrote:
>
if I set my body element width to be 100%, how many px value equal to
this 100% width?
All of them.
if I want my CSS use px unit
Why would you want to do that? px and % units don't usually mix well.

If you post a URL, or at least a mock up of what you envision, we could
evaluate the situation better and give you more specific advice.

--
Berg
Dec 15 '07 #11
dorayme wrote:
I think of a "head of the pin" type question as rather more where
there is a feint chance of an answer in a debate with rather ill
defined terms.
If that is the case, then we can have an answer of sorts. You create a
DIV (or anything else that can be set invisible) and style it to have
width:100%

This "thing" will be exactly the width in pixels that the OP is after.

So, they just have to use a bit of JavaScript, to find precisely how
wide it is (*right now*, it will be different one mouse click/drag
later) and the job is done.

As with the original "42", they're *really* not going to like the answer.

I've used this technique precisely once. I was using coloured DIVs to
generate simple horizontal bar charts, and on modern displays an
accuracy of one tenth of a percent of the display may be too coarse, so
I needed something finer, and pixels seemed the right thing to use.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Dec 16 '07 #12
In article <47********@news.greennet.net>,
Steve Swift <St***********@gmail.comwrote:
dorayme wrote:
I think of a "head of the pin" type question as rather more where
there is a feint chance of an answer in a debate with rather ill
defined terms.

If that is the case, then we can have an answer of sorts. You create a
DIV (or anything else that can be set invisible) and style it to have
width:100%
A div is 100% by default.

(I notice now I misspelt a word. Never mind. I suppose no one
really wants to talk about angels on pins? I think this business
might have started in reference to a needle point in a context
where many things might be able to be in the same place and yet
be distinguishably different. Angels!)

--
dorayme
Dec 16 '07 #13
On 12/14/07 09:23 pm, mao wrote:
>
if I set my body element width to be 100%, how many px value equal to
this 100% width?
body {width: Xpx;}
Why?
Perhaps if you explained why you would want to do such a thing, we could
give you useful advice.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Dec 17 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Emil Dotchevski | last post: by
1 post views Thread by Anita Meyer | last post: by
reply views Thread by Fred Lock | last post: by
5 posts views Thread by John Smith | last post: by
11 posts views Thread by yawnmoth | last post: by
1 post views Thread by psion | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.