[TypeStyle] Use fallback values in TypeStyle for better browser support

本文介绍如何通过TypeStyle使用浏览器前缀和回退值来增强CSS兼容性,并展示了最佳实践,包括变量维护等方面。

You can increase the browser support of your CSS using fallback values and vendor prefixes. This lesson covers using vendor prefixes and fallback values (single prop multiple values) with TypeStyle. It also shows best practices for maintaining variables in the presence of vendor prefixing.

 

import { style, cssRaw, types } from "typestyle";
import * as React from "react";
import * as ReactDOM from "react-dom";

cssRaw(`
    body {
        font-size: 1.5em;
        font-weight: bold;
        color: gold
    }
`);

const scroll: types.NestedCSSProperties = {
  "-webkit-overflow-scrolling": "touch",
  overflow: "auto"
};

const bg = style(scroll, {
  backgroundColor: [
    /* The fallback */
    "rgb(200, 54, 54)",
    /** Graceful upgrade */
    "rgba(200, 54, 54, 0.5)"
  ]
});

const App = () =>
  <div className={bg}>
    Hello World!
  </div>;

ReactDOM.render(<App />, document.getElementById("root"));

 

转载于:https://www.cnblogs.com/Answer1215/p/6960743.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值