我对Bootstrap 5、html和css都是新手.然而,我正在使用它们来创建一个网站,我也在使用Bootstrap 5来创建卡片,但我想让这些卡片可点击,这样它们就会链接到网站上的另一个页面.但在添加锚标签后,卡片仍然不可点击.

Test.html

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>Home |</title>

<meta name="description" content="Write an awesome description for your new site here. It will appear in your document head meta (for Google search results) and in your feed.xml site description." />

<link rel="stylesheet" href="/_bridgetown/static/css/main.c7d4dd3f1984a290e9be.css" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" 
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" 
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" href="../css/index.css" />
<link
          rel="stylesheet"
          data-purpose="Layout StyleSheet"
          title="Default"
    disabled
          href="/css/app-937c1ff7d52fd6f78dd9322599e2b5d4.css?vsn=d"
        >
        <link
          rel="stylesheet"
          data-purpose="Layout StyleSheet"
          title="Web Awesome"

          href="/css/app-wa-8d95b745961f6b33ab3aa1b98a45291a.css?vsn=d"
        >

          <link
            rel="stylesheet"

            href="https://site-assets.fontawesome.com/releases/v6.4.0/css/all.css"
          >

          <link
            rel="stylesheet"

            href="https://site-assets.fontawesome.com/releases/v6.4.0/css/sharp-solid.css"
          >

          <link
            rel="stylesheet"

            href="https://site-assets.fontawesome.com/releases/v6.4.0/css/sharp-regular.css"
          >

          <link
            rel="stylesheet"

            href="https://site-assets.fontawesome.com/releases/v6.4.0/css/sharp-light.css"
          >
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body>

  <!-- SERVICES SECTION START -->
  <section>
    <div class="container">
        <div class="row py-5">
            <h2 class="display-6 mb-4">Our Services</h2>
        <div class="col-lg-4 col-md-6">
          <a href="/about.html" class="nav-link"></a>
          <div class="card text-center p-4 mb-2 crd">
            <i class="fa-solid fa-camera-cctv fa-3x"></i>
            <h4>CCTV Services</h4>
            <p class="p-2">
              <b>CCTV Services</b> are an essential component of any business. CCTV provides real-time monitoring of multiple locations; the security they supply is indispensable, allowing businesses to have peace of mind knowing that...
            </p>
          </div>
        </div>
        <!-- <div class="col-lg-4 col-md-6">
          <div class="card text-center p-4 mb-2">
            <i class="fa-solid fa-sign-hanging fa-3x"></i>
            <h4>Digital Signage</h4>
            <p class="p-2">
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam
              voluptatum, voluptate, quibusdam, quia voluptas quod quos
              exercitationem quae voluptatibus doloribus quidem. Quisquam
            </p>
          </div>
        </div> -->
        <div class="col-lg-4 col-md-6">
          <div class="card text-center p-4 mb-2 crd">
            <i class="fa-solid fa-database fa-3x"></i>
            <h4>Datacenter Support</h4>
            <p class="p-2">
              <b>Datacenters</b> are the foundation of many modern businesses, providing the infrastructure and resources necessary to save, process, and dispense data. They produce an off-premises location to secure and back up your business's data.
            </p>
          </div>
        </div>
        <div class="col-lg-4 col-md-6">
          <div class="card text-center p-4 mb-2 crd">
            <i class="fa-solid fa-sign-hanging fa-3x"></i>
            <h4>Digital Signage</h4>
            <p class="p-2">
              <b>Digital Signage</b> has grown rapidly over the last two decades well beyond just a flashy trend for big businesses in the realm of marketing and advertising, and the general dissemination of information. Now it has become the expected strategy.
            </p>
          </div>
        </div>
        <div class="col-lg-4 col-md-6">
          <div class="card text-center p-4 mb-2 crd">
            <i class="fa-solid fa-headset fa-3x"></i>
            <h4>General Support</h4>
            <p class="p-2">
              <b>General Support</b> is a crucial element to every modern business; providing essential support to businesses of all shapes and sizes. The focal point of General Support is to... 
            </p>
          </div>
        </div>
        <div class="col-lg-4 col-md-6">
          <div class="card text-center p-4 mb-2 crd">
            <i class="fa-solid fa-server fa-3x"></i>
            <h4>Network Support</h4>
            <p class="p-2">
              <b>Network Support</b> includes making sure all networking hardware, software, and other related dependencies are both up to date and functioning properly. Monitoring the network for potential problems...
            </p>
          </div>
              </div>
      <div class="col-lg-4 col-md-6">
        <div class="card text-center p-4 mb-2 crd">
          <i class="fa-solid fa-bars fa-3x"></i>
          <h4>Additional Services</h4>
          <p class="p-2">
            <br/> 
            <br/> 
            <br/> 
            <br/> 
            <br/> 
          </p>
        </div>
      </div>
        </div>
    </div>
  </section>
  <!-- SERVICES SECTION CLOSE -->

  


  </body>
</html>

Test.css

@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');

body {
    background: hsl(233, 47%, 96%);
    font-family: 'Poppins', sans-serif;
}

hr {
    border: 1.5px solid hsl(216, 90%, 44%)
}

.crd {
    background: hsl(233, 47%, 96%);
    transition: all;
}

.crd:hover {
    background: hsl(216, 90%, 44%);
    color: #fff;
    transition: 0.5s;
}

.card img {
    margin: auto;
    
}

#rounded_circle {
    width: 76px;
    aspect-ratio: 1;
    background-color: hsl(0, 0%, 75%);
}

footer a {
    color: hsl(0, 0%, 100%);
}

#footer {
    color: hsl(0, 0%, 100%);
}

#copyright {
    border-top: 1px solid hsl(0, 0%, 20%) ;
}

.c-item {
    height: 480px;
}

.c-img {
    height: 100%;
    object-fit: cover;
    filter: brightness(0.6);
}

#team-img {
    height: 100%;
    object-fit: cover;
}

@media (min-width: 576px) {
    .dropdown:hover > .dropdown-menu {
        display: block;
        margin-top: 0;
    }
}

@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');

body {
    background: hsl(233, 47%, 96%);
    font-family: 'Poppins', sans-serif;
}

hr {
    border: 1.5px solid hsl(216, 90%, 44%)
}

.crd {
    background: hsl(233, 47%, 96%);
    transition: all;
}

.crd:hover {
    background: hsl(216, 90%, 44%);
    color: #fff;
    transition: 0.5s;
}

.card img {
    margin: auto;
    
}

#rounded_circle {
    width: 76px;
    aspect-ratio: 1;
    background-color: hsl(0, 0%, 75%);
}

footer a {
    color: hsl(0, 0%, 100%);
}

#footer {
    color: hsl(0, 0%, 100%);
}

#copyright {
    border-top: 1px solid hsl(0, 0%, 20%) ;
}

.c-item {
    height: 480px;
}

.c-img {
    height: 100%;
    object-fit: cover;
    filter: brightness(0.6);
}

#team-img {
    height: 100%;
    object-fit: cover;
}

@media (min-width: 576px) {
    .dropdown:hover > .dropdown-menu {
        display: block;
        margin-top: 0;
    }
}
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>Home |</title>

<meta name="description" content="Write an awesome description for your new site here. It will appear in your document head meta (for Google search results) and in your feed.xml site description." />

<link rel="stylesheet" href="/_bridgetown/static/css/main.c7d4dd3f1984a290e9be.css" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" 
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" 
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" href="../css/index.css" />
<link
          rel="stylesheet"
          data-purpose="Layout StyleSheet"
          title="Default"
    disabled
          href="/css/app-937c1ff7d52fd6f78dd9322599e2b5d4.css?vsn=d"
        >
        <link
          rel="stylesheet"
          data-purpose="Layout StyleSheet"
          title="Web Awesome"

          href="/css/app-wa-8d95b745961f6b33ab3aa1b98a45291a.css?vsn=d"
        >

          <link
            rel="stylesheet"

            href="https://site-assets.fontawesome.com/releases/v6.4.0/css/all.css"
          >

          <link
            rel="stylesheet"

            href="https://site-assets.fontawesome.com/releases/v6.4.0/css/sharp-solid.css"
          >

          <link
            rel="stylesheet"

            href="https://site-assets.fontawesome.com/releases/v6.4.0/css/sharp-regular.css"
          >

          <link
            rel="stylesheet"

            href="https://site-assets.fontawesome.com/releases/v6.4.0/css/sharp-light.css"
          >
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body>

  <!-- SERVICES SECTION START -->
  <section>
    <div class="container">
        <div class="row py-5">
            <h2 class="display-6 mb-4">Our Services</h2>
        <div class="col-lg-4 col-md-6">
          <a href="/about.html" class="nav-link"></a>
          <div class="card text-center p-4 mb-2 crd">
            <i class="fa-solid fa-camera-cctv fa-3x"></i>
            <h4>CCTV Services</h4>
            <p class="p-2">
              <b>CCTV Services</b> are an essential component of any business. CCTV provides real-time monitoring of multiple locations; the security they supply is indispensable, allowing businesses to have peace of mind knowing that...
            </p>
          </div>
        </div>
        <!-- <div class="col-lg-4 col-md-6">
          <div class="card text-center p-4 mb-2">
            <i class="fa-solid fa-sign-hanging fa-3x"></i>
            <h4>Digital Signage</h4>
            <p class="p-2">
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam
              voluptatum, voluptate, quibusdam, quia voluptas quod quos
              exercitationem quae voluptatibus doloribus quidem. Quisquam
            </p>
          </div>
        </div> -->
        <div class="col-lg-4 col-md-6">
          <div class="card text-center p-4 mb-2 crd">
            <i class="fa-solid fa-database fa-3x"></i>
            <h4>Datacenter Support</h4>
            <p class="p-2">
              <b>Datacenters</b> are the foundation of many modern businesses, providing the infrastructure and resources necessary to save, process, and dispense data. They produce an off-premises location to secure and back up your business's data.
            </p>
          </div>
        </div>
        <div class="col-lg-4 col-md-6">
          <div class="card text-center p-4 mb-2 crd">
            <i class="fa-solid fa-sign-hanging fa-3x"></i>
            <h4>Digital Signage</h4>
            <p class="p-2">
              <b>Digital Signage</b> has grown rapidly over the last two decades well beyond just a flashy trend for big businesses in the realm of marketing and advertising, and the general dissemination of information. Now it has become the expected strategy.
            </p>
          </div>
        </div>
        <div class="col-lg-4 col-md-6">
          <div class="card text-center p-4 mb-2 crd">
            <i class="fa-solid fa-headset fa-3x"></i>
            <h4>General Support</h4>
            <p class="p-2">
              <b>General Support</b> is a crucial element to every modern business; providing essential support to businesses of all shapes and sizes. The focal point of General Support is to... 
            </p>
          </div>
        </div>
        <div class="col-lg-4 col-md-6">
          <div class="card text-center p-4 mb-2 crd">
            <i class="fa-solid fa-server fa-3x"></i>
            <h4>Network Support</h4>
            <p class="p-2">
              <b>Network Support</b> includes making sure all networking hardware, software, and other related dependencies are both up to date and functioning properly. Monitoring the network for potential problems...
            </p>
          </div>
              </div>
      <div class="col-lg-4 col-md-6">
        <div class="card text-center p-4 mb-2 crd">
          <i class="fa-solid fa-bars fa-3x"></i>
          <h4>Additional Services</h4>
          <p class="p-2">
            <br/> 
            <br/> 
            <br/> 
            <br/> 
            <br/> 
          </p>
        </div>
      </div>
        </div>
    </div>
  </section>
  <!-- SERVICES SECTION CLOSE -->

  


  </body>
</html>

推荐答案

Bootstrap为您提供了一个可爱的stretched-link级解决方案.你只需要在你的卡片上添加一个这个类的链接,卡片就会突然变得可点击.

<div class="col-lg-4 col-md-6">
  <div class="card text-center p-4 mb-2 crd">
    <i class="fa-solid fa-camera-cctv fa-3x"></i>
    <h4>CCTV Services</h4>
    <p class="p-2">
      <b>CCTV Services</b> are an essential component
          of any business. CCTV provides real-time
          monitoring of multiple locations; the security
          they supply is indispensable, allowing
          businesses to have peace of mind knowing that...
    </p>
    <a href="/about.html" class="stretched-link"></a>
  </div>
</div>

来源:https://getbootstrap.com/docs/4.4/utilities/stretched-link/

Html相关问答推荐

如何在两个弹性项目之间添加边框?

如何才能完成这个背景按钮

将多个内联元素置于中心,而无需访问父级上的CSS

CSS复选框并排

在浮动元素旁边垂直居中

如何删除在小屏幕上单击按钮时出现的蓝色方块?

连续的相同 colored颜色 单元格应位于同一列、网格框中

这<;td&>如何溢出<;表>;?

未在抖动中播放的HTML音频||文本正在工作其他标记正在播放,但音频未播放

我希望创建一个对角手风琴与不同的内容(文本和图像)在其正常状态和其他元素悬停

错误时交换表单,成功时使用HTMX重定向

如何 Select 表格';TMS Web Core中的body html元素?

如何在Go模板中传入途中创建的 map

jquery向单词中的一组字母添加跨度

复制两个

会产生一个空行;复制

元素不会

理解图像与其内容框之间的关系

如何垂直平移一个元素,使其新位置位于另外两个元素之间?

我如何使用 CSS nth-child(odd) nth-child(even) 来对齐 CSS 网格中的列?

让 Iframe 覆盖整个页面

具有淡入/淡出效果的 CSS 选框