Given an image and the task is to set the image to align to center (vertically and horizontally) inside a bigger div. It can be done by using the position property of the element.
Example 1: This example uses position property to make the image align to center.
Example 2: This example uses center property to set the image to center in a div.
- How to vertically align text inside a flexbox using CSS?
- How to horizontally center a using CSS?
- Making a div vertically scrollable using CSS
- How to vertically center text with CSS?
- Convert an image into grayscale image using HTML/CSS
- CSS | page-break-inside Property
- CSS to put icon inside an input element in a form
- Add the slug field inside Django Model
- Where is an object stored if it is created inside a block in C++?
- CSS | Image Gallery
- CSS | Image Sprites
- Saving an Image from URL in PHP
- Resize image proportionally with CSS
- How to change color of PNG image using CSS?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.