当前位置: 动力学知识库 > 问答 > 编程问答 >

pug - Jade (node.js) - more than one class on an element?

问题描述:

in jade one can write:

div.container

and it compiles into:

<div class="container"></div>

But what if you have several classes like:

<div class="span 4"><div>

I have written it like this:

div(class="span 4")

But I am thinking: Is there not a better way of doing it in jade?

网友答案:

From the documentation:

how about some classes?

div.user-details

renders <div class="user-details"></div>

multiple classes? and an id? sure:

div#foo.bar.baz

renders <div id="foo" class="bar baz"></div>

网友答案:

The following format

    div#MyBox.span12.blueButton.moveLeft

will create

    <div id="MyBox" class="span12 blueButton moveLeft"></div>
网友答案:

You don't have to specify div

#MyBox.span12.blueButton.moveLeft     

will apply the selected class and id on a div element :

Since div's are such a common choice of tag, it is the default if you omit the tag name: .content compiles to <div class="content"></div>

See the Pug (new name for Jade) documentation.

However you have to specify the tags of each and every other element you use with an id or class.

Ex.

body
  #page
    header.row
      h1= title
    .row
      p Express App
分享给朋友:
您可能感兴趣的文章:
随机阅读: