css注释_CSS注释示例–如何注释CSS

css注释

Comments are used in CSS to explain a block of code or to make temporary changes during development. The commented code doesn’t execute.

CSS中使用注释来解释代码块或在开发过程中进行临时更改。 注释的代码不执行。

Both single and multi-line comments in CSS begin with /* and end with */, and you can add as many comments to your stylesheet as you like. For example:

CSS中的单行和多行注释都以/*开头,并以*/结尾,并且您可以根据需要在样式表中添加任意数量的注释。 例如:

/* This is a single line comment*/
.group:after {content: "";display: table;clear: both;
}/*This isa multi-linecomment
*/

You can also make your comments more readable by stylizing them:

您还可以通过设置样式的风格来使注释更具可读性:

/*
***
* SECTION FOR H2 STYLE 
***
* A paragraph with information
* that would be useful for someone
* who didn't write the code.
* The asterisks around the paragraph 
* help make it more readable.
***
*/

用注释组织CSS (Organizing CSS with comments)

In larger projects, CSS files can quickly grow in size and become difficult to maintain. It can be helpful to organize your CSS into distinct sections with a table of contents to make it easier to find certain rules in the future:

在较大的项目中,CSS文件的大小会快速增长,并且变得难以维护。 将您CSS组织成带有目录的不同部分可能会有所帮助,以便将来更轻松地查找某些规则:

/* 
*  CSS TABLE OF CONTENTS
*   
*  1.0 - Reset
*  2.0 - Fonts
*  3.0 - Globals
*  4.0 - Color Palette
*  5.0 - Header
*  6.0 - Body
*    6.1 - Sliders
*    6.2 - Imagery
*  7.0 - Footer
*//*** 1.0 - Reset ***//*** 2.0 - Fonts ***//*** 3.0 - Globals ***//*** 4.0 - Color Palette ***//*** 5.0 - Header ***//*** 6.0 - Body ***/
h2 {font-size: 1.2em;font-family: "Ubuntu", serif;text-transform: uppercase;
}/*** 5.1 - Sliders ***//*** 5.2 - Imagery ***//*** 7.0 - Footer ***/

有关CSS的更多信息: CSS语法和选择器 (A little bit more about CSS: CSS Syntax and Selectors)

When we talk about the syntax of CSS, we’re talking about how things are laid out. There are rules about what goes where, both so you can write CSS consistently and a program (like a browser) can interpret it and apply it to the page correctly.

当我们谈论CSS的语法时,我们在谈论事物的布局。 关于去哪里有规则,因此都可以一致地编写CSS,并且程序(如浏览器)可以解释CSS并将其正确地应用于页面。

There are two main ways to write CSS.

编写CSS的主要方法有两种。

内联CSS (Inline CSS)

Specifics on CSS Specificity: CSS Tricks

有关CSS特殊性的细节: CSS技巧

Inline CSS applies styling to a single element and its children, until another style overriding the first is encountered.

内联CSS将样式应用于单个元素及其子元素,直到遇到另一个覆盖第一个样式的样式。

To apply inline CSS, add the “style” attribute to an HTML element that you’d like to modify. Inside quotes, include a semicolon-delimited list of key/value pairs (each in turn separated by a colon) indicating styles to set.

要应用内联CSS,请将“样式”属性添加到您要修改HTML元素中。 在引号内,包括用分号分隔的键/值对列表(每个键/值对依次由冒号分隔),以指示要设置的样式。

Here’s an example of inline CSS. The words “One” and “Two” will have a background color of yellow and text color of red. The word “Three” has a new style that overrides the first, and will have a background color of green and text color of cyan. In the example, we’re applying styles to <div> tags, but you can apply a style to any HTML element.

这是内联CSS的示例。 单词“一个”和“第二”将具有黄色的背景色和红色的文本色。 “三”一词具有新的样式,该样式将覆盖第一个样式,并且将具有绿色的背景颜色和青色的文本颜色。 在示例中,我们将样式应用于<div>标记,但是您可以将样式应用于任何HTML元素。

<div style="color:red; background:yellow">One<div>Two</div><div style="color:cyan; background:green">Three</div>
</div>

内部CSS (Internal CSS)

While writing an inline style is a quick way to change a single element, there’s a more efficient way to apply the same style to many elements of the page at once.

虽然编写内联样式是更改单个元素的快速方法,但是有一种更有效的方法可将同一样式同时应用于页面的许多元素。

The internal CSS has its styles specified in the <style> tag, and it is embedded in the <head> tag.

内部CSS在<style>标记中指定了其样式,并且将其嵌入在<head>标记中。

Here’s an example that has a similar effect as the “inline” example above, except the CSS has been extracted to its own area. The words “One” and “Two” will match the div selector and be red text on a yellow background. The words “Three” and “Four” will match the div selector too, but they also match the .nested_div selector which applies to any HTML element that references that class. This more specific selector overrides the first, and they end up appearing as cyan text on a green background.

这是一个与上述“内联”示例具有相似效果的示例,只是CSS已被提取到其自己的区域。 单词“ One”和“ Two”将与div选择器匹配,并在黄色背景上为红色文本。 单词“三”和“四”也将与div选择器匹配,但是它们也与.nested_div选择器匹配,该选择器适用于引用该类的任何HTML元素。 这个更具体的选择器会覆盖第一个选择器,最终它们在绿色背景上显示为青色文本。

<style type="text/css">div { color: red; background: yellow; }.nested_div { color: cyan; background: green; }
</style><div>One<div>Two</div><div class="nested_div">Three</div><div class="nested_div">Four</div>
</div>

The selectors shown above are extremely simple, but they can get quite complex. For example, it’s possible to apply styles only to nested elements; that is, an element that’s a child of another element.

上面显示的选择器非常简单,但是会变得非常复杂。 例如,可以仅将样式应用于嵌套元素; 也就是说,一个元素是另一个元素的子元素。

Here’s an example where we’re specifying a style that should only be applied to div elements that are a direct child of other div elements. The result is that “Two” and “Three” will appear as red text on a yellow background, but “One” and “Four” will remain unaffected (and most likely black text on a white background).

这里就是我们指定只应适用于一种风格的例子div是其他的直接子元素div元素。 结果是“两个”和“三个”将在黄色背景上显示为红色文本,但“一个”和“四个”将不受影响(并且很可能在白色背景上显示为黑色文本)。

<style type="text/css">div > div { color: red; background: yellow; }
</style><div>One<div>Two</div><div>Three</div>
</div>
<div>Four
</div>

外部CSS (External CSS)

All the styling has its own document which is linked in the <head> tag. The extension of the linked file is .css

所有样式都有自己的文档,该文档链接在<head>标记中。 链接文件的扩展名为.css

翻译自: https://www.freecodecamp.org/news/comments-in-css/

css注释

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/390578.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

r软件时间序列分析论文_高度比较的时间序列分析-一篇论文评论

r软件时间序列分析论文数据科学 &#xff0c; 机器学习 (Data Science, Machine Learning) In machine learning with time series, using features extracted from series is more powerful than simply treating a time series in a tabular form, with each date/timestamp …

leetcode 168. Excel表列名称

题目 给你一个整数 columnNumber &#xff0c;返回它在 Excel 表中相对应的列名称。 例如&#xff1a; A -> 1 B -> 2 C -> 3 … Z -> 26 AA -> 27 AB -> 28 … 示例 1&#xff1a; 输入&#xff1a;columnNumber 1 输出&#xff1a;“A” 示例 2&…

飞机订票系统

1 #include <stdio.h>2 #include <stdlib.h>3 #include <string.h>4 #include <conio.h>5 typedef struct flightnode{6 char flight_num[10]; //航班号7 char start_time[10]; //起飞时间8 char end_time[10]; //抵达时间9 char st…

解决Mac10.13 Pod报错 -bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.fram

升级10.13以后Pod命令失效&#xff0c;解决办法如下&#xff1a; 终端执行 brew link --overwrite cocoapods 复制代码尝试 Pod 命令是否已经恢复 若报错继续执行 brew reinstall cocoapodsbrew install rubybrew link --overwrite cocoapods 复制代码尝试 Pod 命令是否已经恢复…

angular示例_用示例解释Angular动画

angular示例为什么要使用动画&#xff1f; (Why use Animations?) Modern web components frequently use animations. Cascading Style-sheets (CSS) arms developers with the tools to create impressive animations. Property transitions, uniquely named animations, mu…

selenium抓取_使用Selenium的网络抓取电子商务网站

selenium抓取In this article we will go through a web scraping process of an E-Commerce website. I have designed this particular post to be beginner friendly. So, if you have no prior knowledge about web scraping or Selenium you can still follow along.在本文…

剑指 Offer 37. 序列化二叉树

题目 序列化是将一个数据结构或者对象转换为连续的比特位的操作&#xff0c;进而可以将转换后的数据存储在一个文件或者内存中&#xff0c;同时也可以通过网络传输到另一个计算机环境&#xff0c;采取相反方式重构得到原数据。 请设计一个算法来实现二叉树的序列化与反序列化…

ie8 ajaxSubmit 上传文件提示下载

转载 解决ie下ajaxsubmit上传文件提示下载文件问题 主要是应为放回类型为json&#xff0c;返回text/html转载于:https://www.cnblogs.com/yang-C-J/p/8963278.html

一个简单的 js 时间对象创建

JS中获取时间很常见&#xff0c;凑凑热闹&#xff0c;也获取一个时间对象试试 首先&#xff0c;先了解js的获取时间函数如下&#xff1a; var myDate new Date(); //创建一个时间对象 myDate.getYear(); // 获取当前年份&#xff08;2位&#x…

裁判打分_内在的裁判偏见

裁判打分News flash: being an umpire is hard. Their job is to judge whether a ball that’s capable of moving upwards of 100 MPH or breaking 25 inches crossed through an imaginary zone before being caught. I don’t think many would argue that they have it ea…

数据库sql课程设计_SQL和数据库-初学者完整课程

数据库sql课程设计In this course, Mike Dane will teach you database management basics and SQL.在本课程中&#xff0c;Mike Dane将教您数据库管理基础知识和SQL。 The course starts off with Mike helping you install MySQL on Windows or Mac. Then he explores topic…

LCP 07. 传递信息

小朋友 A 在和 ta 的小伙伴们玩传信息游戏&#xff0c;游戏规则如下&#xff1a; 有 n 名玩家&#xff0c;所有玩家编号分别为 0 &#xff5e; n-1&#xff0c;其中小朋友 A 的编号为 0 每个玩家都有固定的若干个可传信息的其他玩家&#xff08;也可能没有&#xff09;。传信息…

微信公众号自动回复加超链接最新可用实现方案

你在管理微信号时是否会有自动回复或者在关键字触发自动回复加一个超链接的需求呢&#xff1f;例如下图像王者荣耀这样&#xff1a; 很多有开发经验的朋友都知道微信管理平台会类似富文本编辑器&#xff0c;第一想到的解决方案会是在编辑框中加<a href网址 >显示文字<…

devops开发模式流程图_2020 Web开发人员路线图–成为前端,后端或DevOps开发人员的视觉指南

devops开发模式流程图There are many ways you can go about picking up the skills you need to become a developer.您可以采用多种方法掌握成为开发人员所需的技能。 There are linear curriculums that teach you a bit of everything - like freeCodeCamps full stack de…

从Jupyter Notebook切换到脚本的5个理由

意见 (Opinion) 动机 (Motivation) Like most people, the first tool I used when started learning data science is Jupyter Notebook. Most of the online data science courses use Jupyter Notebook as a medium to teach. This makes sense because it is easier for be…

leetcode 1833. 雪糕的最大数量

夏日炎炎&#xff0c;小男孩 Tony 想买一些雪糕消消暑。 商店中新到 n 支雪糕&#xff0c;用长度为 n 的数组 costs 表示雪糕的定价&#xff0c;其中 costs[i] 表示第 i 支雪糕的现金价格。Tony 一共有 coins 现金可以用于消费&#xff0c;他想要买尽可能多的雪糕。 给你价格…

MVC架构 -- 初学试水选课管理系统

项目文件网站地址&#xff1a;http://www.gegecool.cn:90/ 第一次对MVC 进行转载于:https://www.cnblogs.com/wtusoso/p/8032120.html

rest api 示例2_REST API教程– REST Client,REST Service和API调用通过代码示例进行了解释

rest api 示例2Ever wondered how login/signup on a website works on the back-end? Or how when you search for "cute kitties" on YouTube, you get a bunch of results and are able to stream off of a remote machine?有没有想过网站上的登录/注册在后端如…

win10子系统linux编译ffmpeg

android-ndk-r14b(linux版) ffmpeg-4.0 开启win10子系统&#xff08;控制面板-》程序和功能-》启用或关闭Windows功能 然后在 适用与 Linux 的 Windows 子系统前面打勾&#xff09; 然后点击确定&#xff0c;等待安装&#xff0c;电脑会重启 然后在win10应用商店 搜索ubuntu安装…

ip登录打印机怎么打印_不要打印,登录。

ip登录打印机怎么打印Often on Python, especially as a beginner, you might print( ) a variable in order to see what is happening in your program. It is possible if you rely on too many print statements throughout your program you will face the nightmare of h…