Jump to content
  • 0

pomoc Centrovanie obrázka a z-index


Invouk

Dotaz

Zdravím: mám problém v CSS: 

CSS:

.logo
{
    display: block;
    margin: 0 auto;
}

toto dáva obrázok do stredu no a potrebujem aby bol obrázok za a jeden onrázok pred tým prvým, a aby bol v strede tak som skúšal toto:
 

 .logo{
    position: absolute;
    z-index: 3500;
    display: block;
    margin: 0 auto;
}

Ale toto mi dá preč vycentrovanie obrázka a dá pred, pomôžete ako na to ?

Link to comment
Share on other sites

11 odpovědí na tuto otázku

Recommended Posts

  • 0


<div class="image-wrapper">
<div class="sq1"></div>
<div class="sq2"></div>
</div>


.image-wrapper{
position: relative;
width: 200px;
height: 200px;
}
.sq1{
position: absolute;
z-index: 1;
width: 100%;
height: 100%;
background: #333;
}
.sq2{
position: absolute;
z-index: 2;
width: 100%;
height: 100%;
background: #999;
}
Link to comment
Share on other sites

  • 0

CSS

.image-wrapper{
      width: 100%;
      position: relative;
      margin: 0 auto;
    }
    .lg{
      position: absolute;
      z-index: 200;
    }
    .bg-lg{
      position: absolute;
      z-index: 100;
      height: 500px;
    }

HTML:

<div class="image-wrapper">
 <div class="lg"><img src="./img/Batman_Logo.jpeg" alt="Logo" style="width: 30%; height: 20%;"></img></div>
 <div class="bg-lg"> <img src="./img/bg.png" alt="bg-logo"></img></div>
</div>

a robí mi to, hocijako ani neroztiahne ten bg do maxima, a ani nevycentruje, a dá to pred text... čož nechcem.

Edited by eXpresS
Link to comment
Share on other sites

  • 0

http://codepen.io/Huzy666/pen/oBrxEm Tady to máš :) Nahraď obrázky za background-color a je to :) A uprav si velikosti.

 

Pokud někdo půjde přes mobil, tak tam bude zbytečně velká mezera mezi horní hranou a obrázkem.

 

Místo translate bych udělal display: table; a display: table-cell;

Link to comment
Share on other sites

  • 0

Pokud někdo půjde přes mobil, tak tam bude zbytečně velká mezera mezi horní hranou a obrázkem.

 

Místo translate bych udělal display: table; a display: table-cell;

To slyším po prvně, abych se přiznal :d Někdy to vyzkouším.

Link to comment
Share on other sites

  • 0

Pridal som tam obrázok aby pulzoval:

 

.pulse {
  animation: pulse 7s infinite;
  display: table;
  margin-top: 50px;
  animation-direction: alternate;
  -webkit-animation-name: pulse;
  animation-name: pulse;
}

@-webkit-keyframes pulse {
  0% {
    -webkit-transform: scale(1);
  }
  50% {
    -webkit-transform: scale(1.1);
  }
  100% {
    -webkit-transform: scale(1);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

Zistil som, že toto mi dáva na stranu ten obrázok. Vycentrované bez pulse som to mal.
Ale ako tam dám toto tak to posune tak o 20% do pravej strany.

Edited by eXpresS
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...