首页 > 其他分享 >styled-components & CSS pseudo classes All In One

styled-components & CSS pseudo classes All In One

时间:2023-10-05 23:33:40浏览次数:32  
标签:flex const after pseudo content classes styled com CSS

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

image

https://stackoverflow.com/questions/77238243/after-element-not-working-in-my-react-component-react-3d-portfolio-project/77238418#77238418

(

标签:flex,const,after,pseudo,content,classes,styled,com,CSS
From: https://www.cnblogs.com/xgqfrms/p/17744108.html

相关文章

  • CSS 实现 table 表头固定 tbody 显示垂直滚动条并自定义滚动条样式
    一、最终效果图 二、关键代码html代码:<divclass="table_info"><tableborder="0"cellspacing="0"cellpadding="0"style="width:100%;"><thead><tr><th>项目账号</th&g......
  • WebKit Inside: CSS 样式表的匹配时机
    WebKitInside:CSS的解析介绍了CSS样式表的解析过程,这篇文章继续介绍CSS的匹配时机。无外部样式表内部样式表和行内样式表本身就在HTML里面,解析HTML标签构建DOM树时内部样式表和行内样式就会被解析完毕。因此如果HTML里面只有内部样式表和行内样式,那么当DOM树......
  • Vue在main.js全局引入scss文件,组件里使用scss变量报错问题
    问题描述在写组件样式的时候,普通样式都没问题,一碰到$变量就errorModulebuildfailed(from./node_modules/sass-loader/dist/cjs.js):color:$normal-active-color;^Undefinedvariable.╷22│color:$normal-active-color;│......
  • css小技巧
    <divid="shizijia"></div>#shizijia{margin-left:80px;background:blue;height:130px;position:relative;width:18px;}#shizijia:after{background:green;content:"";height:18px;left:-55px;posit......
  • 矩阵的乘法运算与css的3d变换(transform)
    theme:qklhk-chocolate引言:你有没好奇过,在一个使用了transform变换的元素上使用window.getComputedStyle(htmlElement)['transform']查询出来的值代表什么?为什么硬件加速要使用transform,以及为什么硬件加速会快?小科普:关于矩阵的乘法 以两个二阶齐次矩阵相乘为例 [......
  • Module build failed (from ./node_modules/css-loader/dist/cjs.js): CssSyntaxError
    问题描述在webpack的时候报错ERRORin./packages/theme-chalk/mixins/mixins.scss(./node_modules/css-loader/dist/cjs.js!./packages/theme-chalk/mixins/mixins.scss)Modulebuildfailed(from./node_modules/css-loader/dist/cjs.js):CssSyntaxError(14:8)......
  • Angular inlineCriticalCss 和内部函数 walkStyleRules 介绍
    有一个客户启用了AngularServerSideRendering,并且启用了inlineCriticalCss,后来发现在Dynatrace的hotspot里的vendor.js文件有个名叫walkStyleRules的函数,耗时比较多。如下图所示:Angular服务器端渲染(ServerSideRendering)Angular的服务器端渲染是一种技术,允许在......
  • 深航电企业评价评级系统可视化(HTML,CSS,JS)
    一.项目背景深航电企业评价评级系统EERS是一款企业绩效评价平台,旨在为企业提供科学、全面、精准的绩效评价服务,帮助企业发现问题、改进管理,提高整体绩效。EERS评级系统借助大数据、云计算、人工智能等现代技术手段,将企业绩效数据进行多维度、系统化、动态化分析,为企业提供可视化......
  • WebKit Inside: CSS 样式表的解析
    CSS全称为层叠样式表(Cascading Style Sheet),用来定义HTML文件最终显示的外观。为了理解CSS的加载与解析,需要对CSS样式表的组成,尤其是CSSSelector有所了解,相关部分可以参看这里。HTML文件里面引入CSS样式表有3种方式:1外部样式表2内部样式表3行内样式不......
  • CSS关系选择器
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>Document</title>......