【发布时间】:2020-10-29 01:40:41
【问题描述】:
我想更新我的标题以使用弹性框。我想要一个图标,然后是左侧的 4 个 A 标签链接,然后是右侧的两个标签,其中包含一个图像。当我在任何项目上设置 align-self 时,它会上下移动,而不是像我预期的那样左右移动。请帮忙。
function renderSections() {
return sections.map((section, i) => {
let sect = section.toString();
if (i !== 0) {
return (
<p className="HeadLink" onClick={() => scrollToSection(sect)}>
{section}
</p>
);
} else {
return (
<p className="HeadLink" key={section}>
{section}
</p>
);
}
});
}
return (
<HeadCon id="HeadCon">
<img alt="logo" className="logo" src={logo} />
{renderSections()}
<a className="project-icon-link" href="/#/weather">
<img alt="Gove Weather" className="project__icon" src={weather} />
</a>
<a className="project-icon-link" href="/#/SuperHeroSmackDown">
<img
alt="Super Hero Smack Down"
className="project__icon"
src={superHSD}
/>
</a>
</HeadCon>
);
export const HeadCon = styled.div`
* {
box-sizing: border-box;
}
display: flex;
flex-direction: row;
width: 100%;
align-items: center;
position: -webkit-sticky;
position: sticky;
text-align: left;
height: 70px;
top: 0;
right: 0;
left: 0;
/* border: 2px solid orange; */
background: black;
.project-icon-link {
align-self: flex-end;
}
【问题讨论】:
-
你试过 justify-self 吗?
-
是的,我有,在 Firefox 开发工具中,它说 justify-self 对这个项目没有影响,因为它不是一个网格项目......
标签: reactjs flexbox styled-components