0

I am trying to add background image center but i am unable to do it i have tried all the method but unable to do it.here is my tried code

<a href="#" style="background-position:center center;">
      <img src="https://firebasestorage.googleapis.com/v0/b/growthfilepractice.appspot.com/o/ownerCampaign.jpg?alt=media&token=846535ef-b1c7-4063-aace-6e0843f9d001" style="width:800px;height:800px">
    </a>

    <a href="#">
      <img src="https://firebasestorage.googleapis.com/v0/b/growthfilepractice.appspot.com/o/ownerCampaign.jpg?alt=media&token=846535ef-b1c7-4063-aace-6e0843f9d001" style="width: 800px;height: 800px;background-repeat: no-repeat;
      background-attachment: fixed;
      background-position: center; ">
    </a>

2 Answers2

1

you need to add some styles

    a {
      width: 800px;
      height: 800px;
      background-repeat: no-repeat;
      background-image: url('https://firebasestorage.googleapis.com/v0/b/growthfilepractice.appspot.com/o/ownerCampaign.jpg?alt=media&token=846535ef-b1c7-4063-aace-6e0843f9d001');
      background-position: center;
    }
1

I assume your goal is to center you images. It is pretty easy, just do it like this:

.img-wrapper{
  text-align: center;
}
<div class="img-wrapper"><a href="#">
  <img src="https://firebasestorage.googleapis.com/v0/b/growthfilepractice.appspot.com/o/ownerCampaign.jpg?alt=media&token=846535ef-b1c7-4063-aace-6e0843f9d001" style="width:800px;height:800px">
</a>

<a href="#">
  <img src="https://firebasestorage.googleapis.com/v0/b/growthfilepractice.appspot.com/o/ownerCampaign.jpg?alt=media&token=846535ef-b1c7-4063-aace-6e0843f9d001" style="width: 800px;height: 800px;">
  </a></div>
Ezir cz
  • 50
  • 7