+ 1
How do i position an element to the center of a div element?
Am having a two elements and i want to position the other element to the center of the div such that, its position is always at the center irrespective of the screen size. How do i do that. thanks in advance.
4 Answers
+ 4
Maybe this could help
https://code.sololearn.com/WnNWl3XiEd84/?ref=app
0
thanks,,,, let me try
0
Just to it
Div{
position:relative;
}
Item{
position: absolute;
top:50%;
left:50%;
transform: translate (-50%,-50%);
}
This method will help you
0
have tried this it doesn't seem to work fine for me,,,,
div {
position: relative;
}
item {
position: absolute;
margin: auto;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px
}
this one works fine for one element but fails for for multiple elements