热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

AtoZCSS快速提示:利用Color属性

ThisarticleisapartofourAtoZCSSSeries.Youcanfindotherentriestotheserieshere.Viewthefullscre

This article is a part of our AtoZ CSS Series. You can find other entries to the series here. View the full screencast and transcript for color here.

本文是我们的AtoZ CSS系列的一部分。 您可以在此处找到该系列的其他条目。 查看全部截屏和成绩单color 在这里 。

Welcome to our AtoZ CSS series! In this series I’ll be exploring different CSS values (and properties) beginning with a letter from the alphabet. We know that sometimes screencasts are just not enough, in this article I’ve added a new quick tip/lesson about the color property for you.

欢迎来到我们的AtoZ CSS系列! 在本系列中,我将探索不同CSS值(和属性),以字母中的一个字母开头。 我们知道有时屏幕截图还不够,在本文中,我为您添加了有关color属性的新快速提示/课程。

css-C2.jpg-01

C代表color (C is for color)

The color property is used to change the color of text on the page, but what about the color of selected text?

color属性用于更改页面上文本的颜色,但是所选文本的颜色呢?

Using the ::selection pseudo element, text highlighted with the mouse can be styled. There are only a handful of properties that can be altered when styling the selected text. These are limited to:

使用::selection伪元素,可以设置用鼠标突出显示的文本的样式。 在样式选定文本时,只有少数几个属性可以更改。 这些仅限于:

  • color

    color

  • background-color

    background-color

  • cursor

    cursor

  • outline

    outline

  • text-decoration

    text-decoration

  • text-shadow

    text-shadow

Even though you’re limited in the properties you can style with ::selection, you can still use the cascade to set different selection colors for different parts of the page.

即使您可以使用::selection样式的属性有限,您仍然可以使用级联为页面的不同部分设置不同的选择颜色。

See the Pen tip-c by SitePoint (@SitePoint) on CodePen.

请参阅CodePen上的SitePoint ( @SitePoint )提供的Pen tip-c 。

Test out this feature by highlighting some text in each of the paragraphs in the Codepen result.

通过在Codepen结果的每个段落中突出显示一些文本来测试此功能。

供应商前缀 (Vendor prefixes)

In Firefox the ::selection pseudo element still needs a -moz prefix and due to the way pseudo elements are parsed, a separate selector and block of styles is required; comma separating the two selectors won’t work.

在Firefox中, ::selection伪元素仍然需要-moz前缀,并且由于解析伪元素的方式不同,因此需要单独的选择器和样式块。 逗号分隔两个选择器将不起作用。

/* this won't work */
::selection,
::-moz-selection {
color: white;
background: green;
}
/* do this instead */
::selection {
color: white;
background: green;
}
::-moz-selection {
color: white;
background: green;
}

颜色发生器 (Color Generators)

There are a couple of great places to find and create color schemes for your projects. The following are some that I’ve found useful in the past:

有几个不错的地方可以找到和创建项目的配色方案。 以下是我过去发现有用的一些内容:

  • https://color.adobe.com/

    https://color.adobe.com/

  • http://coolors.cc/

    http://coolors.cc/

  • http://paletton.com/

    http://paletton.com/

  • http://paintbycode.github.io/gradient-generator/

    http://paintbycode.github.io/gradient-generator/

翻译自: https://www.sitepoint.com/atoz-css-color/




推荐阅读
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 本文介绍了一个适用于PHP应用快速接入TRX和TRC20数字资产的开发包,该开发包支持使用自有Tron区块链节点的应用场景,也支持基于Tron官方公共API服务的轻量级部署场景。提供的功能包括生成地址、验证地址、查询余额、交易转账、查询最新区块和查询交易信息等。详细信息可参考tron-php的Github地址:https://github.com/Fenguoz/tron-php。 ... [详细]
  • 本文整理了常用的CSS属性及用法,包括背景属性、边框属性、尺寸属性、可伸缩框属性、字体属性和文本属性等,方便开发者查阅和使用。 ... [详细]
  • Python中的PyInputPlus模块原文:https ... [详细]
  • Thisworkcameoutofthediscussioninhttps://github.com/typesafehub/config/issues/272 ... [详细]
  • 场景1.IE,Firefox浏览器访问不了网站,谷歌浏览器可以,返回错误码DNS_PROBE_POSSIBLE.2.pingwww.qq.com可以ping通,ping局域 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 本文介绍了网页播放视频的三种实现方式,分别是使用html5的video标签、使用flash来播放以及使用object标签。其中,推荐使用html5的video标签来简单播放视频,但有些老的浏览器不支持html5。另外,还可以使用flash来播放视频,需要使用object标签。 ... [详细]
  • 本博文基于《Amalgamationofproteinsequence,structureandtextualinformationforimprovingprote ... [详细]
  • python+selenium十:基于原生selenium的二次封装fromseleniumimportwebdriverfromselenium.webdriv ... [详细]
  • 详解 Python 的二元算术运算,为什么说减法只是语法糖?[Python常见问题]
    原题|UnravellingbinaryarithmeticoperationsinPython作者|BrettCannon译者|豌豆花下猫(“Python猫 ... [详细]
author-avatar
短暂的幸福2
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有