Как перенести вниз текст?

Рейтинг: 0Ответов: 1Опубликовано: 07.04.2023

Текст Go to listen хочу перенести под текст с анимацией вниз, но не могу, буду благодарен за ответ!

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: "Montserrat", sans-serif;
  font-family: "Poppins", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: url("./img/main_img.jpg") no-repeat;
  background-size: cover;
  background-position: center;
  background-color: silver;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 20px 100px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 99;
}

.logo {
  font-size: 2em;
  color: #fff;
  user-select: none;
}

.navigation a {
  position: relative;
  font-size: 1.1em;
  color: #fff;
  text-decoration: none;
  font-weight: 1000;
  margin-left: 40px;
}

.navigation a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 100%;
  height: 3px;
  background: #fff;
  border-radius: 5px;
  transform: scaleX(0);
  transition: transform 0.5s;
}

.navigation a:hover::after {
  transform: scaleX(1);
}

.navigation .btnLogin-popup {
  width: 130px;
  height: 50px;
  background: transparent;
  border: 2px solid #fff;
  outline: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1em;
  color: #fff;
  font-weight: 1000;
  margin-left: 40px;
  transition: transform 0.5s;
}

.navigation .btnLogin-popup:hover {
  box-shadow: inset 0 -100px 0 0 #fff;
  background: #fff;
  color: #8400ff;
}

.wrapper {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 100px;
  width: 20ch;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  animation: printed-text 3s ease;
}

@keyframes printed-text {
  from {
    width: 0;
  }
}

.txt {
  color: #fff;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@1,300&family=Poppins:wght@200&display=swap" rel="stylesheet" />
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Night Music | Music for deep thoughts</title>
</head>

<body>
  <header>
    <h2 class="logo">Night Music</h2>
    <nav class="navigation">
      <a href="#">Home</a>
      <a href="#">About</a>
      <a href="#">Services</a>
      <a href="#">Contact</a>
      <button class="btnLogin-popup">Login</button>
    </nav>
  </header>

  <div class="wrapper">
    <h1 class="title">Music for deep thoughts</h1>
  </div>

  <h2 class="txt">Go to listen</h2>

  <script src="./script.js"></script>
</body>

</html>

Ответы

▲ 1Принят

Текст Go to listen хочу перенести под текст с анимацией вниз

Осталось только определиться на сколько "перенести вниз". :)

Предложу такой вариант...

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: "Montserrat", sans-serif;
  font-family: "Poppins", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: url("./img/main_img.jpg") no-repeat;
  background-size: cover;
  background-position: center;
  /* добавил */
  flex-wrap: wrap;
  background-color: silver;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 20px 100px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 99;
}

.logo {
  font-size: 2em;
  color: #fff;
  user-select: none;
}

.navigation a {
  position: relative;
  font-size: 1.1em;
  color: #fff;
  text-decoration: none;
  font-weight: 1000;
  margin-left: 40px;
}

.navigation a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 100%;
  height: 3px;
  background: #fff;
  border-radius: 5px;
  transform: scaleX(0);
  transition: transform 0.5s;
}

.navigation a:hover::after {
  transform: scaleX(1);
}

.navigation .btnLogin-popup {
  width: 130px;
  height: 50px;
  background: transparent;
  border: 2px solid #fff;
  outline: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1em;
  color: #fff;
  font-weight: 1000;
  margin-left: 40px;
  transition: transform 0.5s;
}

.navigation .btnLogin-popup:hover {
  box-shadow: inset 0 -100px 0 0 #fff;
  background: #fff;
  color: #8400ff;
}

.wrapper {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 100px;
  width: 20ch;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  animation: printed-text 3s ease;
}

@keyframes printed-text {
  from {
    width: 0;
  }
}

.txt {
  color: #fff;
  /* добавил */
  flex-basis: 100%;
}

body > * {
  border: 2px solid red;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@1,300&family=Poppins:wght@200&display=swap" rel="stylesheet" />
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Night Music | Music for deep thoughts</title>
</head>

<body>
  <header>
    <h2 class="logo">Night Music</h2>
    <nav class="navigation">
      <a href="#">Home</a>
      <a href="#">About</a>
      <a href="#">Services</a>
      <a href="#">Contact</a>
      <button class="btnLogin-popup">Login</button>
    </nav>
  </header>

  <div class="wrapper">
    <h1 class="title">Music for deep thoughts</h1>
  </div>

  <h2 class="txt">Go to listen</h2>

  <script src="./script.js"></script>
</body>

</html>