[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(),
/** 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的更多相关文章
- [TypeStyle] Style CSS pseudo elements with TypeStyle
Just like pseudo-classes, pseudo-elements are added to selectors but instead of describing a special ...
- CSS pseudo classes All In One
CSS pseudo classes All In One CSS 伪类 https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes ...
- [TypeStyle] Compose CSS classes using TypeStyle
We will demonstrate composing classes using the utility classes function. classes is also what we re ...
- [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 ...
- 【CSS】Intermediate2:Pseudo Classes
1.specify a state or relation to the selector selector:pseudo_class { property: value; } 2.Link 3.Dy ...
- Node聊天程序实例05:index.html和style.css
作者:vousiu 出处:http://www.cnblogs.com/vousiu 本实例参考自Mike Cantelon等人的<Node.js in Action>一书. index. ...
- 可否控制<link type=text/css rel=stylesheet href=style.css>
本篇文章主要介绍了"可否控制<link type=text/css rel=stylesheet href=style.css> ", 主要涉及到可否控制<lin ...
- WordPress主题开发:style.css主题信息标记
在最简单的情况下,一个WordPress主题由两个文件构成: index.php ------------------主模版 style.css -------------------主样式表 而且s ...
- 跨平台移动开发 Xuijs超轻量级的框架Style CSS属性用法
PhoneGap里面推荐使用的超轻量级的框架 Style CSS属性用法 设置css属性:setstyle 通过ID设置css属性 x$('#top1').setStyle('color', '#DB ...
随机推荐
- deep-in-es6(三)
模板字符串:反撇号(`)包起来的内容. eg: var str = `assassin`; console.log(str); 模板占位符:${};可达到数据的渲染,在占位符中可以是表达式,运算符,函 ...
- Activemq开启JMX及问题排查
0.服务端开启JMX服务 一.修改${ ActiveMQ_HOME} /conf/activemq.xml文件 在<broker>标签中添加如下属性:useJMX="true&q ...
- 如何优雅的写UI——(4)选项卡美化
现在做出来的选项卡实在太丑的,咱们怎么把他弄得好看一点呢 tabctrl是可以添加icon图标的,那派生与tabctrl的mfctabctrl肯定也能添加图标,他们两个添加图标的原理一样,但是还是有点 ...
- FZU 1921 栀子花开
栀子花开 Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 19216 ...
- PatentTips - Control register access virtualization performance improvement
BACKGROUND OF THE INVENTION A conventional virtual-machine monitor (VMM) typically runs on a compute ...
- TCP/IP图解学习总结(二)
注意:这里的第n层是依照OSI协议来的 I 网桥--2层交换机.数据链路层面上链接两个网络的设备.它可以识别数据链路层中的数据帧. II 路由器-3层交换机.网络层面上连接两个网络,并对分组报文 ...
- 【翻译自mos文章】OGG的集成捕捉模式支持Oracle database标准版么?
OGG的集成捕捉模式支持Oracle database标准版么? 来源于: Does OGG 11.2.1 Integrated Capture Work with Oracle Database S ...
- 编程算法 - 水洼的数量 代码(C)
水洼的数量 代码(C) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 有一个大小为N*M的园子, 雨后起了积水. 八连通的积水被觉得是连接在一起的. 请求 ...
- centos6.*yum源更新
[1] 首先备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak [2]编辑vi /etc/yu ...
- React项目编译node内存溢出
坑爹的node 内存溢出 react开发项目 安装一个插件依赖 ,然后就报错了 报错如下(自己的没有截图出来 这是从别人的截图---报错基本差不多) 之前因为项目大而且旧的原因 使用 过 ...