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

发布于 2024-10-09 11:26:19 字数 234 浏览 6 评论 0原文

总的来说,我对 html 和 web 编码很陌生。下面的代码中变量前面的句点表示什么?

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

谢谢

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

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

岁月苍老的讽刺 2024-10-16 11:26:19

这些不是变量。
这些是 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 选择器将选择 HTML 中的所有

页,
# 表示 ID,因此 #first_set 它将选择具有该 id 的对象,在本例中它将选择

<ul id="first_set">

点符号选择类,因此 .item 选择器将选择所有对象在这种情况下,使用 item 类,它将选择所有

<li class="item">

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

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

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


值得一提的是,一般来说,一个 ID(用 #myID 选择)只能在 HTML 页面上使用一次,而一个类可以在多个元素上使用。此外,一个元素可以有多个类;只需用空格分隔它们即可。 (例如,

  • ) – 白金 Azure< /a>

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

    You use CSS Selectors to style those elements in the HTML


    Since they've suggested. =)

    There are a few ways to reference HTML nodes in CSS, the most common are ID's, Classes and the tag name.

    take a look at this example

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

    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 }
    

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

    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; }
    

    and it will only select the objects with class item that are inside the #first_set.


    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

    迷荒 2024-10-16 11:26:19

    也就是在CSS中将一个样式分组标记为一个类。
    请阅读教程@w3schools,这是一个非常好的入门教程。

    http://www.w3schools.com/css/default.asp

    That is to mark a style grouping as a class in CSS.
    Please go through the tutorial @w3schools, that is a real good starter.

    http://www.w3schools.com/css/default.asp

    哥,最终变帅啦 2024-10-16 11:26:19

    通常某些东西所属的类,例如

    .treeListContainer input
    

    treelistcontainer是类,输入是类中的控件,因此样式仅影响该类中的控件

    usually the class something belongs to for example

    .treeListContainer input
    

    treelistcontainer is the class and input is the control within the class so the style only affects the controls within that class

    清风夜微凉 2024-10-16 11:26:19

    你所说的部分是嵌入在HTML中的CSS。 CSS 和 HTML 都没有变量,您正在查看选择器

    点前缀表示它是一个 类选择器 并且将匹配一个 HTML 元素,它是给定类的成员。

    要使元素成为类的成员,类名将添加到以 类属性

    因此 .page_title 将与以下元素匹配:

    class="foo page_title bar baz"
    

    但是,一般来说,您赋予类名(例如“page_title”)的任何内容都可能与主标题相同,因此 HTML 通常应该看起来像:

    <h1>Main heading goes here</h1>
    

    而 CSS:

    h1 { … }
    

    顺便说一句, 是 HTML(和 HTML 兼容的 XHTML)中的错误。 CSS 注释由 /**/ 分隔。

    The section you talk about is CSS embedded in HTML. Neither CSS nor HTML have variables, you are looking at selectors.

    The dot prefix indicates that it is a class selector and will match an HTML element which is a member of the given class.

    To make an element a member of a class, the class name is added to the space separated list given as the value of the class attribute.

    Thus .page_title will match an element with:

    class="foo page_title bar baz"
    

    Generally speaking, however, anything you give a class name such as "page_title" to is likely to be the same thing as the main heading, so the HTML should usually look like:

    <h1>Main heading goes here</h1>
    

    And the CSS:

    h1 { … }
    

    Incidentally, <!-- Modify these styles -->, is an error in HTML (and HTML compatible XHTML). A CSS comment is delimited with /* and */.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文