CSS question

D

DrewC

I am trying to position a block in my CSS and I want it to when I resize the
browser window the margin on both sides remain the same. But I can only get
the left side to behave this way
 
A

Animesh K

DrewC said:
I am trying to position a block in my CSS and I want it to when I resize the
browser window the margin on both sides remain the same. But I can only get
the left side to behave this way

To get the answer, please give a link to your website. It is hard to
know what does your CSS file looks like.
 
D

DrewC

http://drewclayton.com/test.htm

#top2 {
padding: 10px;
border: 5px solid #ccc;
background: #666;
height: 100px; /* ie5win fudge begins */
voice-family: "\"}\"";
voice-family:inherit;
height: 46px;
width: 352px;
margin-top: 20px;
margin-right: 20px;
margin-bottom: 0px;
margin-left: 20px;
position: absolute;
left: 130px;
top: 163px;
}


Thats the code for the block. It keeps the margin on the right as I resize
the window, but the right doesn't behave the same way
 
J

John Hosking

DrewC said:
I am trying to position a block in my CSS and I want it to when I resize the
browser window the margin on both sides remain the same. But I can only get
the left side to behave this way

When you (1) provide a URL as Animesh suggests, you can also (2) explain
what you mean by "remain the same": do you mean the same as each other,
or the same as they were before resizing? Also, you may wish to (3) post
your CSS topics to comp.infosystems.www.authoring.stylesheets.
 
J

Jukka K. Korpela

Scripsit DrewC:
I am trying to position a block in my CSS and I want it to when I
resize the browser window the margin on both sides remain the same.
But I can only get the left side to behave this way

Set margin-left: auto and margin-right: auto. Make sure you have a
conforming doctype that puts browsers into "standards" mode, and a) accept
the fact that a fraction of old browsers don't center the block or b) use
HTML tools for centering.

Of course, you need to set a width for the block for this to work. If you
just want, say, 3em margins on both sides and the block to occupy the rest
of the available width, simply set margin-left: 3em and margin-right: 3em
(or just margin: 0 3em if it its OK to explicitly set vertical margins to
zero).
 
A

Animesh K

DrewC said:
http://drewclayton.com/test.htm

#top2 {
padding: 10px;
border: 5px solid #ccc;
background: #666;
height: 100px; /* ie5win fudge begins */
voice-family: "\"}\"";
voice-family:inherit;
height: 46px;
width: 352px;
margin-top: 20px;
margin-right: 20px;
margin-bottom: 0px;
margin-left: 20px;
position: absolute;
left: 130px;
top: 163px;
}


Thats the code for the block. It keeps the margin on the right as I resize
the window, but the right doesn't behave the same way

Please bottom post to keep the context.

Your html file is almost empty so it is unclear what you desire to
achieve. Also, link to your CSS file using relative directory structure.
file:///c\........ will work only on your computer, not on the server.

Best,
Animesh
 
D

DrewC

Your html file is almost empty so it is unclear what you desire to
achieve. Also, link to your CSS file using relative directory structure.
file:///c\........ will work only on your computer, not on the server.


yes, I know that. I just want to know how to achive it before I upload it
 
D

dorayme

Your html file is almost empty so it is unclear what you desire to
achieve. Also, link to your CSS file using relative directory structure.
file:///c\........ will work only on your computer, not on the server.


yes, I know that. I just want to know how to achive it before I upload it[/QUOTE]

You want the egg to come first?
 
A

Animesh K

DrewC said:
yes, I know that. I just want to know how to achive it before I upload it

Yes but your html file has only one div. You mentioned that you want to
position two columns. Can you post the full thing (however awful it is,
don't worry)?
 
N

Neredbojias

Well bust mah britches and call me cheeky, on Tue, 14 Aug 2007 19:32:18
GMT DrewC scribed:
I am trying to position a block in my CSS and I want it to when I
resize the browser window the margin on both sides remain the same.
But I can only get the left side to behave this way

Here are some excerpts from your posts to date:

(1) I am trying to position a block in my CSS and I want it to when I
resize the browser window the margin on both sides remain the same. But I
can only get the left side to behave this way

- Meaning you can only get the left side to remain the same as ...? What?

(2) Thats the code for the block. It keeps the margin on the right as I
resize the window, but the right doesn't behave the same way

- How many right hands do _you_ possess?

(3) yes, I know that. I just want to know how to achive it before I upload
it

- If the solution to your problem necessitates uploading it first, your
"want" is irrational.

Anyway, Jukka seems to have the answer. To keep consistently-sized side
margins, you can't include a container width. When I first read your post,
I had the same question as John Hosking asked. Whether English is your
native language or not, you should try to present your queries in better
fashion in the future.
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top