styled-components & CSS pseudo classes All In One
styled-components & CSS pseudo classes All In One
::after
&::before
CSS 伪元素
const ListItem = styled.li`
font-size: 70px;
font-weight: bold;
cursor: pointer;
color: transparent;
-webkit-text-stroke: 1px white;
position: relative;
&::after {
content: "${(props) => props.text}";
position: absolute;
top: 0;
left: 0;
}
&:hover {
&::after {
color: rebeccapurple;
}
}
`;
demos
import React from 'react'
import styled from 'styled-components'
const data = [
"Web Development",
"Data Science",
"DevOps",
"Low Code Platforms",
"Automation",
];
const Section = styled.div`
height: 100vh;
scroll-snap-align: center;
display: flex;
justify-content: center;
`
const Container = styled.div`
width: 1400px;
display: flex;
justify-content: space-between;
`
const Left = styled.div`
flex: 1;
display: flex;
align-items: center;
`
const List = styled.ul`
list-style: none;
display: flex;
flex-direction: column;
gap: 20px;
`
const ListItem = styled.li`
font-size: 70px;
font-weight: bold;
cursor: pointer;
color: transparent;
-webkit-text-stroke: 1px white;
position: relative;
&::after {
content: "${(props) => props.text}";
position: absolute;
top: 0;
left: 0;
}
&:hover {
&::after {
color: rebeccapurple;
}
}
`;
const Right = styled.div`
flex: 1;
`
const Works = () => {
return (
<Section>
<Container>
<Left>
<List>
{data.map(item=>(
<ListItem key={item} text={item}>{item}</ListItem>
))}
</List>
</Left>
<Right></Right>
</Container>
</Section>
)
}
export default Works
refs
©xgqfrms 2012-2025
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/17744108.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2022-10-05 js 代码性能优化原理剖析与实战 All In One
2022-10-05 say goodbye to Heroku All In One
2021-10-05 TypeScript Class All In One
2021-10-05 js OOP All In One
2020-10-05 Node.js require 模块加载原理 All In One
2020-10-05 node.js module.exports & exports & module.export all in one
2016-10-05 gulp error handler