【发布时间】:2021-04-04 10:15:54
【问题描述】:
我的 create-react-app 部署在 github 页面上时遇到问题。
在第一张图片中,它是我在 github 页面上部署的应用程序。图片应该位于页面中间。
第二张图片显示了在我的本地主机上使用 npm start 运行时的样子。
这是代码,如果有人可以帮助我弄清楚如何使图像在部署中居中,那将是非常感谢:
在我的 About.js 中:
import React from 'react';
import me from '../../photos/portraits/portraits8.jpg';
import './About.css';
const About = () => {
return(
<div>
<figure className="figure center">
<img src={me} alt="" className="about-img"/>
<figcaption className="figcaption bg-color">Hi, my name is Thomas Nguyen, and I’m a freelance photographer based in Morgan Hill, CA. My main focus is automotive photography as well as portrait photography. I'm also a Software Engineer, and this whole website was built with React, Javascript, CSS, and HTML!</figcaption>
</figure>
</div>
);
}
export default About;
在我的 About.css 中:
.about-img{
/*max-height: 500px;*/
max-height: 400px;
height: auto\9;
width: auto;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
.figure {
display: table;
margin: 0;
}
.figcaption {
display: table-caption;
caption-side: bottom;
padding: 10px;
}
.bg-color{
background-color: rgba(78, 100, 124, .1);
}
【问题讨论】:
标签: html css reactjs github github-pages