sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
windandwaves's Avatar

having a special stylesheet for 800x600


Question posted by: windandwaves (Guest) on August 24th, 2007 12:25 AM
Hi Folk

I was wondering if I could do the following:

write a php function that changes a stylesheet from 1024x768 to one
for 800x600 by literally changing all the widths, heights, font-sizes,
etc... by the ratio between 800/1024 (i.e. multiplying all values to
do with height or length with 0.78125)

My question is how I would write a regular expression that replaces as
follows:

YYYpx to ZZZpx
YYYem to ZZZem
YYYpt to ZZZpt
YYY% to ZZZ%

where YYY is the original numerical value and ZZZ = YYY * 0.78125.

Could you please help me to write this regular expression to test this
theory?

Thank you

Nicolaas

7 Answers Posted
Richard's Avatar
Guest - n/a Posts
#2: Re: having a special stylesheet for 800x600


"windandwaves" <nfrancken@gmail.comwrote in message
news:1187910993.925507.262780@x40g2000prg.googlegr oups.com...
Quote:
Originally Posted by
Hi Folk
>
I was wondering if I could do the following:
>
write a php function that changes a stylesheet from 1024x768 to one
for 800x600 by literally changing all the widths, heights, font-sizes,
etc... by the ratio between 800/1024 (i.e. multiplying all values to
do with height or length with 0.78125)
>
My question is how I would write a regular expression that replaces as
follows:
>
YYYpx to ZZZpx
YYYem to ZZZem
YYYpt to ZZZpt
YYY% to ZZZ%
>
where YYY is the original numerical value and ZZZ = YYY * 0.78125.
>
Could you please help me to write this regular expression to test this
theory?
>
Thank you
>
Nicolaas
>


Hi,
I dont understand why you want to do that.
Can you not change the dimensions to relative sizes (%)?

Richard.


=?ISO-8859-15?Q?Iv=E1n_S=E1nchez_Ortega?='s Avatar
=?ISO-8859-15?Q?Iv=E1n_S=E1nchez_Ortega?= August 24th, 2007 12:35 AM
Guest - n/a Posts
#3: Re: having a special stylesheet for 800x600

windandwaves wrote:
Quote:
Originally Posted by
[...] that changes a stylesheet from 1024x768 to one
for 800x600 by literally changing all the widths, heights, font-sizes,
etc... by the ratio between 800/1024 (i.e. multiplying all values to
do with height or length with 0.78125)


Have two different style sheets with different base values on just the
<bodyelement. Have a third (cascading) sheet with the rest of the
styling, express *everything* in either percentage or em. Problem solved
without touching a single line of code.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.
Jerry Stuckle's Avatar
Guest - n/a Posts
#4: Re: having a special stylesheet for 800x600

windandwaves wrote:
Quote:
Originally Posted by
Hi Folk
>
I was wondering if I could do the following:
>
write a php function that changes a stylesheet from 1024x768 to one
for 800x600 by literally changing all the widths, heights, font-sizes,
etc... by the ratio between 800/1024 (i.e. multiplying all values to
do with height or length with 0.78125)
>
My question is how I would write a regular expression that replaces as
follows:
>
YYYpx to ZZZpx
YYYem to ZZZem
YYYpt to ZZZpt
YYY% to ZZZ%
>
where YYY is the original numerical value and ZZZ = YYY * 0.78125.
>
Could you please help me to write this regular expression to test this
theory?
>
Thank you
>
Nicolaas
>


Or, better yet - don't used fixed sizes for your pages. Rather, have
pages which flow with the current window size (fluid window).

And just because my screen size is 1024x768 (or whatever) doesn't mean
my window size is. In fact, it almost never is. So your idea won't
work on my browser.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
Join Bytes!
==================
windandwaves's Avatar
Guest - n/a Posts
#5: Re: having a special stylesheet for 800x600

thanks for all the replies.

Just out of curiosity. Do you know what the regular expression would
be?

Thank you

Nicolaas

On Aug 24, 12:28 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
Originally Posted by
windandwaves wrote:
Quote:
Originally Posted by
Hi Folk

>
Quote:
Originally Posted by
I was wondering if I could do the following:

>
Quote:
Originally Posted by
write a php function that changes a stylesheet from 1024x768 to one
for 800x600 by literally changing all the widths, heights, font-sizes,
etc... by the ratio between 800/1024 (i.e. multiplying all values to
do with height or length with 0.78125)

>
Quote:
Originally Posted by
My question is how I would write a regular expression that replaces as
follows:

>
Quote:
Originally Posted by
YYYpx to ZZZpx
YYYem to ZZZem
YYYpt to ZZZpt
YYY% to ZZZ%

>
Quote:
Originally Posted by
where YYY is the original numerical value and ZZZ = YYY * 0.78125.

>
Quote:
Originally Posted by
Could you please help me to write this regular expression to test this
theory?

>
Quote:
Originally Posted by
Thank you

>
Quote:
Originally Posted by
Nicolaas

>
Or, better yet - don't used fixed sizes for your pages. Rather, have
pages which flow with the current window size (fluid window).
>
And just because my screen size is 1024x768 (or whatever) doesn't mean
my window size is. In fact, it almost never is. So your idea won't
work on my browser.
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================



Toby A Inkster's Avatar
Guest - n/a Posts
#6: Re: having a special stylesheet for 800x600

windandwaves wrote:
Quote:
Originally Posted by
Just out of curiosity. Do you know what the regular expression would
be?


It's not a task I'd even *attempt* using regular expressions. If I really
needed to programatically modify some CSS, I'd parse the stylesheet into
some sort of object structure, tweak the objects and then re-serialise
back to CSS. Complex work, but the only way that's going to cover all the
edge cases.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 64 days, 11:52.]

TrivialEncoder/0.2
http://tobyinkster.co.uk/blog/2007/...rivial-encoder/
gosha bine's Avatar
Guest - n/a Posts
#7: Re: having a special stylesheet for 800x600

On 24.08.2007 01:16 windandwaves wrote:
Quote:
Originally Posted by
Hi Folk
>
I was wondering if I could do the following:
>
write a php function that changes a stylesheet from 1024x768 to one
for 800x600 by literally changing all the widths, heights, font-sizes,
etc... by the ratio between 800/1024 (i.e. multiplying all values to
do with height or length with 0.78125)
>
My question is how I would write a regular expression that replaces as
follows:
>
YYYpx to ZZZpx
YYYem to ZZZem
YYYpt to ZZZpt
YYY% to ZZZ%
>
where YYY is the original numerical value and ZZZ = YYY * 0.78125.
>
Could you please help me to write this regular expression to test this
theory?
>



assuming your stylesheet is in the variable $css,

$css = preg_replace_callback('/\d+(?=\s*(px|em|pt|%))/', 'convert', $css);

function convert($m) {
return round($m[0] * 800 / 1024);
}


hope this helps


--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Good Man's Avatar
Guest - n/a Posts
#8: Re: having a special stylesheet for 800x600

windandwaves <nfrancken@gmail.comwrote in news:1187910993.925507.262780
@x40g2000prg.googlegroups.com:
Quote:
Originally Posted by
Hi Folk
>
I was wondering if I could do the following:
>
write a php function that changes a stylesheet from 1024x768 to one
for 800x600 by literally changing all the widths, heights, font-sizes,
etc... by the ratio between 800/1024 (i.e. multiplying all values to
do with height or length with 0.78125)
>


wow cool, using CSS completely incorrectly!

CSS = a way for your pages to look good REGARDLESS OF SCREEN RESOLUTION


Programming for screen resolution puts you squarely back to 1996.

 
Not the answer you were looking for? Post your question . . .
197,041 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 197,041 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors