samedi 2 juillet 2016

Arrow pseudo-element with transform rotate doesn't stay centered when re-sizing window

My problem is that I cannot place a triangle pointer right in the middle. Well, I can set pointer for some size of window, but when I shrink or extend window it places in the wrong place again. What am I missing ?

body {
  background: #333333;
}
.container {
  width: 98%;
  height: 80px;
  line-height: 80px;
  position: relative;
  top: 20px;
  min-width: 250px;
  margin-top: 50px;
}
.container-decor {
  border: 4px solid #C2E1F5;
  color: #fff;
  font-family: times;
  font-size: 1.1em;
  background: #88B7D5;
  text-align: justify;
}
.container:before {
  top: -33px;
  left: 48%;
  transform: rotate(45deg);
  position: absolute;
  border: solid #C2E1F5;
  border-width: 4px 0 0 4px;
  background: #88B7D5;
  content: '';
  width: 56px;
  height: 56px;
}
<div class="container container-decor">great distance</div>

Aucun commentaire:

Enregistrer un commentaire