18910140161

PHP-是否有一种方法可以使带有css的html的页眉和页脚始终显示,即使网页是可滚动的?(没有javascript)-堆栈溢出

顺晟科技

2022-10-19 11:33:16

52

我只想让页眉贴在顶部,页脚贴在底部 所有显示宽高比均居中 并在可滚动的网页中可见 因为这将是一个大网站 没有其他页面

  1. 顶部的图像
  2. 关于它下面的我们
  3. 站点链接
  4. 图像滑块 E.T.C

不依赖JavaScript

提前感谢

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link href="index_dark.css" rel="stylesheet">
  <link href="home_dark.css" rel="stylesheet">
  <title>IndiePump</title>
  </head>
  <body>
    <!-- Starting with the Header of the Site-->
    <header class="main-header">
      <a href="/" class="brand-logo">
        <img src="logo_header.png">
        <div class="brand-logo-name">IndiePump</div>
      </a>
      <nav class="main-nav">
        <ul>
          <li><a href="login_dark.html">Join Us</a></li>
          <li><a href="index.html" class="moon-button"></a></li>
        </ul>
      </nav>
    </header>
    <!-- Setting Up the Footer-Bar of the Site-->
    <footer class="main-footer">
      <nav class="footer-container">
        <ul>
          <li>
            <a href="#" class="contact-link">
              <img src="social_icons/dark/email.png"</img>
              Contact Us
            </a>
          </li>
          <div class="copyright-container">
            <img src="social_icons/dark/copyright.png"></img>
            <p>2021</p>
          </div>
          <div class="dev-container">
            <img src="social_icons/dark/developed.png"></img>
            <p>Ver 1.0</p>
          </div>
        </nav>
        <nav class="footer-container">
          <ul>
            <li>
              <a href="#" class="facebook-link">
                <img src="social_icons/dark/facebook.png"></img>
              </a>
            </li>
            <li>
              <a href="#" class="twitter-link">
                <img src="social_icons/dark/twitter.png"></img>
              </a>
            </li>
            <!--<li>
              <a href="#" class="instagram-link">
                <img scr="social_icons/dark/instagram.jpg"></img>
              </a>
            </li>-->
            <li>
              <a href="#" class="discord-link">
                <img src="social_icons/dark/discord.png"></img>
              </a>
            </li>
            <li>
              <a href="#" class="messenger-link">
                <img src="social_icons/dark/messenger.png"></img>
              </a>
            </li>

      </nav>
    </footer>

</body>
</html>



*/ 
The CSS Part
/*
@import url("https://fonts.googleapis.com/css?family=Poppins:400,500,700");

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  display; grid;
  padding: 0;
  margin: auto;
  width: 100%;
  background-color: #1a1b20;
  font-family: Poppins, sans-serif;
  font-size: 1.2rem;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-header {
  height: 110px
}

.brand-logo {
  display: flex;
  align-items: center;
  font-size: 1.25em;
  color: gold;
  text-decoration: none;
}

.brand-logo-name {
  margin-left: 1rem;
}

.main-nav {
  display: flex;
  text-align: center;
  justify-content: center;
}

.main-nav ul {
  display: flex;
  height: auto;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: center;
  text-align: center;
  list-style: none;
}

.main-nav a {
  color: gold;
  text-decoration: none;
  padding: 1rem;
}

.main-nav a:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.moon-button {
  background-image: url(moon.png);
  background-color: #1a1b20;
  background-repeat: no-repeat;
  color: rgba(0,0,0,0);
  display: flex;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: center;
  width: 65px;
  height: 65px;
  border: 0;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  -webkit-appearance: none;
  outline: none;
}

.moon-button:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.main-footer {
  display: flex;
  height: 65px;
  justify-content: space-between;
  align-items: center;
  bottom: 0;
}

.footer-container {
  display: flex;
  text-align: center;
  justify-content: space-between;
  align-items: center;
}

.footer-container ul{
  display: flex;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  font-size: 0.9rem;
  list-style: none;
}

.contact-link {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.contact-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.copyright-container {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.copyright-container:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.dev-container {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.dev-container:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.facebook-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.facebook-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.twitter-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.twitter-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.discord-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.discord-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.discord-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.discord-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.messenger-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.messenger-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

顺晟科技:

用于您的和

在HTML中有一些错误,比如不需要和缺少标记。

如果不使用JavaScript,则应在所有页面中包含页眉和页脚代码。

正如vanowm所回答的那样,将标头定位为fixed是网页中常见的一件事,当您手动将标头的html代码包含到所需的页面中时,就不会出现此类问题。

我建议的一件事是,当您希望您的标题固定在站点顶部时,使用一个带有标题的更多粘性分区。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link href="index_dark.css" rel="stylesheet">
  <link href="home_dark.css" rel="stylesheet">
  <title>IndiePump</title>
  </head>
  <body>
    <!-- Starting with the Header of the Site-->
    <header class="main-header">
      <a href="/" class="brand-logo">
        <img src="logo_header.png">
        <div class="brand-logo-name">IndiePump</div>
      </a>
      <nav class="main-nav">
        <ul>
          <li><a href="login_dark.html">Join Us</a></li>
          <li><a href="index.html" class="moon-button"></a></li>
        </ul>
      </nav>
    </header>
    <!-- Setting Up the Footer-Bar of the Site-->
    <footer class="main-footer">
      <nav class="footer-container">
        <ul>
          <li>
            <a href="#" class="contact-link">
              <img src="social_icons/dark/email.png"</img>
              Contact Us
            </a>
          </li>
          <div class="copyright-container">
            <img src="social_icons/dark/copyright.png"></img>
            <p>2021</p>
          </div>
          <div class="dev-container">
            <img src="social_icons/dark/developed.png"></img>
            <p>Ver 1.0</p>
          </div>
        </nav>
        <nav class="footer-container">
          <ul>
            <li>
              <a href="#" class="facebook-link">
                <img src="social_icons/dark/facebook.png"></img>
              </a>
            </li>
            <li>
              <a href="#" class="twitter-link">
                <img src="social_icons/dark/twitter.png"></img>
              </a>
            </li>
            <!--<li>
              <a href="#" class="instagram-link">
                <img scr="social_icons/dark/instagram.jpg"></img>
              </a>
            </li>-->
            <li>
              <a href="#" class="discord-link">
                <img src="social_icons/dark/discord.png"></img>
              </a>
            </li>
            <li>
              <a href="#" class="messenger-link">
                <img src="social_icons/dark/messenger.png"></img>
              </a>
            </li>

      </nav>
    </footer>

</body>
</html>



*/ 
The CSS Part
/*
@import url("https://fonts.googleapis.com/css?family=Poppins:400,500,700");

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  display; grid;
  padding: 0;
  margin: auto;
  width: 100%;
  background-color: #1a1b20;
  font-family: Poppins, sans-serif;
  font-size: 1.2rem;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-header {
  height: 110px
}

.brand-logo {
  display: flex;
  align-items: center;
  font-size: 1.25em;
  color: gold;
  text-decoration: none;
}

.brand-logo-name {
  margin-left: 1rem;
}

.main-nav {
  display: flex;
  text-align: center;
  justify-content: center;
}

.main-nav ul {
  display: flex;
  height: auto;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: center;
  text-align: center;
  list-style: none;
}

.main-nav a {
  color: gold;
  text-decoration: none;
  padding: 1rem;
}

.main-nav a:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.moon-button {
  background-image: url(moon.png);
  background-color: #1a1b20;
  background-repeat: no-repeat;
  color: rgba(0,0,0,0);
  display: flex;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: center;
  width: 65px;
  height: 65px;
  border: 0;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  -webkit-appearance: none;
  outline: none;
}

.moon-button:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.main-footer {
  display: flex;
  height: 65px;
  justify-content: space-between;
  align-items: center;
  bottom: 0;
}

.footer-container {
  display: flex;
  text-align: center;
  justify-content: space-between;
  align-items: center;
}

.footer-container ul{
  display: flex;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  font-size: 0.9rem;
  list-style: none;
}

.contact-link {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.contact-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.copyright-container {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.copyright-container:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.dev-container {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.dev-container:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.facebook-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.facebook-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.twitter-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.twitter-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.discord-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.discord-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.discord-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.discord-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.messenger-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.messenger-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

如果您真的不想使用javascript,在本例中也可以使用php。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link href="index_dark.css" rel="stylesheet">
  <link href="home_dark.css" rel="stylesheet">
  <title>IndiePump</title>
  </head>
  <body>
    <!-- Starting with the Header of the Site-->
    <header class="main-header">
      <a href="/" class="brand-logo">
        <img src="logo_header.png">
        <div class="brand-logo-name">IndiePump</div>
      </a>
      <nav class="main-nav">
        <ul>
          <li><a href="login_dark.html">Join Us</a></li>
          <li><a href="index.html" class="moon-button"></a></li>
        </ul>
      </nav>
    </header>
    <!-- Setting Up the Footer-Bar of the Site-->
    <footer class="main-footer">
      <nav class="footer-container">
        <ul>
          <li>
            <a href="#" class="contact-link">
              <img src="social_icons/dark/email.png"</img>
              Contact Us
            </a>
          </li>
          <div class="copyright-container">
            <img src="social_icons/dark/copyright.png"></img>
            <p>2021</p>
          </div>
          <div class="dev-container">
            <img src="social_icons/dark/developed.png"></img>
            <p>Ver 1.0</p>
          </div>
        </nav>
        <nav class="footer-container">
          <ul>
            <li>
              <a href="#" class="facebook-link">
                <img src="social_icons/dark/facebook.png"></img>
              </a>
            </li>
            <li>
              <a href="#" class="twitter-link">
                <img src="social_icons/dark/twitter.png"></img>
              </a>
            </li>
            <!--<li>
              <a href="#" class="instagram-link">
                <img scr="social_icons/dark/instagram.jpg"></img>
              </a>
            </li>-->
            <li>
              <a href="#" class="discord-link">
                <img src="social_icons/dark/discord.png"></img>
              </a>
            </li>
            <li>
              <a href="#" class="messenger-link">
                <img src="social_icons/dark/messenger.png"></img>
              </a>
            </li>

      </nav>
    </footer>

</body>
</html>



*/ 
The CSS Part
/*
@import url("https://fonts.googleapis.com/css?family=Poppins:400,500,700");

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  display; grid;
  padding: 0;
  margin: auto;
  width: 100%;
  background-color: #1a1b20;
  font-family: Poppins, sans-serif;
  font-size: 1.2rem;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-header {
  height: 110px
}

.brand-logo {
  display: flex;
  align-items: center;
  font-size: 1.25em;
  color: gold;
  text-decoration: none;
}

.brand-logo-name {
  margin-left: 1rem;
}

.main-nav {
  display: flex;
  text-align: center;
  justify-content: center;
}

.main-nav ul {
  display: flex;
  height: auto;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: center;
  text-align: center;
  list-style: none;
}

.main-nav a {
  color: gold;
  text-decoration: none;
  padding: 1rem;
}

.main-nav a:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.moon-button {
  background-image: url(moon.png);
  background-color: #1a1b20;
  background-repeat: no-repeat;
  color: rgba(0,0,0,0);
  display: flex;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: center;
  width: 65px;
  height: 65px;
  border: 0;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  -webkit-appearance: none;
  outline: none;
}

.moon-button:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.main-footer {
  display: flex;
  height: 65px;
  justify-content: space-between;
  align-items: center;
  bottom: 0;
}

.footer-container {
  display: flex;
  text-align: center;
  justify-content: space-between;
  align-items: center;
}

.footer-container ul{
  display: flex;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  font-size: 0.9rem;
  list-style: none;
}

.contact-link {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.contact-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.copyright-container {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.copyright-container:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.dev-container {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.dev-container:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.facebook-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.facebook-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.twitter-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.twitter-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.discord-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.discord-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.discord-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.discord-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.messenger-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.messenger-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

这有助于通过简单的代码行将页眉和页脚包含在所需的页面中。

如果您希望将来使用Javascript,您可以这样做...

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link href="index_dark.css" rel="stylesheet">
  <link href="home_dark.css" rel="stylesheet">
  <title>IndiePump</title>
  </head>
  <body>
    <!-- Starting with the Header of the Site-->
    <header class="main-header">
      <a href="/" class="brand-logo">
        <img src="logo_header.png">
        <div class="brand-logo-name">IndiePump</div>
      </a>
      <nav class="main-nav">
        <ul>
          <li><a href="login_dark.html">Join Us</a></li>
          <li><a href="index.html" class="moon-button"></a></li>
        </ul>
      </nav>
    </header>
    <!-- Setting Up the Footer-Bar of the Site-->
    <footer class="main-footer">
      <nav class="footer-container">
        <ul>
          <li>
            <a href="#" class="contact-link">
              <img src="social_icons/dark/email.png"</img>
              Contact Us
            </a>
          </li>
          <div class="copyright-container">
            <img src="social_icons/dark/copyright.png"></img>
            <p>2021</p>
          </div>
          <div class="dev-container">
            <img src="social_icons/dark/developed.png"></img>
            <p>Ver 1.0</p>
          </div>
        </nav>
        <nav class="footer-container">
          <ul>
            <li>
              <a href="#" class="facebook-link">
                <img src="social_icons/dark/facebook.png"></img>
              </a>
            </li>
            <li>
              <a href="#" class="twitter-link">
                <img src="social_icons/dark/twitter.png"></img>
              </a>
            </li>
            <!--<li>
              <a href="#" class="instagram-link">
                <img scr="social_icons/dark/instagram.jpg"></img>
              </a>
            </li>-->
            <li>
              <a href="#" class="discord-link">
                <img src="social_icons/dark/discord.png"></img>
              </a>
            </li>
            <li>
              <a href="#" class="messenger-link">
                <img src="social_icons/dark/messenger.png"></img>
              </a>
            </li>

      </nav>
    </footer>

</body>
</html>



*/ 
The CSS Part
/*
@import url("https://fonts.googleapis.com/css?family=Poppins:400,500,700");

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  display; grid;
  padding: 0;
  margin: auto;
  width: 100%;
  background-color: #1a1b20;
  font-family: Poppins, sans-serif;
  font-size: 1.2rem;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-header {
  height: 110px
}

.brand-logo {
  display: flex;
  align-items: center;
  font-size: 1.25em;
  color: gold;
  text-decoration: none;
}

.brand-logo-name {
  margin-left: 1rem;
}

.main-nav {
  display: flex;
  text-align: center;
  justify-content: center;
}

.main-nav ul {
  display: flex;
  height: auto;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: center;
  text-align: center;
  list-style: none;
}

.main-nav a {
  color: gold;
  text-decoration: none;
  padding: 1rem;
}

.main-nav a:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.moon-button {
  background-image: url(moon.png);
  background-color: #1a1b20;
  background-repeat: no-repeat;
  color: rgba(0,0,0,0);
  display: flex;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: center;
  width: 65px;
  height: 65px;
  border: 0;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  -webkit-appearance: none;
  outline: none;
}

.moon-button:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.main-footer {
  display: flex;
  height: 65px;
  justify-content: space-between;
  align-items: center;
  bottom: 0;
}

.footer-container {
  display: flex;
  text-align: center;
  justify-content: space-between;
  align-items: center;
}

.footer-container ul{
  display: flex;
  margin: auto;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  font-size: 0.9rem;
  list-style: none;
}

.contact-link {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.contact-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.copyright-container {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.copyright-container:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.dev-container {
  display: flex;
  margin: auto;
  margin-left: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.dev-container:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.facebook-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.facebook-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.twitter-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.twitter-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.discord-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.discord-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.discord-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.discord-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}

.messenger-link {
  display: flex;
  margin: auto;
  margin-right: 1rem;
  padding: 0;
  align-items: center;
  justify-content: space-between;
  border-radius: 0;
  outline: 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-indent: 10px;
  color: gold;
  outline: none;
}

.messenger-link:hover {
  opacity: 0.5;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
}
  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航