javascript - 如何让 Bootstrap 卡停留在reactjs中的屏幕中间

标签 javascript css reactjs twitter-bootstrap web

我试图让我的卡片保持在屏幕中间,但它不起作用。我使用了 align-items 和 justify-content。 我看过不同的网站。

//登录.js

import React, { Component } from 'react';
import './App.css';

class Login extends Component {
  render() {
    return (
      <div className="App">
        <div className="card cardalign w-50">
          <div className="card-body">
          <img className="logo" src="https://cdn.macrumors.com/article-new/2018/05/apple-music-note-800x420.jpg"/>
                <h1 className="signintext">MusicFlo Signin</h1>
                <form className="logininputs">
                <input className="emailinput" placeholder="Email"/>
                <input className="passwordinput" placeholder="Password"/>
                <button className="btn btn-primary btn-md m-2">Log In</button>
            </form>
          </div>
        </div>
      </div>
    );
  }
}

export default Login;

还有下面的css

//App.css

.App {
  text-align: center;
}

.App-logo {
  animation: App-logo-spin infinite 20s linear;
  height: 40vmin;
  pointer-events: none;
}

.App-header {
  background-color: #282c34;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: calc(10px + 2vmin);
  color: white;
}

.App-link {
  color: #61dafb;
}

.logo {
  height:120px;
  width: 220px;
  border-radius: 50%;
  margin-top: 150px
}

.signintext {
  margin-top: 50px;
  font-style: italic
}

.logininputs {
  display:flex;
  flex-direction: column;
  align-items: center
}

.emailinput {
  width: 30vw;
  height: 5vh;
  margin-bottom: 10px;
  border: solid 2px indigo
}

.passwordinput {
  width: 30vw;
  height: 5vh;
  border: solid 2px indigo
}

.card {
  align-items: center;
  justify-content: center;
  background-color: lightgrey;
  border: 5px solid black

}
@keyframes App-logo-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

我看了reactjs的纪录片。它仍然没有显示在中心。请看图片。谢谢

enter image description here

任何信息都会很棒

最佳答案

将此添加到 App css 类

margin-left: auto;
margin-right: auto;

Center div

关于javascript - 如何让 Bootstrap 卡停留在reactjs中的屏幕中间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55288908/

相关文章:

javascript - 水平附加图像

智能手机、平板电脑等的 CSS 开发

javascript - 设置后React状态为空

javascript - 将文件写入设备

javascript - 数组中的数组,AngularJS,ng-repeat

javascript - 我如何切换声明的变量 slideIndex 以将其放入对象中?

javascript - Kendo网格导出日期格式不正确

javascript - 别名化其他域上的DOM函数(Document.Write)和脚本

php - CSS 背景仍在重复

javascript - ReactJS 如何知道 props 是否已经存在?