The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> problem with adding drop shadows in traditional method.
sameer shaik
post Sep 5 2012, 03:04 AM
Post #1





Group: Members
Posts: 6
Joined: 16-August 12
Member No.: 17,617



we add negative margin values for top and left but why should we add values for bottom and left also.

why this?

margin: -5px 5px 5px -5px


why it cant be this?

margin: -5px 0px 0px -5px


because we want our image to move top and left in negative direction but why should we also add values for right and bottom sides?

pls clarify thanks...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 5 2012, 06:37 AM
Post #2


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 13,731
Joined: 9-August 06
Member No.: 6



You can use just "margin-top: -5px, margin-left: -5px", that is leave the other values out altogether.

Theoretically what you suggest would stretch the image. You move the top-left margins but say the bottom-right ones should stay where they were. I don't know if any browser does this now, I can't find one. Maybe the rules have changed. I'm sure that at one point it was possible to stretch a box with margins in the most CSS aware browsers but I don't manage to do it now. unsure.gif


--------------------
“Never go to excess, but let moderation be your guide.”
– Cicero

IPB Image
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 5 2012, 11:50 AM
Post #3


.
********

Group: WDG Moderators
Posts: 4,776
Joined: 10-August 06
Member No.: 7



QUOTE(sameer shaik @ Sep 5 2012, 10:04 AM) *

we want our image to move top and left in negative direction but why should we also add values for right and bottom sides?

In the first example a block element like a DIV should be moved. In the second it should become stretched, assuming that the width is "auto" (otherwise it will move there, too). Can't remember exactly why all this happens, the W3C spec can be very vague about things like this.

Images (like in your example) have intrinsic width, so maybe they can't be stretched this way. unsure.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 5 2012, 11:50 AM
Post #4


.
********

Group: WDG Moderators
Posts: 4,776
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Sep 5 2012, 01:37 PM) *

I'm sure that at one point it was possible to stretch a box with margins in the most CSS aware browsers but I don't manage to do it now. unsure.gif

It still works:

CODE
<style type="text/css">
body {
border: solid blue;
margin: 3em;
width: 20em;
}

p {
border: 1px solid red;
margin: 0;
}

p#t {margin-top: -5px;}
p#r {margin-right: -5px; width: auto;}
p#rw {margin-right: -5px; width: 20em;}
p#b {margin-bottom: -5px;}
p#l {margin-left: -5px; width: auto;}
p#lw {margin-left: -5px; width: 20em;}
p#lr {margin-left: -5px; margin-right: 5px; width: auto;}
p#lrw {margin-left: -5px; margin-right: 5px; width: 20em;}
</style>


<p id="t">top</p>
<p id="r">right, auto width</p>
<p id="rw">right, explicit width</p>
<p id="b">bottom</p>
<p id="l">left, auto width</p>
<p id="lw">left, explicit width</p>
<p id="lr">left+right, auto width</p>
<p id="lrw">left+right, explicit width</p>



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 5 2012, 01:22 PM
Post #5


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 13,731
Joined: 9-August 06
Member No.: 6



Yeah. My test DIVs had a width. blush.gif

I just want to point a thing out.
QUOTE
but why should we add values for bottom and left also.

That is the springing point. You CAN leave them out. But you don't do that in you example. Setting them to zero isn't leaving them out. It's specifying exactly how wide they should be, even if that width is 0.


--------------------
“Never go to excess, but let moderation be your guide.”
– Cicero

IPB Image
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Jaycbrf4
post Sep 5 2012, 02:17 PM
Post #6


Member
***

Group: Members
Posts: 33
Joined: 9-August 12
Member No.: 17,587



If you leave them out, they will default to browser defaults
http://www.w3.org/TR/CSS21/sample.html
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 5 2012, 02:27 PM
Post #7


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 13,731
Joined: 9-August 06
Member No.: 6



It isn't likely there will ever be a browser that adds margins to IMG.


--------------------
“Never go to excess, but let moderation be your guide.”
– Cicero

IPB Image
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 25th May 2013 - 12:44 AM