css在兼容模式下无法引用_如何在CSS中使用深色模式
css在兼容模式下无法引用
by Frank Lämmer
由FrankLämmer
如何在CSS中使用深色模式 (How to get dark mode working with CSS)
I have been playing around with MacOS Mojave’s dark mode lately. It’s not 100% pleasing to my eyes, yet. But it’s especially useful when nerding out at night time with little ambient light.
最近,我一直在玩MacOS Mojave的黑暗模式。 但是,这还不是100%令我满意的。 但是,当夜间在几乎没有环境光的情况下呆着时,它特别有用。
Dark mode is a design trend. Many reading applications (Medium App, Twitter …) have it already. It’s not only about just inverting all colors, but it’s also about art direction.
暗模式是一种设计趋势。 许多阅读应用程序(Medium App,Twitter…)已经拥有它。 这不仅涉及到反转所有颜色,还涉及艺术指导。
并非所有事物都是黑暗的(还) (Not everything is dark (yet))
One thing that can be a bit shocking when working in dark mode is the flash of light when opening a document with a big white background. This post explores how to deal with dark mode on the web and styling dark mode with CSS.
在黑暗模式下工作时,可能会有些震惊的一件事是打开带有大白背景的文档时的闪光灯。 这篇文章探讨了如何处理Web上的暗模式以及如何使用CSS设置暗模式。
处理暗模式用户设置 (Dealing with dark mode user settings)
So wouldn’t it be nice if documents and websites would respect the current surrounding theme?
那么,如果文档和网站尊重当前的周围主题,那不是很好吗?
自动颜色转换? (Automatic color conversion?)
At least Safari and Firefox already have a “Reader mode” with support for light text on a dark background. Here, the <article> context gets rendered using custom styles for best readability and removing clutter, and there is a setting for inverting colors. Extending on that, browsers might invert websites automatically with smart styles. Sounds scary! But at least Apple Mail is doing so already. It even inverts colors for some HTML mail.
至少Safari和Firefox已经具有“阅读器模式”,并支持深色背景上的浅色文本。 在这里,<article>上下文使用自定义样式进行呈现,以实现最佳的可读性并消除混乱,并且存在用于反转颜色的设置。 除此之外,浏览器可能会自动以智能样式反转网站。 听起来吓人! 但是至少Apple Mail已经这样做了。 它甚至可以反转某些HTML邮件的颜色。
Smart-inverting colors might or might not be a solution. What else?
智能反转颜色可能是解决方案,也可能不是解决方案。 还有什么?
媒体查询抢救! (Media query to the rescue!)
I am not alone. Dark mode for CSS is currently (August 2018) being discussed in “CSS Working Group Editor Drafts”. The idea is to make that available as a media query. Something has already landed in Safari (private), see also here.
我并不孤单。 CSS的深色模式目前(2018年8月) 正在 “ CSS Working Group Editor Drafts”中讨论 。 这个想法是使它作为媒体查询可用。 某些东西已经登陆Safari( 私有 ),请参见此处 。
So in theory you can do this:
因此,理论上您可以执行以下操作:
@media (prefers-color-scheme: dark) { color: white; background: black}
Let’s wait until all browsers are ready. I think there is some way to go for standardization. The OS makers might need to agree on something as well.
让我们等到所有浏览器准备就绪。 我认为有一些方法可以标准化。 操作系统制造商可能还需要就某些事情达成共识。
倒不暗模式 (Inverted is not dark mode)
Did you know: There already is a media feature for “inverted-colors” in Media Queries Level 4. That’s not the same as dark mode. A kind of “dark mode” has been around for a while. Windows has also High Contrast mode. There are many different takes on that.
您知道吗:Media Queries Level 4中已经具有“反色”的媒体功能。这与暗模式不同。 一种“黑暗模式”已经存在了一段时间。 Windows还具有“ 高对比度”模式。 有很多不同的看法。
Nevertheless, it would be really cool if website authors could decide if and how to deal with it when a user with enabled “dark mode” visited their site. So you, as the designer, have full control over how your website will look in “lights off mode”. Much more work for you? No, it’s easy. Read on.
但是,如果启用了“暗模式”的用户访问他们的网站时,网站作者可以决定是否以及如何处理它,那真的很酷。 因此,作为设计师,您可以完全控制您的网站在“熄灯模式”下的外观。 还有更多工作要做吗? 不,很简单。 继续阅读。
隐身模式不是黑暗模式 (Incognito is not dark mode)
When opening an incognito window for private browsing, many browsers will present a dark browser chrome to highlight the difference. That’s also not dark mode, but it’s dark.
当打开隐身窗口进行私密浏览时,许多浏览器会显示深色的浏览器镶边,以突出显示差异。 那也不是暗模式,但它是暗的。
使用CSS var主题化黑暗模式 (Using CSS vars for theming dark mode)
Thanks to “CSS custom properties” (also known as “CSS Vars”), we can now more easily than ever create themes with very little CSS. The most simple invert theme:
多亏了“ CSS自定义属性”(也称为“ CSS Vars”),我们现在可以比以往更轻松地用很少CSS创建主题。 最简单的反转主题:
root: { --text-color: DarkBlue; --back-color: Azure;}
body { color: var(--text-color); background: var(--back-color)}
@media (prefers-dark-interface) { root: { --text-color: Azure; --back-color: DarkBlue; } }
Shameless plug: My (great new) CSS framework Teutonic CSS already makes use of such simple inverting:
无耻的插件:我的(全新)CSS框架Teutonic CSS已经利用了这种简单的反转:
网站更改浏览器镶边 (Websites changing browser chrome)
This article is about how a user setting can change the appearance of a website. It also works the other way around: a website can change the way the browser looks. There are some proprietary meta tags available, so far only for mobile browsers:
本文是关于用户设置如何更改网站外观的文章。 它也以另一种方式起作用:网站可以更改浏览器的外观。 有一些专有的元标记可用,到目前为止仅适用于移动浏览器:
<meta name="theme-color" content="black"><meta name="msapplication-navbutton-color" content="black"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black">
ARGH!
啊!
进一步阅读 (Further readings)
The article “OS: High Contrast versus Inverted Colors” by Adrian Roselli discusses the differences between “inverted” and “high contrast” in Windows and macOS.
Adrian Roselli的文章“ OS:高对比度与反转色 ”讨论了Windows和macOS中“反转”和“高对比度”之间的区别。
The article “How “invert brightness” can improve accessibility and help us use our devices” by Matthew Atkinson discusses how inverting colors helps with the user experience. You can also find the concept of “smart inverting” colors there.
马修·阿特金森(Matthew Atkinson)的文章“ 如何“反转亮度”如何改善可访问性并帮助我们使用设备 ”讨论了反转颜色如何帮助用户体验。 您还可以在此处找到“智能反转”颜色的概念。
摘要 (Summary)
The nice thing about standards is that you have so many to choose from.
关于标准的好处是您有很多选择。
While “night mode” is definitely a trend, different implementations are floating around. Raise your voice to make that ONE web standard. Get your CSS forward compatible so you can support that without too much hustle.
尽管“夜间模式”无疑是一种趋势,但不同的实现方式四处飘浮。 提高您的声音以建立一个网络标准。 使您CSS向前兼容,以便您无需太多麻烦就可以支持它。
翻译自: https://www.freecodecamp.org/news/how-to-get-dark-mode-working-with-css-740ad31e22e/
css在兼容模式下无法引用
相关文章:

COJ 0995 WZJ的数据结构(负五)区间操作
WZJ的数据结构(负五)难度级别:C; 运行时间限制:1000ms; 运行空间限制:262144KB; 代码长度限制:2000000B 试题描述请你设计一个数据结构,完成以下功能…

接入网易云信IM即时通讯的微信小程序聊天室
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 接入流程: 初次接触网易云通信IM服务,您可以通过以下产品介绍文档了解我们的产品功能、相关概念、业务限制: 产品简介主要功能帐号集成与登录接口及业务限制 1. 创建…

vue颜色选择器_如何制作? Vue的颜色选择器!
vue颜色选择器by ZAYDEK由ZAYDEK 如何制作? Vue的颜色选择器! (How to make a ? color picker with Vue!) 注意:颜色看起来可能比实际颜色更可爱! (Caution: colors may appear cuter than they are!) Before I get to the arti…

centos7中使用yum安装tomcat以及它的启动、停止、重启
centos7中使用yum安装tomcat 介绍 Apache Tomcat是用于提供Java应用程序的Web服务器和servlet容器。 Tomcat是Apache Software Foundation发布的Java Servlet和JavaServer Pages技术的开源实现。 本教程介绍在CentOS 7服务器上使用yum进行Tomcat 7的基本安装和一些配置。请注意…

JS 数组A有数组B的数据就删除
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 创建了两个数组,并且封装了一个函数以供调用。 var arr1 [a,b,c,d],arr2 [a,c,d,f]; this.arrayWeightRemoval(arr1,arr2); //返回结果 [b] ;// 数据去重this.arrayWeightRemoval functio…

PL/SQL Developer的调试存储过程
学会使用PL/SQL Developer的调试功能,对于编写复杂的存储过程,包,funtion...非常有帮助,所以今晚学习了一下: (1)在sp里设置断点。 (2)点击TEST. (3) Debug-->Start. …

graphql_普通英语GraphQL指南
graphqlby Luis Aguilar路易斯阿吉拉尔(Luis Aguilar) 普通英语GraphQL指南 (A Guide to GraphQL in Plain English) 您需要了解的最新流行语正在席卷API开发领域。 (All you need to know about the latest buzzword that’s taking the API development scene by storm.) TL…

第1课第4.4节_Android硬件访问服务编写HAL代码
android应用如何访问C库 - 落魄影子 - 博客频道 - CSDN.NET http://blog.csdn.net/ab198604/article/details/51249303 Android硬件访问服务框架代码编写 - 落魄影子 - 博客频道 - CSDN.NET http://blog.csdn.net/ab198604/article/details/51397586 4 编写HAL代码 源码下载方…
Android新版NDK环境配置(免Cygwin)
本菜鸟在查阅了很多文章,又是去折腾cygwin之类的,虽然可以编译出so文件,但运行项目却有很多问题。当发现最新的ndk不需要cygwin的时候,跪了(orz)。 现在进入正题。 使用工具: adt-bundle-window…

小程序获取用户的操作轨迹日志
微信小程序开发交流qq群 173683895 花费了两天时间,修改过数次,终于把这个功能封装成了一个独立的工具。 任何小程序都可在不修改原代码的情况下直接镶入使用!!! 步骤: 1. 在小程序 app.js 的平级目录…

paypal提现软件_PayPal软件工程师生命中的一天
paypal提现软件Find out what a normal day is like for a PayPal software engineer.找出PayPal软件工程师的正常日子。 Shruti Kapoor shares what she does and shows off some of the PayPal campus in San Jose, California.Shruti Kapoor分享了她的工作,并展…

关于IOS的蓝牙(转)
关于IOS的蓝牙 首先,你要了解你的目的是什么,一般的IOS蓝牙开发有以下三种目的: 1. IOS设备和IOS设备之间交互 好消息是:ios6.0可以把iPhone手机当从设备了,可以两台iPhone通过蓝牙通信传数据了,有点类似sp…

JavaSE--jdom解析之bom
参考:http://www.cnblogs.com/findumars/p/3620078.html 1 org.jdom2.input.JDOMParseException: Error on line 1: Content is not allowed in prolog. 2 13:15:55,821 [main] ERROR SajtSvrImpl:182 - 未知:org.jdom2.input.JDOMParseException: Error…

JS数组去重,JS根据数组里面的对象属性值去重
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 微信小程序开发交流qq群 173683895 js数组简单去重 var arr1 [1, 2, 3, 4, 5, 6, 3, 4, 3];function arrayUnique1(arr) {var arr1 [], obj {};for (var i 0, elem; (elem arr[i]) ! null; i) {i…

git 设置有效目录_如何有效使用Git
git 设置有效目录The code was working yesterday but today it is not该代码昨天有效,但今天却没有 The code got deleted代码被删除 A weird bug has been introduced suddenly and no-one knows how突然引入了一个奇怪的错误,没人知道如何 If you hav…

C\C++宏大全
一、标准预定义宏The standard predefined macros are specified by the relevant language standards, so they are available with all compilers that implement those standards. Older compilers may not provide all of them. Their names all start with double undersc…

POJ 3630 Phone List
题目大意:给n个字符串,问是否有一个是另一个的前缀思路:把n个字符串插到trie里,然后判断就好,注意一个长字符串覆盖另一个短字符串和短字符串匹配长字符串的区别 1 #include<iostream>2 #include<cstring>3 #include<cstdio>4 #define maxn 10000…

微信小程序地图标记点,点击标记点显示详细信息源码加效果图
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 效果图: 实现代码: <!-- <text>{{markers[id].placeName}}</text> --> <block wx:if{{isshow}}><map id"map" longitude"114.048410" latit…

如何仅使用HTML和JavaScript构建简单的URL缩短器
by Palash Bauri由Palash Bauri 如何仅使用HTML和JavaScript构建简单的URL缩短器 (How to build a simple URL shortener with just HTML and JavaScript) You might have used a URL shortener before, such as bit.ly, goo.gl. They are useful for shortening long URLs so…

hibernate中的hql查询语句list查询所有与iterate查询所有的区别
hibernate中的hql查询语句list查询所有与iterate查询所有的区别 list查询所有; 01,会立即产生一条select语句1select查询出来的所有语句都会被session管理, 保 存在缓存中 02,清空或者不清空session缓存中的数据,再次…

php解决 mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysq
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 The mysql extension is deprecated and will be removed in the future: use mysq 翻译: mysql_connect这个模块将在未来弃用,请你使用mysqli或者PDO来替代。 解决方法&#x…

Test execution order
刚开始的时候,JUnit并没有规定测试方法的调用执行顺序。方法通过映射的API返回的顺序进行调用。然 而,使用JVM顺序是不明智的,因为Java平台没有规定任何特定的顺序,事实上JDK7或多或少的返回的是随机顺序。大部分写的好的测试代码…

您需要了解有关Angular中的ng-template,ng-content,ng-container和* ngTemplateOutlet的所有信息...
It was one of those days when I was busy working on new features for my office project. All a sudden, something caught my attention:那是我忙于为Office项目开发新功能的日子之一。 突然间,一些事情引起了我的注意: While inspecting the DOM …

洛谷P2587 [ZJOI2008]泡泡堂
传送门 1368 泡泡堂 省队选拔赛 时间限制: 1 s空间限制: 128000 KB题目等级 : 大师 Master题解题目描述 Description第XXXX届NOI期间,为了加强各省选手之间的交流,组委会决定组织一场省际电子竞技大赛,每一个省的代表队由n名选手组成…

bootstrap的日期选择器 完整源码demo附效果图
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 效果图: (点击图1时钟显示图2自动隐藏图1,点击图2的日历会显示图1自动隐藏图2) 源码 <!DOCTYPE html> <html><head><meta charset&q…

redux 局部刷新_如何使用Redux Observables和刷新令牌API获取新的访问令牌
redux 局部刷新by Sachin Kumar由Sachin Kumar 如何使用Redux Observables和刷新令牌API获取新的访问令牌 (How to get a new access token using Redux observables and the refresh token API) This article is about how I handled a 401 status code on an API response. …

九宫格抽奖转盘源码分析
效果如上图所示,下面对其实现代码进行分析,看能不能破解其抽奖规则。需要引入jquery-1.8.3.min.js和images/9张图片。 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-tra…

关于使用strtok的一个小问题
今天在弄一下啊小小程序的时候。报错,出现了问题。先看代码 int main(int argc, char* argv[]) {char *filename "interface_ipset_1_1.json";char* split1 "_";char* split2 ".";char splitfile1[4][NAME_MAX];sagent_string_sp…

微信小程序发送模板消息,php发送模板消息
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 formId 在安卓系统是纯数字,在IOS系统是一串加密字符,如图: 发送模板消息(服务通知)效果图: 前端 wxml <form bindsubmit"…

使用TypeScript映射和条件类型使React组件更出色
by Deepu K Sasidharan通过Deepu K Sasidharan 使用TypeScript映射和条件类型使React组件更出色 (Make your React components great with TypeScript mapped and conditional types) You’ve probably heard about TypeScript. You may have heard someone claiming how grea…