12. CSS – Positioning HTML Elements Part-1

12. CSS – Positioning HTML Elements Part-1


Hello everyone. And welcome back. In today’s video you learn about opposition in Yemen elements CSX provides us with the following acquisition by using static relative absolute fixed and sticky. Let’s try the first one stop it is the default violence with extreme elements whether we declare it or not elements our position and no order on the back page let us strike one example on the sun but don’t say we’ve got this image here. So let’s try getting a position static so let’s make a buck about it. OK so so we’ve already got an idea for the image mounted image. So you’re legislating in the position say position static let’s say that and as you can see nothing changes let’s try I really don’t bottom moneys. So it’s a top 16 vixens or let’s a hundred pixels. Let’s try getting a left of our Lucy vixens and as you can see these values aren’t affecting are going to make this position in the normal order. Moving on to the next one which is finishing up relative positions extreme elements relative to their normal position making an extreme attainment relative gives you access to the elements from its normal position by using Top Right Bottom Left properties. Let’s try an example in the standard that don’t say you have this image on this image is not any different. So if you open the good. So we’ve got an image about an idea let’s try giving us a position like this so let’s remove these models and let’s give it position relative. Let’s say that as you can see nothing changes by default but do move this image to enough to use the Top Right Bottom Left property. Before we do that let’s change the dimensions of the game to completely give up the image. Think of it like it represents the original position of the image. So the width and height is to enter pixels so that seems the same for our purposes 300 pixels height 300 pixels it has got about a top so let’s remove that let’s add some margin on the top say 80 pixels and let’s add some model on the left see 80 pixels. Let’s save it now. Like completely behind that image. So let’s go. I got another two hour images so. So you sixteen pixels on as you can see that image moved 16 pixels from the top edge. Let’s try increasing the value say 36 pixels. And as you can see image move more towards the bottom. So it is 36 pixels on the top edge. Similarly let’s try right. So let’s say 10 pixels. And as you can see some images now then pixels of which on the right edge. Let’s try increasing the value of say 32. And it is more away from the right edge. Let’s try a negative value. First let me do zero. It’s not it’s like perfectly on the right digit. So if you give a negative value C minus 16 pixels it moves towards the right. So it’s going in the negative direction off our right edge. That’s how we use this position relative to move the element from its original position. So as you can see here on the top bottom we’ve got these many likeness and they don’t seem in the same do vertically normally to move it down we could all use modern dot on the bottom button but it wouldn’t work here because these at length elements. So let’s try it out first. So this is the glass for menu item. So let’s try giving a margin dots a 30 pixels and as you can see still in the same position. Let’s try again at the bottom drops a two to six thirty pixels. Again no difference. So do means that you can use the position better did on use the Doppler look deeply moved towards the top. Let’s try that C position relative. Let’s save it. Now let’s say opposite it’s in the same position. Let’s try giving it a negative value do top so that it means towards the dog age so let’s say minus 60 pixels. Okay. He went a little too much too. That’s right. When it’s done let’s ride minus eight minus five. That looks much better. All right so moving on to the next one which is position absolute. It positions the exterior element relative to the first green element that has a position other than the static. Let’s try on example when the sun and I don’t see you this image of up and then definitely let’s make the bit in the US position. So this is output isn’t made index so its position relative. And let’s give this image permission absolute so. Position absolute. Let’s save it. Let’s writing it around the say double zero let’s say you’re on as you can see the image moves to the top image of the meaning there. Similarly if we give another galaxy left 20 pixels on scene and it starts other individuals from the left edge of the body to say we want us on the right hand side. So we could do something like this right. Zero. Otherwise you go nuts on the top right corner similarly if you wanted to move it to the bottom right corner we could do something like this or not. We can use bottom and now as you can see it is on the bottom right corner of the building. So as I mentioned earlier this absolute position element is relative to the first key element that has been achieved. Other than static so let’s say none of the tough position is staggering. So in that case it is position relative did not mean it’s human element. So let’s right and we’re in this position relative. Let’s bring it back to the top left corner. Let’s say that are not as you can see it’s on the top left corner far that beach but if you notice it’s coming on top of that number. So far we have with that X and Y axis. So basically we have a move and means left dry dog on bottom but we haven’t moved elements in and out or in other words where to go to the plate of ice cream for this group. We can use another proper deployment Z next this index probably can only be used one position has a value other than static not to avoid this or really give out ball by Ohio’s index. So that’s been about good a. So this is our dog daughter let’s say Z next day let’s say that nothing changes because he makes good on position of these other better stepping. So that seems like inclusion relative now as you can see our images below the dog boy that’s also the device if there’s something that you do not understand feel free to drop a comment and we will discuss it see you in the next video by anti-gay.