【发布时间】:2020-10-23 11:01:06
【问题描述】:
我正在尝试将图像与标题对齐,但我无法做到这一点。我添加了颜色背景只是为了查看每个元素的位置。
下面是代码:
<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>;
和css:
.create-container {
margin-top: 3rem;
margin-bottom: 5rem;
margin-left: auto;
margin-right: auto;
width: 40%;
}
.create-container h2 {
text-align: center;
height: 51px;
font-family: Fredoka One;
font-size: 50px;
color: #333333;
background-color: red;
}
.create-section {
width:100%;
}
.create-icon {
width:47px;
height:47px ;
}
.create-style-title {
background-color: blue;
}
.create-tile {
display: inline-block;
left: 12px;
top: 80px;
text-align: left;
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;
}
但它看起来像这样:
而不是这个:
有什么想法吗?我尝试了过去从 stackoverflow 获得的建议,但它仍然无法正常工作。 不用担心蓝/红bkg,它真的只是支持放置元素
【问题讨论】:
标签: css reactjs react-bootstrap