[英]How can i get my two icons side-by-side in my footer in React app?
I'm building a react portfolio.我正在建立一个反应组合。 I'm struggling to style my footer.我正在努力设计我的页脚。 I only want to include icons of Github and LinkedIn on it.我只想在上面包含 Github 和 LinkedIn 的图标。 I want to have them side-by-side, and at the bottom of the screen once you reach the end of the page.我想让它们并排放置,并且在您到达页面末尾时位于屏幕底部。 Currently, the two icons are stacked vertically at the bottom, in the middle of the page, with a lot of space between the two rows.目前,这两个图标垂直堆叠在底部,在页面中间,两行之间有很大的空间。 I have react-bootstrap implemented.我已经实施了反应引导程序。
Here's my footer component:这是我的页脚组件:
import {AiFillGithub} from "react-icons/ai";
import {AiFillLinkedin} from "react-icons/ai";
function Footer() {
return (
<footer className="justify-content-center font-link">
<div className="primary flex-row center">
<ul className="flex-row">
<li className="links">
<a href="https://github.com/PhuongHoang68"
target="_blank"
rel="noreferrer"
>
<h3 className="icon"><AiFillGithub size="3rem"/></h3>
</a>
</li>
<li className="links">
<a href="https://www.linkedin.com/in/phuong-hoang-a0b4901a5/"
target="_blank"
rel="noreferrer"
>
<h3 className="icon"><AiFillLinkedin size="3rem"/></h3>
</a>
</li>
</ul>
</div>
</footer>
)
}
export default Footer;
Here's my related css:这是我的相关 css:
.App {
font-family: sans-serif;
min-height: 100vh;
display: flex;
flex-direction: column;
}
footer {
background-color: gray;
text-align: center;
margin-top: auto;
padding: 8px;
}
html,
body {
min-height: 100%;
}
body {
margin: 0;
padding: 0;
font-weight: 600;
line-height: 1.5;
font-size: 18px;
background: var(--dark);
color: var(--light);
font-family: 'Poiret One', cursive;
}
Here's my app.js (only the parts related to the footer):这是我的 app.js(只有与页脚相关的部分):
import Footer from './components/Footer';
<div className="app">
<Footer />
</div>
export default App;
I have tried many methods and nothing is working.我尝试了很多方法,但没有任何效果。 i have included the above code that is above.我已经包含了上面的代码。 Please help me, I really appreciate it请帮助我,我真的很感激
It seems that ul
has class flex-row
but does not have its display
set as flex
, therefore the flex behavior is not enabled.似乎ul
有 class flex-row
但没有将其display
设置为flex
,因此未启用 flex 行为。
For a Bootstrap solution to fix this, perhaps try add d-flex
, justify-content-center
, align-items-center
and (if the default list style also needed to be removed) list-unstyled
to the className
of ul
.对于解决此问题的 Bootstrap 解决方案,也许可以尝试将d-flex
、 justify-content-center
、 align-items-center
和(如果还需要删除默认列表样式) list-unstyled
到className
的ul
名。
Simplified demo on: stackblitz简化演示: stackblitz
<ul className="d-flex flex-row justify-content-center align-items-center list-unstyled">
...
</ul>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.