0

Хочу реализовать следующее: при нажатии на кнопку во все стороны разъезжается круглый блок. вот пример на буржуйском сайте (смотрите кнопки meira и adstod).

Как я понимаю: есть у меня кнопка, есть большой div со скругленными углами изначально скрытый (display: none ?). А как быть дальше - не знаю. буду рад любым наводкам и помощи. заранее спасибо!

2 ответа 2

1

document.getElementById('button').addEventListener('click', function() {
  this.classList.toggle('button_active');
});
.container {
  position: relative;
}

.button {
  position: absolute;
  top: 0;
  left: 0;
  height: 30px;
  width: 30px;
  background-color: red;
  border-radius: 50%;
  transition: all .3s ease;
}

.button_active {
  height: 300px;
  width: 300px;
  transform: translate(-25%, -25%);
}
<div class="container">
  <div class="button" id="button"></div>
</div>

1

var growth = false;
var get = function(obj) {
  return document.getElementById(obj)
};
get('two').onclick = function() {
  if (growth) {
    get('one').style.width = '50px';
    get('one').style.height = '50px';
    get('one').style.left = '0px';
    get('one').style.top = '0px';
    growth = false
  } else {
    get('one').style.width = '500px';
    get('one').style.height = '500px';
    get('one').style.left = '-250px';
    get('one').style.top = '-250px';
    growth = true
  }
}
body {
  margin: 0;
}
#one {
  width: 50px;
  height: 50px;
  border-radius: 500px;
  background-color: black;
  transition: 0.5s;
  position: absolute;
}
#two {
  width: 50px;
  height: 50px;
  z-index: 5;
  border-radius: 50px;
  background-color: white;
  position: absolute;
}
<html>

<body>
  <div id='one'></div>
  <div id='two'></div>
  </div>
</body>

</html>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.