tags:

views:

117

answers:

4
margin-left:-500px;margin-right:-500px;

What's the meaning ?Why do it like that ?

A: 

See here: http://www.communitymx.com/content/article.cfm?cid=b0029

Konamiman
no,u didn't hit the point.
Mask
Then share the context of the CSS. The html and the CSS. We cant guess based on 1 line of css what its purpose was.
Pino
+7  A: 

Read this nice article: The Definitive Guide to Using Negative Margins

Negative margins are usually applied in small doses but as you’ll see later on, it’s capable of so much more. A few things to note about negative margins are:

1. They are extremely valid CSS

I’m not kidding on this one. W3C even says that, “Negative values for margin properties are allowed…” ‘Nuff said. Check out the article for more details.

2. Negative margins are not a hack

This is especially true. It’s because of not understanding negative margins properly that it got its hackish image. It only becomes a hack if you use it to fix an error you made elsewhere.

3. It goes with the flow

It does not break the flow of the page if applied to elements without floats. So if you use a negative margin to nudge an element upwards, all succeeding elements will be nudged as well.

4. It is highly compatible

Negative margins are wholly supported across all modern browsers (and IE6 in most cases).

5. It reacts differently when floats are applied

Negative margins are not your everyday CSS so they should be applied with care.

6. Dreamweaver doesn’t understand it

Negative margins don’t show up in the Design View of DW. Why are you even checking your site in Design View anyway?

rahul
+1 - nice summary. I've edited to stop the code highlighting.
ck
+1 really nice answer!
RageZ
Nice,but not what I want.
Mask
Dominic has sorted it, looks much nicer now.
ck
Any reason for the down vote?
rahul
+4  A: 

It probably cancels out the 500px padding on the parent element:

<div style="padding-left: 500px; padding-right: 500px;">
   <div style="margin-left:-500px;margin-right:-500px;"></div>
</div>
echo
A: 

i read once (reference forgotten) that negative margins are supposed to send elements out of the way, sending them to the left most side of the browser. It is meant to hide elements out of the browser if you dont want to use

style="display:none"

does the element with the negative margins behave this way?

trace
Yep - though I'd expect it to have a bigger negative value than -500 (you tend to see values like -9999px for this). I've seen this technique used where menu items are meant to be displayed as images, but the text was wanted for people browsing without images, or with styles turned off.
Dominic Rodger