How to have margin-left: 10%; margin-right: 10%;" only sometimes

C

Cal Who

Hi,

My website is created so that the width is not fixed. I adapt to the width
of the browser. If I have a page of text I do something like:

<div style=" margin-left: 10%; margin-right: 10%;">

so the text is set off by margins.

That's nice on my monitor's 1600 pixel wide screen.

But on a laptop (or as a user option) I'd like to change that to no margins.

Can you suggest a way of doing that without having two .css files?



Thanks
 
G

Guest

Hi,

My website is created so that the width is not fixed. I adapt to the width
of the browser. If I have a page of text I do something like:

<div style=" margin-left: 10%; margin-right: 10%;">

so the text is set off by margins.

That's nice on my monitor's 1600 pixel wide screen.

But on a laptop (or as a user option) I'd like to change that to no margins.

Can you suggest a way of doing that without having two .css files?

Thanks

For IE you can try to use CSS expressions, but I would recommend to
make a javascript to check screen width and set div style from there

e.g.

var x;
if (self.innerWidth) // all except Explorer
x = self.innerWidth;
else if (document.documentElement &&
document.documentElement.clientWidth)
// Explorer 6 Strict Mode
x = document.documentElement.clientWidth;
else if (document.body) // other Explorers
x = document.body.clientWidth;

if (x<1600)
.... your code here...
 

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

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top