[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: , minWidth: }, fontSize()),
media({minWidth: }, fontSize()),
media({maxWidth: }, fontSize())
);
ReactDOM.render(
<div className={className}>
Hello Typestyle
</div>,
document.getElementById('root')
);
[TypeStyle] Style CSS pseudo elements with TypeStyle的更多相关文章
- [CSS3] Target HTML Elements not Explicitly set in the DOM with CSS Pseudo Elements (Blockquotes)
Pseudo elements allow us to target elements that are not explicitly set in the DOM. Using ::before : ...
- [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 p ...
- [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 ...
- 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 ...
- wordpress后台编辑如何显示定义的`style.css`样式
wordpress后台编辑如何显示定义的style.css样式 由于公司官网采用wordpress进行搭建,但是却又自己设计页面,无奈主题只能自行构建了,直接修改wordpress自带的主题进行修改. ...
- CSS pseudo classes All In One
CSS pseudo classes All In One CSS 伪类 https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes ...
随机推荐
- 韦东山ARM裸机笔记(1)
1.一个嵌入式Linux系统的软件组成:单片机大全Bootloader-->Linux驱动-->Linux APP-->Linux GUI(Android/QT) 2.驱动程序=软件 ...
- 解决Docker容器内访问宿主机MySQL数据库服务器的问题
懒得描述太多,总归是解决了问题,方法简要记录如下,虽然简要,但是完整,一来纪念处理该问题耗费的大半天时间,二来本着共享精神帮助其他遇到该问题的哥们儿,当然这个方法并不一定能解决你们的问题,但是多少能提 ...
- [Javascript] Identify the most important words in a document using tf-idf in Natural
Tf-idf, or term frequency-inverse document frequency, is a statistic that indicates how important a ...
- apache activemq Failed to bind to server socket 61616
windows环境上: 首先 nestat -ano | findstr "61616" 查看是否有进程,有的话kill掉, 若没有发现,查看windows Internet Co ...
- absolute、relative,toggle()
測试代码例如以下: <div> <div class="global">不应用样式</div> <div class="glob ...
- 控制面板项 .cpl 文件说明
控制面板项 .cpl 文件说明 appwiz.cpl 程序和功能.卸载或更改程序 bthprops.cpl 蓝牙控制面板 desk.cpl ...
- regular-第一课(正则表达式基础)
之前一直听说正则表达式,尤其是在学习java的时候,遇到了不少关于正则表达式的用法.例如一个输入框,你可以使用正则表达式限制输入的内容.当然,在android以后,正则表达式就几乎没有怎么用了.不过呢 ...
- 27.Node.js模块系统
转自:http://www.runoob.com/nodejs/nodejs-module-system.html 为了让Node.js的文件可以相互调用,Node.js提供了一个简单的模块系统. 模 ...
- 为RecyclerView添加item的点击事件
RecyclerView侧重的是布局的灵活性,虽说可以替代ListView但是连基本的点击事件都没有,这篇文章就来详细讲解如何为RecyclerView的item添加点击事件,顺便复习一下观察者模式. ...
- Vue的学习--环境配置
1. 下载vue.min.js或者使用CDN 2. 安装Vue-cli环境 我在window7 32位下使用命令行cmd进行的操作 安装之前应该使用node -v和npm -v检查一下node和n ...