search

Home  >  Q&A  >  body text

How to center an image element inside a wrapping div

Given below are the jsx and css codes and screenshots of the web page.

P粉043566314P粉043566314511 days ago541

reply all(1)I'll reply

  • P粉517090748

    P粉5170907482023-09-11 10:16:22

    Try giving display Flex to the parent div and use justify-content and align-items properties like below

    .movie_image {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 200px;
      border: 2px solid black;
    }
    
    .image {
      height: 100%;
    }

    reply
    0
  • Cancelreply