zoukankan      html  css  js  c++  java
  • [TypeStyle] Style CSS pseudo-classes using TypeStyle with $nest

    TypeStyle is a very thin layer on top of CSS. In this lesson we show how to change styles based on pseudo classes e.g. :focus :hover and :active which matches very closely with what you would write with raw CSS.

    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: {
                '&:focus': {backgroundColor: 'green'},
                '&:hover': fontSize(50),
                /** iphone */
                '@media screen and (-webkit-min-device-pixel-ratio: 2)': {
                    backgroundColor: 'blue'
                }
            }
        },
        media({maxWidth: 700, minWidth: 500}, fontSize(20)),
        media({minWidth: 701}, fontSize(30)),
        media({maxWidth: 499}, fontSize(15))
    );
    
    ReactDOM.render(
        <button className={className}>
            Hello Typestyle
        </button>,
        document.getElementById('root')
    );
  • 相关阅读:
    Asp:Cookies应用指南
    asp:cookies的属性
    数据库压缩
    asp之servervariables全部显示
    sql语句操作表
    asp之FSO大全
    SQL语句
    vbscript语句
    asp之vbscript函数
    IDEA 2017web项目的创建
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6946556.html
Copyright © 2011-2022 走看看