我正试图建立一个登录页面,被分成两列(目前尚未完成).每一列都包含一个图像和文本.当窗口是全尺寸时,它显示得非常好,但如果窗口小于这个大小,页面就不再显示为两列.我希望页面显示为两列而不考虑窗口大小,并使图像与窗口一起缩小和增长,以便它们保持成比例.我try 过使用max-Height和max-Width,但这两种方法都没有解决这个问题.但是,当我删除图像或try 使用完全正方形的图像时,此问题不会发生,并且列会随着窗口大小的调整正确地调整自身的大小.请看下面的截图和代码.

Full Size Window view

Medium Window view

Smallest Window view

.center-img-half {
  display: flex;
  align-items: center;
  justify-content: center;
  scale: 50%;
}

.center-div {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  text-align: center;
}

.black-white-button {
  background-color: black;
  color: white;
  border-radius: 10px;
  font-family: 'Cantata One', serif;
  padding: 10px;
}

.wrapper {
  background-color: white;
}

.login-column1 {
  background-color: lightgray;
  display: flex;
  flex-direction: column;
  flex-basis: 100%;
  flex: 1;
  height: 100vh;
}

.login-column2 {
  background-color: white;
  display: flex;
  flex-direction: column;
  flex-basis: 100%;
  flex: 1;
  height: 100vh;
}

.row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  width: 100%;
}
<div class="wrapper">
  <div class="row">
    <div class="login-column1">
      <div class="center-img-half">
        <img src="https://via.placeholder.com/300x300" />
      </div>
      <div class="center-div">
        <h2>Log in to your chess </h2>
      </div>
      <div class="center-div">
        <h4>Log in with your email and password to access your account.</h4>
      </div>
    </div>
    <div class="login-column2">
      <div class="center-img-half">
        <img src="https://via.placeholder.com/600x200" alt="Chess Pal Logo" />
      </div>
      <div class="center-div">
        <h2> Log in to your account </h2>
      </div>
      <div class="center-div">
        <Button class="black-white-button">Log In</Button>
      </div>
    </div>
  </div>
</div>

推荐答案

这是想要的结果吗?

body{ /* This is just my guess, i don't know what your body should be styled as */
    height: 100vh;
    padding: 0;
    margin: 0;
}

.center-img-half {
    display: flex;
    align-items: center;
    justify-content: center;
    scale: 50%;
  }
  
  .center-div {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    text-align: center;
  }
  
  .black-white-button {
    background-color: black;
    color: white;
    border-radius: 10px;
    font-family: 'Cantata One', serif;
    padding: 10px;
  }
  
  .wrapper {
    background-color: white;
    height: 100%;
  }

  .login-column1,
  .login-column2 {
    display: flex;
    flex-direction: column;
    flex: 1 0 0;
    min-width: 0;
  }

  .row {
    display: flex;
    height: 100%;
    justify-content: space-between;
  }
  
  .login-column1 {
    background-color: lightgray;
  }
  
  .login-column2 {
    background-color: white;
  }
<!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 rel="stylesheet" href="styles.css">
    <title>Document</title>
</head>
<body>
<div class="wrapper">
    <div class="row">
        <div class="login-column1">
        <div class="center-img-half">
            <img src="https://via.placeholder.com/300x300" />
        </div>
        <div class="center-div">
            <h2>Log in to your chess </h2>
        </div>
        <div class="center-div">
            <h4>Log in with your email and password to access your account.</h4>
        </div>
        </div>
        <div class="login-column2">
        <div class="center-img-half">
            <img src="https://via.placeholder.com/600x200" alt="Chess Pal Logo" />
        </div>
        <div class="center-div">
            <h2> Log in to your account </h2>
        </div>
        <div class="center-div">
            <Button class="black-white-button">Log In</Button>
        </div>
        </div>
    </div>
</div>
</body>
</html>

重点放在以下 Select 器上:

  .login-column1,
  .login-column2 {
    display: flex;
    flex-direction: column;
    flex: 1 0 0;
    min-width: 0;
  }

  .row {
    display: flex;
    height: 100%;
    justify-content: space-between;
  }

Html相关问答推荐

纯CSS语音气泡与半透明背景和边框

删除第一个列表项上的左边框

Chrome和Safari浏览器中的CSS3动画不同

Angular Project中的星级 Select

创建一个带有div和径向渐变的全宽半圆

在css中,如何在英雄版块的标题后面做一个粘性的导航栏?

你将如何为手机制作导航栏

如何用js和CSS在两点之间画一条线

Tailwind:父母动态适应子元素的身高

调整屏幕大小时标题在图像下方重叠 - HTML

透明渐变凹矩形

获取 div 中每个元素的 href 并使用它

Mediawiki css/html 信息框创建空白行

如何将 2 种不同的 colored颜色 应用于 css 中的复选框?

需要禁用聚焦输入的工具提示(jquery)

悬停一个 div 时更改所有其他 div 上的字体 colored颜色

有没有办法使用 CSS border-radius 创建 HTML 视频标签的三角形显示?

如何创建带有偏移边框线的双色边框?

我如何使用 HTML 和 CSS 在我的下拉菜单中获得这种类型的样式

当我希望它只横向滚动时,可滚动菜单也会上下移动