Categories
CSS

How to move an entire div element up x pixels with CSS?

Spread the love

Sometimes, we want to move an entire div element up x pixels with CSS.

In this article, we’ll look at how to move an entire div element up x pixels with CSS.

How to move an entire div element up x pixels with CSS?

To move an entire div element up x pixels with CSS, we set the margin-top property.

For instance, we write

div {
  margin-top: -15px;
}

to move the div up 15px by setting margin-top to -15px.

Conclusion

To move an entire div element up x pixels with CSS, we set the margin-top property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *