变量前的点在html中表示什么? [英] What does a dot before a variable indicate in html?
问题描述
一般来说,我是html和web编码的新手.在以下代码中,变量前的句点表示什么?
I'm new to html and web coding in general. What do the periods before variables indicate in the following code?
<style>
<!-- Modify these styles -->
.page_title {font-weight:bold}
.page_text {color:#000000}
</style>
... JS code
谢谢
推荐答案
这些不是变量. 这些是CSS选择器,每个示例都代表带有该类的HTML节点
those are not variables. Those are CSS Selectors, and they represent a HTML node with that class per example
<div class="page_title">Page Title</div>
您使用CSS选择器在HTML中设置这些元素的样式
You use CSS Selectors to style those elements in the HTML
自从他们提出了建议. =)
Since they've suggested. =)
有几种方法可以在CSS中引用HTML节点,最常见的是ID,类和标记名.
There are a few ways to reference HTML nodes in CSS, the most common are ID's, Classes and the tag name.
看看这个例子
<div>
<ul id="first_set">
<li class="item"> Item 1 </li>
<li class="item"> Item 2 </li>
</ul>
<ul id="second_Set">
<li class="item"> Item 1 </li>
<li class="item"> Item 2 </li>
</ul>
</div>
好的.我们有一个div,其中包含两个无序列表,每个列表为两个列表项,现在为CSS:
Ok. we have a div with two unordered lists, each list as two list-items, now the CSS:
div { background-color: #f00; }
#first_set { font-weight: bold; }
#second_set { font-weight: lighter; }
.item { color: #FF00DA }
div
选择器将选择HTML页面中的所有<div>
,
#表示ID,因此#first_set
它将选择具有该ID的对象,在这种情况下,它将选择
the div
selector will select all <div>
's in the HTML page,
the # means ID, so #first_set
it will select the object with that id in this case it will select
<ul id="first_set">
点符号选择类,因此.item
选择器将选择所有具有项目类的对象,在这种情况下,它将选择全部
the dot symbol select classes so the .item
selector will select all objects with the item class in this case it will select all
<li class="item">
这实际上只是基础知识,您可以将这些选择器混合使用,以使每个示例更加具体:
This is just the basics really, you can mix these selectors to be more specific per example:
#first_set .item { text-decoration: underline; }
,它只会选择#first_set内部具有class item的对象.
and it will only select the objects with class item that are inside the #first_set.
值得一提的是,通常,ID(用#myID选择)只能在HTML页面上一次使用,并且一个类可以用于多个元素.另外,一个元素可以具有多个类.只需用空格隔开即可. (例如
<li class="item special-item">
)– 白金Azure
这篇关于变量前的点在html中表示什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!