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(),
/** iphone */
'@media screen and (-webkit-min-device-pixel-ratio: 2)': {
backgroundColor: 'blue'
}
}
},
media({maxWidth: , minWidth: }, fontSize()),
media({minWidth: }, fontSize()),
media({maxWidth: }, fontSize())
); ReactDOM.render(
<button className={className}>
Hello Typestyle
</button>,
document.getElementById('root')
);

[TypeStyle] Style CSS pseudo-classes using TypeStyle with $nest的更多相关文章

  1. [TypeStyle] Style CSS pseudo elements with TypeStyle

    Just like pseudo-classes, pseudo-elements are added to selectors but instead of describing a special ...

  2. CSS pseudo classes All In One

    CSS pseudo classes All In One CSS 伪类 https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes ...

  3. [TypeStyle] Compose CSS classes using TypeStyle

    We will demonstrate composing classes using the utility classes function. classes is also what we re ...

  4. [TypeStyle] Generate static css + html files using TypeStyle

    You can easily use TypeStyle to build static html files with encapsulated CSS. You can use this patt ...

  5. 【CSS】Intermediate2:Pseudo Classes

    1.specify a state or relation to the selector selector:pseudo_class { property: value; } 2.Link 3.Dy ...

  6. Node聊天程序实例05:index.html和style.css

    作者:vousiu 出处:http://www.cnblogs.com/vousiu 本实例参考自Mike Cantelon等人的<Node.js in Action>一书. index. ...

  7. 可否控制<link type=text/css rel=stylesheet href=style.css>

    本篇文章主要介绍了"可否控制<link type=text/css rel=stylesheet href=style.css> ", 主要涉及到可否控制<lin ...

  8. WordPress主题开发:style.css主题信息标记

    在最简单的情况下,一个WordPress主题由两个文件构成: index.php ------------------主模版 style.css -------------------主样式表 而且s ...

  9. 跨平台移动开发 Xuijs超轻量级的框架Style CSS属性用法

    PhoneGap里面推荐使用的超轻量级的框架 Style CSS属性用法 设置css属性:setstyle 通过ID设置css属性 x$('#top1').setStyle('color', '#DB ...

随机推荐

  1. 【Codeforces Round #457 (Div. 2) C】Jamie and Interesting Graph

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 找比n-1大的最小的素数x 1-2,2-3..(n-2)-(n-1)长度都为1 然后(n-1)-n长度为(x-(n-2)) 然后其他 ...

  2. 关于结构体COORD介绍

    COORD是windows API中定义的一种结构,表示一个字符在控制台屏幕上的坐标.其定义为: typedef struct _COORD { SHORT X; // horizontal coor ...

  3. 24.Node.js Stream(流)

    转自:http://www.runoob.com/nodejs/nodejs-stream.html Stream 是一个抽象接口,Node 中有很多对象实现了这个接口.例如,对http 服务器发起请 ...

  4. JS 实现图片模态框,幻灯片,跑马灯功能

    网站中常用的幻灯片和模态框,使用 HTML.JavaScript 与 CSS 来创建 Lightbox,类似相册预览功能.可以运用到视频网站,商城,相册上去 参考了菜鸟教程,有兴趣自己去看 HTML/ ...

  5. 关于Webpack详述系列文章 (第四篇)

    1. webpack基本概念 Entry:入口,Webpack 执行构建的第一步将从 Entry 开始,可抽象成输入.Module:模块,在 Webpack 里一切皆模块,一个模块对应着一个文件.We ...

  6. Python数据类型中的字符串类型

    1.换行字符:\n print ('I love python.\nAnd you?') 2.转义字符(\):\\ print ('\\\n\\') 3.制表字符(对齐表格的各列):\t print ...

  7. jsp中标签id和name的区别(转)

    name原来是为了标识之用,但是现在根据规范,都建议用id来标识元素. 但是name在以下用途是不能替代的:1. 表单(form)的控件名,提交的数据都用控件的name而不是id来控制.因为有许多na ...

  8. 洛谷 P2374 搬运工

    P2374 搬运工 题目背景 陈老师喜欢网购书籍,经常一次购它个百八十本,然后拿来倒卖牟取暴利.(ps:描述要看懂) 题目描述 前些天,高一的新同学来了,他便像往常一样兜售他的书,经过一番口舌,同学们 ...

  9. MDaemon and Apache2

    MDaemon and Apache2 邮件服务器列表 http://down.chinaz.com/class/93_1.htm MDaemon11.03中文破解补丁 http://download ...

  10. 跨域请求发送不了cookie问题: AJAX跨域请求JS配置和服务器端配置

    1.ajax是同步方式 $.ajax({ type: "post", url:url, async:false, data:datatosend, dataType:"j ...