From the course: Responsive Layout

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Positioning

Positioning - HTML Tutorial

From the course: Responsive Layout

Start my 1-month free trial

Positioning

- [Instructor] The position property is used to move elements to different locations on a page. These are the different options for position that we will look at in this video: static, relative, absolute, fixed, and sticky. The default position is static. That means the element is where it is in the flow of the page. You can't use the left, right, top, and bottom properties to move a static element. The other values for position allow you to move the element around. Relative moves the element in relation to its original location, but doesn't affect any other elements. It just leaves an empty space. So the code I'm gonna add here on line nine, I'm gonna apply it to class div2, which is a second block element. And then, position: relative, left: 40px, and top: 40px. And then save, go over here and refresh, and I get this. The left, right, and top and bottom properties are a bit tricky. You're not moving the element towards that direction, you're moving it from that direction. So here…

Contents