css 将图像填充到列中,使其仅显示到第一页

olmpazwi  于 2023-03-20  发布在  其他
关注(0)|答案(1)|浏览(111)

使用bootstrap,我做了一个2列0间距的div,并在第二列放了一个图像。它实际上是在谈论图像的完整高度。我试着只使用css属性,如object-fit,background-size等来适应第一页,但无法做到这一点
这是我尝试过的方法:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="project.css" />
  </head>

    <title>My Lead Form</title>
  </head>
  <body>
    <script
      src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"
      integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"
      crossorigin="anonymous"
    ></script>
    <div class="">
      <div class="container-fluid">
        <div class="row align-items-center text-center">
          <div class="col-md-6 justify-content-center">Column-1</div>
          <div class="col-md-6 second-column">
           <img src="project.jpg" alt="">
          </div>
        </div>
      </div>
    </div>
  </body>
</html>
oyjwcjzk

oyjwcjzk1#

你可以瞄准第二列图像并添加100vh的高度,使图像占据视口的全部高度

.second-column img {
  height: 100vh;
  object-fit: cover;
}

相关问题