图标不会显示在台式计算机的页脚中

Posted

技术标签:

【中文标题】图标不会显示在台式计算机的页脚中【英文标题】:Icons will NOT show in footer on desktop computer 【发布时间】:2020-07-22 16:02:17 【问题描述】:

下午好!我有一个奇怪的问题。我正在创建一个网页只是为了测试我的新手技能。我创建了一个包含一些图像(社交媒体图标)的页脚。每当我在桌面上时,这些图像绝对不会出现在页脚中。每当我在笔记本电脑上时,它们都会完美显示。

在我的桌面上,如果我将图标移动到 html<main> 中,它们就会显示出来。当我把它们放在我的<footer> 区域时,它们就消失了。有没有人遇到过这个?有人可以帮忙吗?

这是 HTML 代码...

* 
  box-sizing: border-box;


body 
  background-color: rgb(219, 219, 219);
  margin: 0;



/*Header CSS code*/

header 
  display: flex;
  flex-direction: column;
  align-items: center;


.logo 
  width: 125px;
  height: 125px;
  border: 2px solid black;
  border-radius: 50%;
  margin-top: 10px;


.under-logo 
  display: flex;
  padding: 10px;


.lambo-logo 
  width: 145px;
  height: 80px;
  border-radius: 20px;
  padding: 10px;


.title 
  font-family: 'Merriweather', serif;



/*Navigation Bar CSS code*/

nav 
  height: 50px;
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid black;
  border-bottom: 1px solid black;
  background-color: rgb(70, 70, 70);
  border: 2px solid black;


.nav-links 
  color: white;
  font-size: 25px;
  padding: 10px 20px;


.nav-links:hover 
  background-color: rgb(0, 0, 150);
  cursor: pointer;
  transition: 0.5s;
  border-radius: 50%;



/*Signup Form CSS code*/

.signup-title 
  text-align: center;


form 
  margin-left: auto;
  margin-right: auto;
  width: 500px;
  border: 2px solid black;
  border-radius: 40px;
  padding-bottom: 20px;
  padding-left: 20px;
  padding-right: 20px;
  margin-top: 10px;
  background-color: rgb(0, 0, 150);
  color: white;


fieldset 
  border: 2px solid black;
  border-radius: 40px;
  width: 400px;
  height: 210px;
  padding: 20px;
  font-size: 25px;
  font-weight: bold;
  margin-right: auto;
  margin-left: auto;
  background-color: rgb(219, 219, 219);
  color: black;


input[type="text"],
[type="email"] 
  width: 100%;
  font-size: 15px;
  height: 30px;
  padding-left: 5px;


button[type="submit"] 
  width: 100%;
  height: 40px;
  margin-top: 10px;
  font-size: 20px;
  font-weight: bold;
  border: 2px solid black;
  border-radius: 40px;
  background-color: rgb(0, 0, 150);
  color: white;


button[type="submit"]:hover 
  cursor: url(Images/pagani-cursor.png) 55 55, auto;
  background-color: green;
  color: white;
  transition: .5s;



/*Car CSS code - Main content of page*/

.cars 
  display: flex;
  flex-direction: column;


.car-name 
  margin-top: 0px;


.car-stats 
  margin-top: 0px;
  margin-bottom: 5px;


.car-display 
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: white;
  padding: 20px;
  border: 2px solid black;
  border-radius: 40px;
  margin-top: 20px;
  margin-bottom: 20px;


.car 
  width: 300px;
  border-radius: 40px;
  border: 2px solid black;



/*Footer CSS code*/

footer 
  background-color: rgb(70, 70, 70);
  height: 75px;
  width: 100%;
  position: absolute;
  border: 2px solid black;
  display: flex;
  justify-content: center;


.footer-text 
  color: white;
  margin-top: 0;
  font-family: 'Merriweather', serif;


.social-icons 
  display: flex;



/*Code for larger screens*/

@media screen and (min-width: 800px) 
  .cars 
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    flex-wrap: wrap;
    padding: 20px;
  
<!DOCTYPE html>
<html lang="en">
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Venny's Cars</title>
  <link href="main.css" rel="stylesheet" type="text/css" />
  <link href="https://fonts.googleapis.com/css2?family=Merriweather:wght@300&display=swap" rel="stylesheet">
</head>

<body>
  <!--Below is the logo and title for the website-->
  <header class="header">
    <img src="Images\VennyDolphin.jpg"  class="logo">
    <div class="under-logo">
      <img src="Images/lambo-logo-reverse.png"  class="lambo-logo">
      <h1 class="title">Venny's Cars</h1>
      <img src="Images/lambo-logo.png"  class="lambo-logo">
    </div>
  </header>
  <!--Below is the Navigation Bar-->
  <nav class="navbar">
    <div class="nav-links"><a href: "#">Link</a></div>
    <div class="nav-links"><a href: "#">2nd Link</a></div>
    <div class="nav-links"><a href: "#">3rd Link</a></div>
  </nav>
  <!--Here is the signup form-->
  <main>
    <form class="signup-form" action="newsletter.html" method="POST">
      <h1 class="signup-title">Sign Up for our Newsletter!</h1>
      <fieldset class="name-email-input">
        <div>
          <label>First Name:</label>
          <input type="text" id="firstname" name="firstname" placeholder="John" required>
        </div>
        <div>
          <label>Email:</label>
          <input type="email" id="email" name="email" placeholder="John@123.com" required>
        </div>
        <!--Signup Button-->
        <div class="button">
          <button type="submit" id="button">Sign Up!</button>
        </div>
      </fieldset>
    </form>
    <!--Below is our section for the cars-->
    <div class="cars">
      <!--Porsche 911 GT2 RS-->
      <div class="car-display">
        <h1 class="car-name">Porsche 911 GT2 RS</h1>
        <img src="Images\gt2rs.jpg" class="car gt2rs" >
        <ul>
          <h2 class="car-stats">Car Stats</h2>
          <li>Engine: 3.8-liter Twin-Turbo Flat 6</li>
          <li>HP: 690hp @ 7000rpm</li>
          <li>Torque: 553 lb-ft @ 2500rpm</li>
          <li>Price: $293,200</li>
        </ul>
        <iframe   src="https://www.youtube.com/embed/PwAhAFyMwk8" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
      </div>
      <!--Koenigsegg One:1-->
      <div class="car-display">
        <h1 class="car-name">Koenigsegg One:1</h1>
        <img src="Images\k1.jpg" class="car k1" >
        <ul>
          <h2 class="car-stats">Car Stats</h2>
          <li>Engine: 5.0-liter Twin-Turbo V8</li>
          <li>HP: 1341hp @ 7500rpm</li>
          <li>Torque: 1010 lb-ft @ 6000rpm</li>
          <li>Price: $2,850,000</li>
        </ul>
        <iframe   src="https://www.youtube.com/embed/7X1z-1xwquk" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
      </div>
      <!--Porsche 918 Spyder-->
      <div class="car-display">
        <h1 class="car-name">Porsche 918 Spyder</h1>
        <img src="Images\918.jpg" class="car 918" >
        <ul>
          <h2 class="car-stats">Car Stats</h2>
          <li>Engine: 4.6-liter V8 Hybrid</li>
          <li>HP: 887hp @ 8600rpm</li>
          <li>Torque: 944 lb-ft @ 5000rpm</li>
          <li>Price: $845,000</li>
        </ul>
        <iframe   src="https://www.youtube.com/embed/nSqzp3kdAm4" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
      </div>
    </div>
  </main>
  <!--Below is the footer-->
  <footer>
    <h2 class="footer-text">Follow me for new additions!</h2>
    <div class="social-icons">
      <a href="#" target="_blank"><img src="Images/facebook.png" ></a>
      <a href="#" target="_blank"><img src="Images/insta.png" ></a>
    </div>
  </footer>
  <script src="script.js"></script>
  <!--Link to javascript-->
  <script src="action.js"></script>
</body>

</html>

【问题讨论】:

这绝对是一个有趣的问题。还要考虑计算机之间的屏幕尺寸和操作系统(Apple、Windows)等内容。你用的是什么css?你在做类似背景的东西吗:url()? @NathanMartin 我所做的唯一 CSS 是将页脚设置在页面底部并为其添加背景颜色。我的文字“关注我以获取新内容!”在页脚内显示得很好。至于不同的设备,我在两台 Windows 计算机之间切换。我的桌面是自定义构建的,但我不知道这是否有什么不同。我也玩过屏幕尺寸。这对我来说没有任何改变。 @RachelGallen 我编辑了我的帖子并添加了页脚的 HTML。 @DustinVenable 请编辑您的问题以添加 css(以及更多主要内容)。顺便说一句,您不需要类页脚,因为页脚是本机标签。此外,路径中的斜线应该指向前方。 @RachelGallen 我添加了所有的 HTML 和 CSS。我还取出了 class="footer" 并反转了我的斜线。我很感激这方面的帮助。我只有 2 周的时间来学习这些东西,所以我的无知程度很高。 【参考方案1】:

在测试您的代码后,这是一个路径问题,但您的代码中确实存在一些其他需要解决的错误。您在顶部的链接已发布为&lt;a href:"#" &gt;Link 1&lt;/a&gt; 等;用冒号代替等号。将链接中的“:”替换为“=”,即使链接为空白。此外,正如已经指出的那样,在许多地方,您都有反斜杠,其中斜杠应该指向前方。 (只有一些已被纠正)。出于 sn-p 的目的,我在头部注释掉了样式表的链接,因为 css 是单独列出的。

关于路径,我使用完整域名在网站上输入了一个 facebook 图标的路径,然后图标就显示出来了。它相当大,所以我为您的社交图标图像添加了一个类以减小大小。根据图标的大小,根据需要调整或删除它。我看到的关于未出现图标的主要问题是您需要更正代码中的文件路径。

希望对你有帮助

* 
  box-sizing: border-box;


body 
  background-color: rgb(219, 219, 219);
  margin: 0;



/*Header CSS code*/

header 
  display: flex;
  flex-direction: column;
  align-items: center;


.logo 
  width: 125px;
  height: 125px;
  border: 2px solid black;
  border-radius: 50%;
  margin-top: 10px;


.under-logo 
  display: flex;
  padding: 10px;


.lambo-logo 
  width: 145px;
  height: 80px;
  border-radius: 20px;
  padding: 10px;


.title 
  font-family: 'Merriweather', serif;



/*Navigation Bar CSS code*/

nav 
  height: 50px;
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid black;
  border-bottom: 1px solid black;
  background-color: rgb(70, 70, 70);
  border: 2px solid black;


.nav-links 
  color: white;
  font-size: 25px;
  padding: 10px 20px;


.nav-links:hover 
  background-color: rgb(0, 0, 150);
  cursor: pointer;
  transition: 0.5s;
  border-radius: 50%;



/*Signup Form CSS code*/

.signup-title 
  text-align: center;


form 
  margin-left: auto;
  margin-right: auto;
  width: 500px;
  border: 2px solid black;
  border-radius: 40px;
  padding-bottom: 20px;
  padding-left: 20px;
  padding-right: 20px;
  margin-top: 10px;
  background-color: rgb(0, 0, 150);
  color: white;


fieldset 
  border: 2px solid black;
  border-radius: 40px;
  width: 400px;
  height: 210px;
  padding: 20px;
  font-size: 25px;
  font-weight: bold;
  margin-right: auto;
  margin-left: auto;
  background-color: rgb(219, 219, 219);
  color: black;


input[type="text"],
[type="email"] 
  width: 100%;
  font-size: 15px;
  height: 30px;
  padding-left: 5px;


button[type="submit"] 
  width: 100%;
  height: 40px;
  margin-top: 10px;
  font-size: 20px;
  font-weight: bold;
  border: 2px solid black;
  border-radius: 40px;
  background-color: rgb(0, 0, 150);
  color: white;


button[type="submit"]:hover 
  cursor: url(Images/pagani-cursor.png) 55 55, auto;
  background-color: green;
  color: white;
  transition: .5s;



/*Car CSS code - Main content of page*/

.cars 
  display: flex;
  flex-direction: column;


.car-name 
  margin-top: 0px;


.car-stats 
  margin-top: 0px;
  margin-bottom: 5px;


.car-display 
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: white;
  padding: 20px;
  border: 2px solid black;
  border-radius: 40px;
  margin-top: 20px;
  margin-bottom: 20px;


.car 
  width: 300px;
  border-radius: 40px;
  border: 2px solid black;



/*Footer CSS code*/

footer 
  background-color: rgb(70, 70, 70);
  height: 75px;
  width: 100%;
  position: absolute;
  border: 2px solid black;
  display: flex;
  justify-content: center;


.footer-text 
  color: white;
  margin-top: 0;
  font-family: 'Merriweather', serif;


.social-icons 
  display: flex;


.social-icons a img 
  max-width: 26px;
  height: auto;
  margin: 2px 5px;



/*Code for larger screens*/

@media screen and (min-width: 800px) 
  .cars 
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    flex-wrap: wrap;
    padding: 20px;
  
<!DOCTYPE html>
<html lang="en">
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Venny's Cars</title>
  <!--  <link href="main.css" rel="stylesheet" type="text/css" />
  <link href="https://fonts.googleapis.com/css2?family=Merriweather:wght@300&display=swap" rel="stylesheet">-->
</head>

<body>
  <!--Below is the logo and title for the website-->
  <header class="header">
    <img src="Images/VennyDolphin.jpg"  class="logo">
    <div class="under-logo">
      <img src="Images/lambo-logo-reverse.png"  class="lambo-logo">
      <h1 class="title">Venny's Cars</h1>
      <img src="Images/lambo-logo.png"  class="lambo-logo">
    </div>
  </header>
  <!--Below is the Navigation Bar-->
  <nav class="navbar">
    <div class="nav-links"><a href="#">Link</a></div>
    <div class="nav-links"><a href="#">2nd Link</a></div>
    <div class="nav-links"><a href="#">3rd Link</a></div>
  </nav>
  <!--Here is the signup form-->
  <main>
    <form class="signup-form" action="newsletter.html" method="POST">
      <h1 class="signup-title">Sign Up for our Newsletter!</h1>
      <fieldset class="name-email-input">
        <div>
          <label>First Name:</label>
          <input type="text" id="firstname" name="firstname" placeholder="John" required>
        </div>
        <div>
          <label>Email:</label>
          <input type="email" id="email" name="email" placeholder="John@123.com" required>
        </div>
        <!--Signup Button-->
        <div class="button">
          <button type="submit" id="button">Sign Up!</button>
        </div>
      </fieldset>
    </form>
    <!--Below is our section for the cars-->
    <div class="cars">
      <!--Porsche 911 GT2 RS-->
      <div class="car-display">
        <h1 class="car-name">Porsche 911 GT2 RS</h1>
        <img src="Images\gt2rs.jpg" class="car gt2rs" >
        <ul>
          <h2 class="car-stats">Car Stats</h2>
          <li>Engine: 3.8-liter Twin-Turbo Flat 6</li>
          <li>HP: 690hp @ 7000rpm</li>
          <li>Torque: 553 lb-ft @ 2500rpm</li>
          <li>Price: $293,200</li>
        </ul>
        <iframe   src="https://www.youtube.com/embed/PwAhAFyMwk8" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
      </div>
      <!--Koenigsegg One:1-->
      <div class="car-display">
        <h1 class="car-name">Koenigsegg One:1</h1>
        <img src="Images/k1.jpg" class="car k1" >
        <ul>
          <h2 class="car-stats">Car Stats</h2>
          <li>Engine: 5.0-liter Twin-Turbo V8</li>
          <li>HP: 1341hp @ 7500rpm</li>
          <li>Torque: 1010 lb-ft @ 6000rpm</li>
          <li>Price: $2,850,000</li>
        </ul>
        <iframe   src="https://www.youtube.com/embed/7X1z-1xwquk" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
      </div>
      <!--Porsche 918 Spyder-->
      <div class="car-display">
        <h1 class="car-name">Porsche 918 Spyder</h1>
        <img src="Images/918.jpg" class="car 918" >
        <ul>
          <h2 class="car-stats">Car Stats</h2>
          <li>Engine: 4.6-liter V8 Hybrid</li>
          <li>HP: 887hp @ 8600rpm</li>
          <li>Torque: 944 lb-ft @ 5000rpm</li>
          <li>Price: $845,000</li>
        </ul>
        <iframe   src="https://www.youtube.com/embed/nSqzp3kdAm4" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
      </div>
    </div>
  </main>
  <!--Below is the footer-->
  <footer>
    <h2 class="footer-text">Follow me for new additions!</h2>
    <div class="social-icons">
      <a href="#" target="_blank"><img src="http://www.msskincarebeautysalon.com/images/facebook-button-blue.png" ></a>
      <a href="#" target="_blank"><img src="Images/insta.png" ></a>
    </div>
  </footer>
  <script src="script.js"></script>
  <!--Link to Javascript-->
  <script src="action.js"></script>
</body>

</html>

【讨论】:

哇!这次真是万分感谢。昨晚弄乱了它之后,我让图标工作了。我正在使用 Live Server 打开页面。每当我在浏览器中复制并粘贴 html 的路径时,一切都显示为应有的样子。我不确定为什么 Live Server 是问题所在,但一切都解决了。至于其他一切,感谢您清理我的代码。这对我的未来非常有帮助。

以上是关于图标不会显示在台式计算机的页脚中的主要内容,如果未能解决你的问题,请参考以下文章

初蒙数据表。计算金额并在页脚中显示

初蒙数据表。计算金额并在页脚中显示

在我的页脚中显示当前年份的最轻量级方式是啥?

想在反应原生应用程序的页脚中显示广告

如何在 ag-grid 表的页脚中启用或显示总行

在heroku上部署的rails应用程序和html代码出现在我的页脚中