[CSS] getting visible screen height/ width

G

Guest

Hello,

is it possible to ask in CSS for the visible screen width and height?

I want to define a tag like this

div#foo{
left: $screenwidth/2-500px;
}

if there is any chance to ask for the screen width like it´s done with
"$screenwidth" in my improvisational example.



Regards,

Martin
 
T

Toby Inkster

Martin said:
is it possible to ask in CSS for the visible screen width and height?

No. And even if you could, what use would it be? Browser canvas size is a
lot more useful.
div#foo{
left: $screenwidth/2-500px;
}

Try:

div#foo {
width: 500px;
left: 50%;
margin-left: -250px;
}

(think about it and you'll see why it works)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,600
Members
45,179
Latest member
pkhumanis73
Top