Background-position is not working

Asked

Viewed 235 times

2

Hey there, guys. I used the image-Replacement technique, tried to leave the image centralized using the background-position: center, but the image position remains unchanged. Would anyone know why the background-position is not working, how can I fix it? Follow the print:

inserir a descrição da imagem aqui

aside {
  height: 100vw;
  background-color: #fff;
  border-right: 3px solid #000;
  font-family: 'Lato', sans-serif;
  text-align: center;
  padding-top: 25px !important;
}

aside h1 {
    background-image: url(cal.png);
    background-position: center center;
    background-repeat: no-repeat;
    height: 208px;
    width: 200px;
}

aside h1 span {
    visibility: hidden;
}
<body>
   
   <div class="columns">
      
       <aside class="column is-3">
           <h1><span>Lorem ipsum</span></h1>
           
       </aside>
                   
   </div>

2 answers

2


I don’t know if this is it, but width: 200px is giving conflict,

aside {
  height: 100vw;
  background-color: #fff;
  border-right: 3px solid #000;
  font-family: 'Lato', sans-serif;
  text-align: center;
  padding-top: 25px !important;
}

aside h1 {
     
    background-image: url(https://i.stack.imgur.com/1mdGL.jpg);
    background-position: center;
    background-repeat: no-repeat;
    height: 208px;
   
}

aside h1 span {
    visibility: hidden;
}
<body>
   
   <div class="columns">
      
       <aside class="column is-3">
           <h1><span>Lorem ipsum</span></h1>
           
       </aside>
                   
   </div>

2

I solved it very simple how you were rendering the image width was conflicting so just add:

aside h1{
    display: block;
    margin: 0 auto;
}

aside {
  height: 100vw;
  background-color: #fff;
  border-right: 3px solid #000;
  font-family: 'Lato', sans-serif;
  text-align: center;
  padding-top: 25px !important;
}

aside h1 {
    background-image: url("https://image.prntscr.com/image/RQ2u88wpQDmxnJNQyput-Q.png");
    background-position: center center;
    background-repeat: no-repeat;
    height: 208px;
    width: 200px;
    display: block;
    margin: 0 auto;
}

aside h1 span {
    visibility: hidden;
}
<div class="columns">
    <aside class="column is-3">
        <h1><span>Lorem ipsum</span></h1>
           
    </aside>
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.