html - 在页脚中居中标题以组织它

我能够找到一个 html 和 css 代码来开始创建我的页脚。我能够让它看起来有点像我想要的,如下面的代码所示:

但是,我希望能够将所有三个标题居中,但我似乎无法找到如何...

* {
  margin: 0;
  padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
body {
  line-height: 1.5;
  font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.textDecoration {
  text-decoration: none;
  color: inherit;
}

.container {
  max-width: 100%;
  margin: 0px;
}

.row {
  display: flex;
  flex-wrap: wrap;
}

ul {
  list-style: none;
}

.footer {
  background-color: #24262b;
  padding: 0px 0;
  width: 100%;
}

.footer-col {
  width: 25%;
  padding: 0 15px;
}

.footer-col h4 {
  font-size: 18px;
  color: #ffffff;
  text-transform: capitalize;
  margin-bottom: 35px;
  font-weight: 500;
  position: relative;
}

.footer-col h4::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: -10px;
  background-color: red;
  height: 2px;
  box-sizing: border-box;
  width: 50px;
}

.footer-col ul li:not(:last-child) {
  margin-bottom: 10px;
}

.footer-col ul li a {
  font-size: 16px;
  text-transform: capitalize;
  color: #ffffff;
  text-decoration: none;
  font-weight: 300;
  color: #bbbbbb;
  display: block;
  transition: all 0.3s ease;
}

.footer-col ul li a:hover {
  color: #ffffff;
  padding-left: 8px;
}

.footer-col .social-links a {
  display: inline-block;
  height: 40px;
  width: 40px;
  background-color: rgba(255, 255, 255, 0.2);
  margin: 0 10px 10px 0;
  text-align: center;
  line-height: 40px;
  border-radius: 50%;
  color: #ffffff;
  transition: all 0.5s ease;
}

.footer-col .social-links a:hover {
  color: #24262b;
  background-color: #ffffff;
}
<p>In this example, we remove the bullets from the list, and its default padding and margin.</p>

<ul>
  <li><a href="#home">Home</a></li>
  <li><a href="#news">News</a></li>
  <li><a href="#contact">Contact</a></li>
  <li><a href="#about">About</a></li>
</ul>

<footer class="footer">
  <div class="container">
    <div class="row">
      <div class="footer-col">
        <h4>Terms & Conditions</h4>
      </div>
      <div class="footer-col">
        <h4><a class="textDecoration" href="#privacy">Privacy and Policy</a></h4>
      </div>

      <div class="footer-col">
        <h4>Follow Us</h4>
        <div class="social-links">

        </div>
      </div>
      <div class="footer-col">
        <div class="social-links">
          <h3><img src="https://i.ibb.co/Lp1sB0M/face4.png"></a>
            <img src="https://i.ibb.co/XVzFjBR/ig3.png"></a>
            <img src="https://i.ibb.co/vVRq5dz/tw2.png"></a>
            <img src="https://i.ibb.co/8j8dWcG/yt2.png"></a>
          </h3>
        </div>
      </div>
    </div>
</footer>

您可以为我提供任何提示来实现这一目标吗?您会为页脚的社交网络图标推荐什么?

回答1

将所有 h4 放在一个 footer-col div 中是有意义的,因为您希望它们在中心分组。所以你可以这样做,然后将 display: flex; 添加到 footer-col 并使用 justify-content: center; 将它们居中。然后你可以添加一个 gap 来分隔它们。我还在您的 social-links 上添加了 display: flex; 以允许它们弯曲以保持在同一行。

* {
  margin: 0;
  padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
body {
  line-height: 1.5;
  font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.social-links {
  display: flex;
}

.textDecoration {
  text-decoration: none;
  color: inherit;
}

.container {
  max-width: 100%;
  margin: 0px;
}

.row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
}

ul {
  list-style: none;
}

.footer {
  background-color: #24262b;
  padding: 0px 0;
  width: 100%;
}

.footer-col {
  display: flex;
  width: 100%;
  justify-content: center;
  gap: 2em;
}

.footer-col h4 {
  font-size: 18px;
  color: #ffffff;
  text-transform: capitalize;
  margin-bottom: 35px;
  font-weight: 500;
  position: relative;
}

.footer-col h4::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: -10px;
  background-color: red;
  height: 2px;
  box-sizing: border-box;
  width: 50px;
}

.footer-col ul li:not(:last-child) {
  margin-bottom: 10px;
}

.footer-col ul li a {
  font-size: 16px;
  text-transform: capitalize;
  color: #ffffff;
  text-decoration: none;
  font-weight: 300;
  color: #bbbbbb;
  display: block;
  transition: all 0.3s ease;
}

.footer-col ul li a:hover {
  color: #ffffff;
  padding-left: 8px;
}

.footer-col .social-links a {
  display: inline-block;
  height: 40px;
  width: 40px;
  background-color: rgba(255, 255, 255, 0.2);
  margin: 0 10px 10px 0;
  text-align: center;
  line-height: 40px;
  border-radius: 50%;
  color: #ffffff;
  transition: all 0.5s ease;
}

.footer-col .social-links a:hover {
  color: #24262b;
  background-color: #ffffff;
}
<!DOCTYPE html>
<html>

<head>
  <style>

  </style>
</head>

<body>

  <p>In this example, we remove the bullets from the list, and its default padding and margin.</p>

  <ul>
    <li><a href="#home">Home</a></li>
    <li><a href="#news">News</a></li>
    <li><a href="#contact">Contact</a></li>
    <li><a href="#about">About</a></li>
  </ul>

  <footer class="footer">
    <div class="container">
      <div class="row">
        <div class="footer-col">
          <h4>Terms & Conditions</h4>
          <h4><a class="textDecoration" href="#privacy">Privacy and Policy</a></h4>
          <h4>Follow Us</h4>
        </div>
        <div class="social-links"><img src="./img/face4.png">
          <img src="./img/ig3.png">
          <img src="./img/tw2.png">
          <img src="./img/yt2.png">
        </div>
      </div>

    </div>
  </footer>

</body>

</html>

相似文章

c++ - 所有尖括号的名称是什么?

在C++中,我们在不同的地方有尖括号,我认为有时在与其他开发人员交谈时区分它们很重要,例如在暴徒编程期间导航某人时(例如“转到第36行中的箭头运算符”或“现在写宇宙飞船运算符”)。虽然我当然可以称它们...