html - 在html中变量前的点表示什么?

标签 html variables period

我一般不熟悉 html 和网络编码。以下代码中变量前的句点表示什么?

<style>
<!-- Modify these styles -->
.page_title       {font-weight:bold}
.page_text        {color:#000000}
</style>
... JS code

谢谢

最佳答案

那些不是变量。 这些是 CSS 选择器,它们代表每个示例具有该类的 HTML 节点

<div class="page_title">Page Title</div>

您使用 CSS 选择器在 HTML 中设置这些元素的样式


因为他们已经建议了。 =)

有几种方法可以在 CSS 中引用 HTML 节点,最常见的是 ID、类和标签名称。

看看这个例子

<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:

div { background-color: #f00; } 
#first_set { font-weight: bold; }
#second_set { font-weight: lighter; }
.item { color: #FF00DA }

div选择器将选择所有 <div>在 HTML 页面中, # 表示 ID,所以 #first_set它将选择具有该 ID 的对象,在这种情况下它将选择

<ul id="first_set">

点符号选择类所以 .item选择器将选择所有具有 item 类的对象,在这种情况下它将选择所有

<li class="item">

这实际上只是基础知识,您可以根据示例混合使用这些选择器以使其更加具体:

#first_set .item { text-decoration: underline; }

它只会选择#first_set 内具有类 item 的对象。


It's worth mentioning that in general, an ID (selected with #myID) should only be used ONCE on an HTML page, and a class can be used on multiple elements. Additionally, an element can have more than one class; just separate them with spaces. (e.g., <li class="item special-item">) – Platinum Azure

关于html - 在html中变量前的点表示什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4556250/

相关文章:

html - 在 bootstrap carousel 中的每个图像的底部添加链接

sql - 在 SQL Server 中,如何创建表的引用变量?

python - 使用变量作为函数名和字符串

javascript - 列出使用 jQuery 检查的变量值

java - 在另外两个textview获取值之后设置textview值

java - 以编程方式查找给定函数的周期性

java - 如何使用 Jquery 将多个值传递给 servlet

html - Materialise textarea 标签在固定高度上不可滚动

javascript - 提交前验证 "select"下拉列表

sql - SQL 中时间段的交叉和合并