search

Home  >  Q&A  >  body text

Responsive PNG image on background image?

I'm trying to make a page design like this: Click

Actually, I succeeded. The problem is that when I change the resolution of the web page, the elements overlap, the background div and PNG behave differently and everything looks terrible. (I've tried using position:absolute(PNG) and position:relative(background))

P粉107991030P粉107991030324 days ago468

reply all(1)I'll reply

  • P粉011360903

    P粉0113609032024-02-22 13:30:03

    You can use the background-size and background-position CSS properties. You should try this way:

    body {
      background-image: url("your-bg-image.jpg");
      background-size: cover;
      background-position: center;
    }
    
    .responsive-image {
      background-image: url("your-image.png");
      background-size: contain;
      background-position: center;
      width: 100%;
      height: 100%;
    }

    reply
    0
  • Cancelreply