reactjs - @aws-amplify/ui-react 登录按钮位置自定义
问题描述
我@aws-amplify/ui-react
在我的项目中使用。我只调用了AmplifySignIn
组件,没有任何 SignUp。我从Codesandbox导出了一个示例项目并开始进行一些自定义。这是我的登录代码。
const SignIn = () => (
<AmplifyAuthenticator style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
backgroundImage: `url(${backgroundImage})`,
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
}}>
<AmplifySignIn hideSignUp={true} slot="sign-in" headerText="" usernameAlias="email" >
<div slot="federated-buttons">
</div>
</AmplifySignIn>
我在我的项目中使用了相同的代码,并尝试使用与示例项目相同的 UI 来模仿。但是示例项目和我的真实项目之间的登录按钮大小不同。
示例项目 UI:
显示登录按钮的相同代码如下:
即使我使用相同的 CSS,为什么登录在我的视图中完全居中?
另外,我尝试查看元素在浏览器中的呈现方式。在示例项目中,我看到添加了一个空跨度的 slot(secondary-footer-content),如下所示
但是在我的项目中,我看到另一个 div 添加了 class full-width-footer-content
。
如何解决此问题以显示我的登录按钮就像示例项目一样?我不擅长 CSS。但尝试模仿与项目相同的项目。
先感谢您。
解决方案
解决此问题的最快方法是覆盖 aws-amplifyui 库生成的 CSS。
在您的 styles.css 中,添加以下代码:
.full-width-footer-content {
width: 153px !important;
margin-left: auto !important;
}
推荐阅读
- sql - 使用 oracle 的精确字符串匹配包含多个值
- project-reactor - 将 Flux 拆分为 Mono 头和 Flux 尾
- java - Google Cloud Platform - Cloud SQL 上的 MySQL 的 Spring Boot 应用程序连接问题
- npm - 相互依赖的 NPM 包:peerDependency 不针对“主机”包解析
- c++ - 模板函数在哪里实例化?
- postman - POST 操作中的多个实体
- java - Springboot 映射和 DTO
- python - 在单词列表中查找复合词 - Python
- javascript - 表格标题和正文宽度未对齐
- python-3.x - 将列表重新制作成集合时如何计算所有已删除的元素(Python)