-2

How do I center this header? I've tried about everything, and nothing works. ;-;

@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,600italic,700italic);
* {
  margin: 0;
  padding: 0;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
}

body {
  background: #2c3e50;
  font-size: 80%;
  font-family: 'Open Sans', sans-serif;
}

.bg {
  z-index: -1;
  width: 100%;
  height: 100%;
  position: absolute;
  background: linear-gradient( 45deg, #f17c58, #e94584, #24aadb, #27dbb1, #ffdc18, #ff3706);
  background-size: 600% 100%;
  animation: gradient 16s linear infinite;
  animation-direction: alternate;
}

@keyframes gradient {
  0% {
    background-position: 0%;
  }
  100% {
    background-position: 100%;
  }
}

main {
  position: relative;
  height: 240px;
  margin: auto;
  padding: 20px;
  resize: both;
}

.btn-grp {
  height: 68px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

a {
  text-decoration: none;
  color: #fff;
}

a:hover {
  color: #2ecc71;
}

.btn {
  text-align: center;
  cursor: pointer;
  font-size: 24px;
  position: relative;
  background-color: #f39c12;
  border: none;
  padding: 20px;
  width: 200px;
  -webkit-transition-duration: 0.4s;
  transition-duration: 0.4s;
  text-decoration: none;
  overflow: hidden;
}

.btn:hover {
  background: #fff;
  box-shadow: 0 2px 10px 5px #97b1bf;
  color: #000;
}

.btn:after {
  content: '';
  background: #f1c40f;
  display: block;
  position: absolute;
  opacity: 0;
  transition: all 0.8s;
}

.btn:active:after {
  padding: 0;
  margin: 0;
  opacity: 1;
  transition: 0s;
}

.down {
  Position: absolute;
  Bottom: 85%;
}
<html lang="en">

<head>
</head>

<body>
  <div class="bg"></div>
  <div class="down">
    <h1>Welcome</h1>
  </div>
  <main>
    <div class="btn-grp">
      <a href="#" target="_blank">
        <button class="btn" id="btn-home">Home</button>
      </a>
      <a href="#" target="_blank">
        <button class="btn" id="btn-dl">Download</button>
      </a>
    </div>
  </main>
</body>

</html>
Aalexander
  • 4,834
  • 3
  • 7
  • 30
  • To center an element, for example you can use flexbox, here you can find a [good point of start](https://css-tricks.com/snippets/css/a-guide-to-flexbox/). – Sfili_81 Feb 09 '21 at 08:21

1 Answers1

0

 @import url(https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,600italic,700italic);
    * {
      margin: 0;
      padding: 0;
    }
    html,
    body {
      max-width: 100%;
      overflow-x: hidden;
      overflow-y: hidden;
    }
    body {
      background: #2c3e50;
      font-size: 80%;
      font-family: 'Open Sans', sans-serif;
    }
    .bg {
      z-index: -1;
      width: 100%;
      height: 100%;
      position: absolute;
      background: linear-gradient(
        45deg,
        #f17c58,
        #e94584,
        #24aadb,
        #27dbb1,
        #ffdc18,
        #ff3706
      );
      background-size: 600% 100%;
      animation: gradient 16s linear infinite;
      animation-direction: alternate;
    }
    @keyframes gradient {
      0% {
        background-position: 0%;
      }
      100% {
        background-position: 100%;
      } 
    }
    main {
      position: relative;
      height: 240px;
      margin: auto;
      padding: 20px;
      resize: both;
    }
    .btn-grp {
      height: 68px;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
    a {text-decoration: none; color: #fff;}
    a:hover {color: #2ecc71;}
    .btn {
      text-align: center;
      cursor: pointer;
      font-size: 24px;
      position: relative;
      background-color: #f39c12;
      border: none;
      padding: 20px;
      width: 200px;
      -webkit-transition-duration: 0.4s;
      transition-duration: 0.4s;
      text-decoration: none;
      overflow: hidden;
    }
    .btn:hover {
      background: #fff;
      box-shadow: 0 2px 10px 5px #97b1bf;
      color: #000;
    }
    .btn:after {
      content: '';
      background: #f1c40f;
      display: block;
      position: absolute;
      opacity: 0;
      transition: all 0.8s;
    }
    .btn:active:after {
      padding: 0;
      margin: 0;
      opacity: 1;
      transition: 0s;
    } 

    .down { 
    Position: absolute; 
    Bottom: 85%; 
    width: 100%;
    text-align: center;
  } 
<html lang="en">
 <head>
</head>
  <body>
    <div class="bg"></div>
    <div class="down">
      <h1>Welcome</h1>
    </div>
      <main>
        <div class="btn-grp">
          <a  href="#" target="_blank">
            <button class="btn" id="btn-home">Home</button>
          </a>
          <a href="#" target="_blank">
            <button class="btn" id="btn-dl">Download</button>
          </a>
        </div>
      </main>
  </body>
</html>

Changed the css for only .down class like this :

.down { 
    Position: absolute; 
    Bottom: 85%; 
    width: 100%;
    text-align: center;
}
web-sudo
  • 521
  • 12