带有 css 和 bootstrap 的平行四边形卡片

parallelogram card with css and bootsrap

如何使用 css 或 bootsrap 制作这样的卡片?

展示你的作品比搜索答案复制粘贴到这里更好。

下面的示例没有考虑响应式设计,使用 bootstrap-4.

大家可以参考一下Bootstrap

ml-3shadow等class的意思

<!DOCTYPE html>
<html lang="en">

<head>
  <!-- Required meta tags -->
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />

  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous" />

  <title>Hello, world!</title>
</head>
<style>
  .diagonal-left {
    width: 100px;
    height: 100px;
    background-color: #deadee;
    transform: skewX(30deg);
    transform-origin: top;
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .diagonal {
    width: 350px;
    height: 100px;
    background-color: #319b9e;
    transform: skewX(30deg);
    transform-origin: top;
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .diagonal>span {
    transform: skewX(-30deg);
    color: white;
  }
</style>

<body>
  <div class="ml-3 row">
    <div class="diagonal-left shadow"></div>
    <div class="diagonal shadow"><span>Title<br>123</span></div>
  </div>

  </div>

  <!-- Optional JavaScript; choose one of the two! -->

  <!-- Option 1: jQuery and Bootstrap Bundle (includes Popper) -->
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF" crossorigin="anonymous"></script>

  <!-- Option 2: Separate Popper and Bootstrap JS -->
  <!--
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js" integrity="sha384-VHvPCCyXqtD5DqJeNxl2dtTyhF78xXNXdkwX1CZeRusQfRKp+tA7hAShOK/B/fQ2" crossorigin="anonymous"></script>
    -->
</body>

</html>