Исправление положения значка в кнопке, которая анимируется при наведении - PullRequest
1 голос
/ 27 апреля 2020

Я пытаюсь анимировать кнопку электронной почты при наведении курсора. Все работает нормально, за исключением того, что значок почты перемещается в центр, когда он находится над ним. Он должен оставаться слева от текста по существу в исходной позиции. Я был бы очень признателен за любую помощь, которую я могу получить. Вот ссылка на мой Codepen, а также на мой css.

Codepen: https://codepen.io/Qsbrown3/pen/YzyVjjN

Css:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 10px;
  font-family: 'Poppins', sans-serif;
  color: #111111;
}

body {
  width: 100%;
  height: 100;

}

section {
  padding: 6rem;
}

/*Start email icon*/
#container {
  font-size: 1rem;
  line-height: 1.5;
  padding: .1% 10%;
}

#learn-more {
  position: relative;
  display: inline-block;
  cursor: pointer;
  outline: none;
  border: 0;
  vertical-align: middle;
  text-decoration: none;
  background: transparent;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}
#learn-more {
  width: 20rem;
  height: auto;
}
#learn-more #circle {
  -webkit-transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  position: relative;
  margin: 0;
  width: 4rem;
  height: 4rem;
  background: #dadada;
  border-radius: 2.625rem;
}
#learn-more #circle #icon {
  -webkit-transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  position: absolute;

  background: #fff;
}

i {
  color: #fff;
  font-size: 2rem;
  position: absolute;
  display: block;
  content: '';
  top:25%;
  left: 25%;
  width: 50%;
}


#learn-more #circle #icon#arrow {
  -webkit-transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);

  background: none;
}
#learn-more #circle #icon#arrow::before {
  position: absolute;
}
#learn-more #button-text {
  -webkit-transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.75rem 1rem;
  margin: 0 0 0 1.85rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.6;
  text-align: center;
  text-transform: uppercase;
  vertical-align: center;
}
#learn-more:hover #circle {
  width: 100%;
  background: #000;
}
#learn-more:hover #circle #icon{
  background: #fff;
  -webkit-transform: translate(1rem, 0);
          transform: translate(1rem, 0);
}
#learn-more:hover #button-text {
  color: #fff;
}

/*End email icon*/

1 Ответ

0 голосов
/ 27 апреля 2020

Я сделал два изменения в стилях тега i. Пожалуйста, проверьте.

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 10px;
  font-family: 'Poppins', sans-serif;
  color: #111111;
}

body {
  width: 100%;
  height: 100;

}

section {
  padding: 6rem;
}

/*Start email icon*/
#container {
  font-size: 1rem;
  line-height: 1.5;
  padding: .1% 10%;
}

#learn-more {
  position: relative;
  display: inline-block;
  cursor: pointer;
  outline: none;
  border: 0;
  vertical-align: middle;
  text-decoration: none;
  background: transparent;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}
#learn-more {
  width: 20rem;
  height: auto;
}
#learn-more #circle {
  -webkit-transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  position: relative;
  margin: 0;
  width: 4rem;
  height: 4rem;
  background: #dadada;
  border-radius: 2.625rem;
}
#learn-more #circle #icon {
  -webkit-transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  position: absolute;

  background: #fff;
}

i {
  color: #fff;
  font-size: 2rem;
  position: absolute;
  display: block;
  content: '';
  top:25%;
  left: 10px; //changed
  //width: 50%; // removed
}


#learn-more #circle #icon#arrow {
  -webkit-transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);

  background: none;
}
#learn-more #circle #icon#arrow::before {
  position: absolute;
}
#learn-more #button-text {
  -webkit-transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  transition: all 0.45s cubic-bezier(0.65, 0, 0.076, 1);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.75rem 1rem;
  margin: 0 0 0 1.85rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.6;
  text-align: center;
  text-transform: uppercase;
  vertical-align: center;
}
#learn-more:hover #circle {
  width: 100%;
  background: #000;
}
#learn-more:hover #circle #icon{
  background: #fff;
  -webkit-transform: translate(1rem, 0);
          transform: translate(1rem, 0);
}
#learn-more:hover #button-text {
  color: #fff;
}

/*End email icon*/
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...