【发布时间】:2020-06-14 06:06:12
【问题描述】:
所以我正在尝试构建这样的页面:
但它看起来像这样:
我尝试使用多个div 并结合Row 和Col 来做到这一点,但它似乎一团糟。一些更改也没有任何影响。
代码:
import React from 'react';
import TextContents from '../assets/translations/TextContents';
import BlueButton from '../components/materialdesign/BlueButton';
import TeachIcon from '../assets/images/teach-class-icon.svg';
import HostIcon from '../assets/images/host-a-class-icon.svg';
import './CreateClassAndHost.css';
import { Row, Col, Container } from 'react-bootstrap';
class CreateClassAndHost extends React.Component {
render() {
const CreateAClass =
<Col className="create-tile">
<div className="create-style-title">
<img
src= { TeachIcon }
className= "create-icon"
alt="TeachIcon"
/>
<h2>{TextContents.BeATeacher}</h2>
</div>
<p>{TextContents.BeATeacherDesc}</p>
<div className="create-button">
<BlueButton textSize="13" link_href="/createaclass" text={TextContents.BeATeacherBtn} />
</div>
</Col>;
const CreateAHost =
<Col className="create-tile">
<div className="create-style-title">
<img
src= { HostIcon }
className= "create-icon"
alt="HostIcon"
/>
<h2>{TextContents.HostAClass}</h2>
</div>
<p>{TextContents.HostAClassDesc}</p>
<div className="create-button">
<BlueButton textSize="13" link_href="/createahost" text={TextContents.HostAClassBtn} />
</div>
</Col>;
return (
<Container bsPrefix="create-container">
<h1>{TextContents.CreateClassOrHostTitle}</h1>
<Row classname="create-section">
{CreateAClass}
{CreateAHost}
</Row>
</Container>
);
}
}
export default CreateClassAndHost;
CSS代码:
.create-container {
margin-top: 8%;
margin-left: auto;
margin-right: auto;
width: 60%;
}
.create-container h1 {
text-align: center;
height: 51px;
margin: auto;
font-family: Fredoka One;
font-size: 50px;
color: #333333;
width:100%;
}
.create-section {
width:100%;
}
.create-icon {
width:47px;
height:47px ;
}
.create-style-title {
}
.create-tile {
display: inline-block;
left: 12px;
top: 80px;
text-align: center;
width: 200px;
height: 250px;
background-color: #ffffff;
}
.create-tile h2 {
font-family: Source Sans Pro;
font-weight: bold;
font-size: 30px;
line-height: 0.7;
color: #333333;
letter-spacing: -0.6px;
}
.create-tile p {
font-family: Source Sans Pro;
font-size: 20px;
line-height: 1.6;
color: #616161;
width: 280px;
height: 85px;
}
.create-button {
position: relative;
left: 0px;
top: 50px;
}
知道如何使它看起来像上面提供的页面吗?
此外,任何人都可以提供有关如何正确构建布局的良好资源。我还想看看自己在一些资源上很容易展示如何对齐,..构建...
谢谢
【问题讨论】:
-
对于资源我会看 css grid developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout 或 flexbox,这是一个有趣的游戏来学习它:flexboxfroggy.com
-
如果你创建了一个沙箱,可以帮助你:) 只是之前没有使用过引导程序,所以我不确定
标签: javascript css reactjs react-bootstrap