zoukankan      html  css  js  c++  java
  • [TypeStyle] Style CSS pseudo elements with TypeStyle

    Just like pseudo-classes, pseudo-elements are added to selectors but instead of describing a special state, they allow you to style certain parts of an element.

    In this lesson we show how you can insert new content into the DOM using CSS pseudo elements. We also cover using other pseudo element selectors to change default browser behaviors.

    import { style, media } from 'typestyle';
    import * as React from 'react';
    import * as ReactDOM from 'react-dom';
    
    const fontSize = (value: number | string) => {
        const valueStr = typeof value === 'string' ?
                         value :
                         value + 'px';
        return {
            fontSize: valueStr
        }
    };
    const className = style(
        {
            color: 'red',
            transition: 'font-size 0.2s',
            $nest: {
                '&::after': {
                    content: `' Type after'`
                },
                '&::selection': {
                    backgroundColor: 'black',
                    color: 'gold'
                }
            }
        },
        media({maxWidth: 700, minWidth: 500}, fontSize(20)),
        media({minWidth: 701}, fontSize(30)),
        media({maxWidth: 499}, fontSize(15))
    );
    
    ReactDOM.render(
        <div className={className}>
            Hello Typestyle
        </div>,
        document.getElementById('root')
    );
  • 相关阅读:
    【Linux 读书笔记】Linux文件的硬连接和符号连接
    Shell参数
    Shellcase语句的例子
    Shellselect
    Shell小程序一个
    SHELL起步
    接昨天的 while
    Shell循环控制
    Shellwhile循环的例子
    Shellfor语句
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6946588.html
Copyright © 2011-2022 走看看