Strange issue on webkit browsers with transition on label childs


I have this strange issue that happens on Chrome and Opera, but not on Firefox. I have a checkbox input with custom styled label. The label has two elements inside with transition on them.

body {
  background-color: #2F3136;
  text-align: center;
  font-family: "Open Sans", sans-serif;
  color: white;
  font-weight: 400;
.main {
  position: relative;
  margin-top: 25px;
  margin-left: 25px;
.switch-input {
  display: none;
.switch-label {
  position: absolute;
  display: inline-block;
  cursor: pointer;
  font-weight: 500;
  padding: 10px 0 10px 36px;
.switch-label.right {
  top: 20%;
  transform: translateY(-20%);
  left: auto;
  right: 50px;
} {
  left: 50%;
  transform: translateX(-50%);
.switch-label .before, .switch-label .after {
  content: "";
  position: absolute;
  margin: 0;
  outline: 0;
  -ms-transform: translate(0, -50%);
  -webkit-transform: translate(0, -50%);
  transform: translate(0, -50%);
  -webkit-transition: all 0.3s ease;
  transition: all 0.3s ease;
.switch-label .before {
  left: 1px;
  width: 34px;
  height: 14px;
  background-color: #9E9E9E;
  border-radius: 8px;
.switch-label .after {
  left: 0;
  width: 20px;
  height: 20px;
  background-color: #FAFAFA;
  border-radius: 50%;
  box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.14), 0 2px 2px 0 rgba(0, 0, 0, 0.098), 0 1px 5px 0 rgba(0, 0, 0, 0.084);
.switch-input:checked + .switch-label .before {
  background-color: #A5D6A7;
.switch-input:checked + .switch-label .after {
  background-color: #4CAF50;
  -ms-transform: translate(80%, -50%);
  -webkit-transform: translate(80%, -50%);
  transform: translate(80%, -50%);
p {
  margin-left: 0px;
  text-align: center;
  margin-bottom: 0px;
  font-size: small;
.setting {
  position: absolute;
  width: fit-content;
  top: 0;
  height: 50px;
.setting.right {
  margin-left: 150px;
    <meta charset="utf-8">
    <link href=";500;600&display=swap" rel="stylesheet">
    <div class="main">
      <div class="setting">
        <p>before the label</p>
        <input type="checkbox" id="enabled" class="switch-input" checked>
        <label for="enabled" class="switch-label center">
          <div class="before"></div>
          <div class="after"></div>
      <div class="setting right">
        <p>after the label</p>

It seems like every time I change the checkbox state and the transition begins playing, all text after the label element changes its weight or something. I tried to play around with the css to see what is causing this, but I was unable to conclude anything.

Here is a video in case it doesn’t happen for you. See the change in the text after the label:


Try this xD

.setting.right {
  margin-left: 150px;
  z-index: -1; // 

Answered By – KeziX

Answer Checked By – Mildred Charles (AngularFixing Admin)

Leave a Reply

Your email address will not be published.