Tailwind CSS :before pseudo class
Found the problem. The :before pseudo class won't render unless there is content, but in the case of css in js, then content needs to look like this content: '"text"',
and not content: 'text',
Related videos on Youtube
Akusas
I am a graphical designer based in Norway's oldest city Tønbserg. I currently run my own design company in which i create different design elements for customers that reach out to me. I have also started creating a few different WordPress themes that will only be available to customers of mine.
Updated on June 04, 2022Comments
-
Akusas almost 2 years
I've now been working in circles trying to understand what is happening. I'm making a design library using storybook with Tailwind. I can't seem to get the :before pseudo class to work. No matter where I place it in the styling, then it's never rendered.
An example is that I am trying to make a component which uses react-slick, and want to style the navigation:
'& .slick-dots': { bottom: -30, display: 'block', left: 4, listStyle: 'none', margin: 0, padding: 0, position: 'absolute', textAlign: 'center', width: '100%', '& li': { cursor: 'pointer', display: 'inline-block', height: 20, margin: '0 5px', padding: 0, position: 'relative', width: 20, '& button': { border: 0, background: 'transparent', display: 'block', height: 20, width: 20, outline: 'none', lineHeight: 0, fontSize: 0, color: 'transparent', padding: 5, cursor: 'pointer', '&:before': { position: 'absolute', top: 0, left: 0, content: '', width: 20, height: 20, fontFamily: 'sans-serif', fontSize: 20, lineHeight: 20, textAlign: 'center', color: '#000000', opacity: 0.75, display: 'inline-block', }, }, }, },
-
s0xzwasd almost 4 yearsCan you show code snipper or sandbox (jsfiddle, codepen)?
-
Akusas almost 4 yearsIt's ok, found the problem. The :before pseudo class won't render unless there is content, but in the case of css in js, then content needs to look like this
content: '"text"',
and notcontent: 'text',
-