+ 10
Is this valid in CSS?
Is this line of code a valid way to set the margin? I mean is it ok to give this property a negative value? /* margin: -21.5px -10px 10px -10px; */
14 Antworten
+ 6
It's very okay to have negative margins, just as long as you're aware that negative margins could lead to elements overlapping
+ 8
Yes!
+ 8
Yeah
+ 7
D'Lite Thanks.
+ 6
If you're ever wondering about code validity, you can always run your code through a validation service. Here's an example:
https://jigsaw.w3.org/css-validator/validator.html.en#validate_by_input
You can write (almost) anything between /* and */, so you will want to take those off before running the code through the validator. In this case, since you have a standalone rule, you will also want to include it in a ruleset (so apply it to a class or id or other selector) for the sake of the validator.
I hope this helps. 🤷🏻♂️
+ 6
Thanks everybody for answering.
+ 5
No
+ 5
PS Half pixels are valid in CSS.
https://stackoverflow.com/questions/9080633/can-a-css-pixel-be-a-fraction
How the browser chooses to render it varies.
+ 4
Yes but it would not work till you remove /* */
+ 3
Yeah. negative would make it go the opposite way. Like... if you have margin-top: 50px -> would move it down 50pixels.
if you put it negative: margin-top: -50px, it will make it go up 50pixels.
opposite of down (50) = up(-50).
+ 3
No it's not, "21.5" isn't correct because you can't use "half a pixel".
But everything else is ok.
+ 3
Yes
+ 2
pathetic_millenial u can't use half pixel?
is that really = true?
0
Yes