CSS positioning lesson 11


#1

I've tried in all possible ways. I am still getting the same error message about making the margin-top:-20px

Pls help!


#2

CSS has properties for specifying the margin for each side of an element:

  • margin-top

  • margin-right

  • margin-bottom

  • margin-left

margin: top right bottom left

you already have margin-top 20px

just add -

margin:-20px 50px 10px 5px;

#3

Thanks for helping but unfortunately I'm still getting the error message. Here is my Css code:

* {
	border: 1px dashed black;
}

div {
    margin-top:-20px;
    padding:40px;
    border: 4px solid #FF0000;
    margin:20px 50px 10px 5px;
    height: 50px;
	width: 100px;
	border-radius: 5px;
	background-color: #308014;
}

#4

your margin right has a value of 20px, while it should be -20px (negative value)


#5

i think you didn't understand what i said.

here your css

div {
    margin-top:-20px;   //here your mergin-top
    padding:40px;
    border: 4px solid #FF0000;
    margin:20px 50px 10px 5px;   //here  your margin-top
    height: 50px;
    width: 100px;
    border-radius: 5px;
    background-color: #308014;
}

make sense :slight_smile:


#6

Awesome explanation my friend ! Now I got it. Thanks a lot!