Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (20.3k points)

I have following div

<div id="over" style="position:absolute; width:100%; height:100%>

 <img src="img.png">

</div>

How to align the image so as to be located in the middle and center of div?

1 Answer

0 votes
by (40.7k points)

Try using the code given below:

body {

  margin: 0;

}

#over img {

  margin-left: auto;

  margin-right: auto;

  display: block;

}

<div id="over" style="position:absolute; width:100%; height:100%">

  <img src="Your Image Url">

</div>

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...