Bootstrap响应式布局,彻底改变中大屏设计中的小屏设计

问题描述 投票:0回答:1

所以首先我使用 html css 和 js 构建一个页脚。然后我发现了 Bootstrap 并尝试使用 Bootstrap、移动优先设计来创建它 <576px.

在发现 bootstrap 之前,我已经使用 css 在中型和大型桌面中完成了页脚。现在我已经使用引导程序在小屏幕上完成了页脚。不过,我对如何将布局从小屏幕更改为中型和大屏幕并不感到困惑。

所以我想保留这两种设计,但我无法这样做。我知道如何使用引导程序创建中型和大屏幕,但现在我已经编写了小屏幕代码,我不知道如何构建中型和大屏幕的响应代码。

所以基本上应该如此,中型和大型屏幕将使用 1 行 3 列 4 的网格。 但我没能找到如何从我当前的代码转换它。

手机当前代码:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Footer</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" />
  </head>
  <body>
    <footer class="container-fluid bg-secondary fixed-bottom">
      <h1 class="text-black text-center">Ready To Meet The Future?</h1>
      <h6 class="text-center mb-3 fw-normal">Stay up to date with our news and articles</h6>
      <div class="container">
        <div class="row mx-0 px-0 justify-content-center mb-3">
          <div class="col-7 offset-1 px-0">
            <input class="rounded border-0 w-100 h-100" type="email" placeholder="Email Address" />
          </div>
          <div class="col-4">
            <button class="btn btn-danger w-100 h-100" onclick="ClickSubscribe()">Submit</button>
          </div>
        </div>
      </div>
      <hr class="d-md-none my-1" />
      <div class="row px-1">
        <div class="col-3 text-center">
          <a href="#" class="text-black text-decoration-none">Home</a>
        </div>
        <div class="col-3 text-center">
          <a href="#" class="text-black text-decoration-none">About</a>
        </div>
        <div class="col-3 text-center">
          <a href="#" class="text-black text-decoration-none">Product</a>
        </div>
        <div class="col-3 text-center">
          <a href="#" class="text-black text-decoration-none">Contact Us</a>
        </div>
      </div>
      <hr class="my-1 py-0" />
      <div class="container-fluid px-1">
        <div class="row">
          <div class="col-5 offset-1 px-0">©Watches</div>
          <div class="col-5 text-end px-0">
            <a href="#"><i class="fa-brands fa-instagram text-black ms-2"></i></a>
            <a href="#"><i class="fa-brands fa-twitter text-black ms-2"></i></a>
            <a href="#"><i class="fa-brands fa-whatsapp text-black ms-2"></i></a>
            <a href="#"><i class="fa-brands fa-facebook text-black ms-2"></i></a>
          </div>
        </div>
      </div>
    </footer>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
  </body>
</html>

仅使用CSS的旧代码

    <div class="footer-section">
      <div class="footer-subscribe">
        <!-- TODO: Make it 2 Line, Responsive? -->
        <h1>Ready To Meet The Future?</h1>
        <div class="footer-subscription">
          <input
            class="footer-email"
            type="email"
            placeholder="Email Address"
          />
          <button class="footer-subscribe-button" onclick="ClickSubscribe()">
            Submit
          </button>
        </div>
      </div>
      <div class="footer-nav">
        <div class="footer-link">
          <a href="#">Home</a>
          <a href="#">About</a>
          <a href="#">Product</a>
          <a href="#">Contact Us</a>
        </div>
        <div class="footer-contact">
          <a href="#"><i class="fa-brands fa-instagram"></i></a>
          <a href="#"><i class="fa-brands fa-twitter"></i></a>
          <a href="#"><i class="fa-brands fa-whatsapp"></i></a>
          <a href="#"><i class="fa-brands fa-facebook"></i></a>
        </div>
      </div>
    </div>
    <div class="footer-copyright">
      <hr />
      <span>Copyright By Watches</span>
    </div>
  </div>

CSS

.footer-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.footer {
  width: 100%;
  background-color: #e7e7e7;
  padding: 20px 10% 20px;
}

.footer a {
  text-decoration: none;
  color: black;
}

.footer h1 {
  margin: 0px;
  font-size: 56px;
}

.footer-section {
  display: flex;
  justify-content: space-between;
}

.footer-subscribe {
  flex: 1;
  margin-right: 10px;
  gap: 3rem;
  border-right: 2px solid;
}

.footer-subscription {
  display: flex;
  margin-right: 3rem;
  margin-top: 1rem;
}

.footer-email {
  width: 60%;
  padding: 1rem;
  margin-right: 3rem;
  border: none;
  border-radius: 36px;
  box-sizing: border-box;
  outline: none;
}

.footer-subscribe-button {
  background-color: red;
  color: white;
  border: none;
  padding: 0px 2rem;
  font-size: 16px;
}

.footer-nav {
  flex: 1;
  display: flex;
}

.footer-link {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  margin-right: 10px;
  border-right: 2px solid;
}

.footer-contact {
  display: flex;
  flex: 1;
  flex-direction: column;
  flex-wrap: wrap;
  justify-content: space-between;
}

.footer-contact i {
  font-size: 20px;
}

.footer-copyright {
  margin: 20px 0px;
  font-size: 12px;
  font-weight: bold;
}

.footer-copyright hr {
  border-top: 2.5px solid black;
}

@media (max-width: 768px) {
  .footer h1 {
    font-size: 36px;
  }

  .footer-subscribe {
    margin-right: 20px;
    border-right: 1px solid;
  }

  .footer-subscription {
    flex-direction: column;
  }

  .footer-email {
    width: 100%;
    margin: 0 0 1rem 0;
  }

  .footer-subscribe-button {
    width: 100%;
    padding: 1rem;
  }

  .footer-nav {
    flex-direction: row;
  }

  .footer-link {
    border-right: 1px solid;
    margin-right: 20px;
  }

  .footer-contact i {
    font-size: 28px;
  }
}

这是中号大号设计 中大屏

这就是小设计 小屏幕

所以基本上我想保留这两种设计,但我无法做到。我实际上有一个技巧,但它基本上分别创建了 2 个设计,而不是使其响应。所以我可以为小型设计做

d-md-none
并创建中型和大型设计。但显然这不是办法

html css responsive-design bootstrap-5
1个回答
0
投票

那你不应该先做1行3列4吗?中大屏设计完成后可以调整设计。然后你可以从这些代码中调整小屏幕。小屏幕设计需要改变,但就是这样

© www.soinside.com 2019 - 2024. All rights reserved.