Can i use negative value on my stylesheet?

Discussion in 'CSS' started by Shamim501, Jul 11, 2013.

  1. #1
    I am learning Web Design From Couple of months.

    #call_us {
    float: right;
    margin-top: -30px;
    font-style: italic;
    }

    Now, my question is can i use margin-top in negative value on my stylesheet? The design remains ok if i give it, Other hand it is became zigzag.
     
    Shamim501, Jul 11, 2013 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    Many properties accept negative values, among them, margin. As always, I recommend you make yourself well acquainted with the specs.

    Ian Hickson, editor of the WHATWG html standard, from which html5 is derivative, has this to say on how to read the specs:
    cheers,

    gary
     
    kk5st, Jul 12, 2013 IP
  3. maisamjohnm

    maisamjohnm Greenhorn

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    yes you can use it but I think you should learn about positioning
     
    maisamjohnm, Jul 24, 2013 IP
  4. mojjammal

    mojjammal Active Member

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    93
    #4
    Yes you can use negative value on your stylesheet. But i suggest you to avoid negative value, because some time some browser create problems.
     
    mojjammal, Jul 26, 2013 IP
  5. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #5
    Commonly, negative values are used to compensate for some error by the author, so their use simply compounds the error. When used for explicit design/presentation purposes, there are seldom any issues among browsers. Old versions of IE had some quirks you had to work around, but seem to cause no problems as of v.9

    The key is to learn the rules of the game; read the specs. To repeat myself:
    cheers,

    gary
     
    kk5st, Jul 26, 2013 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #6
    Can't say I agree with that statement -- it happens by people who don't know what they are doing, but negative margins are an essential part of most content first multi-column and responsive layouts given what zero flow-width elements do -- much less well coded/reliable 100% min-height layouts can't be done without them either. (given what a unreliable wreck APo or FPo is in that regard)

    That said, the mention of something 'zig-zagging' by the OP makes me wonder if you are correct and he's compensating for some other mistake. It's hard to weigh in as to what the best answer would be without actually seeing the code/layout that's attempting to be accomplished.

    Like a great many posts, without seeing the code we can't really give a proper answer.
     
    deathshadow, Jul 26, 2013 IP
  7. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #7
    @ ds: You cherry picked the quote. The next sentence reads
    (emph added)

    I Think that encompasses your exception.

    cheers,

    gary
     
    kk5st, Jul 26, 2013 IP