1

私は次のCSSを持っています:

#content-button-panel ul li a.folder span {
  cursor: default;
}
#content-button-panel ul li a:not(.folder) span {
  cursor: pointer;
}

および次の HTML:

<a class="title-coffee"><span>Overview</span></a>

HTML (title-xxxxxxx のクラス) にデフォルトのカーソルがあるようにするにはどうすればよいですか? title-coffee または title- で始まる任意のクラスで動作するには、これが必要であることに注意してください。

4

4 に答える 4

2

次のような新しい CSS クラスを追加しないのはなぜですか。

.cursor {
    cursor: default;
}
.pointer {
    cursor: pointer;
}

そして、次のように、必要に応じて各クラスを具体的に使用します。

<a class="coffee cursor"><span>Overview</span></a>
<a class="folder pointer"><span>Pointer</span></a>
于 2012-12-24T16:46:02.387 に答える
1

多くの属性セレクターの 1 つを使用できます。これは、クラス属性が「title-」で始まるすべての要素を選択します

 a[class^="title-"]

あなたの場合、次のように使用します。

#content-button-panel ul li a.folder span,
#content-button-panel ul li a[class^="title-"] span {
  cursor: pointer;
}
于 2012-12-24T16:33:36.603 に答える
0

CSS による否定は、 2 つの方法で行うことができます。

input:not(.classA, .classB) /* 個人的には、この作品を見たことがない */

また

input:not([type="radio"]):not([type="checkbox"])

Typically, I would recommend simply using a 3rd class instead of using :not. But in the case of input elements where some elements look better with the browser's default styling, writing out an inclusive selector to catch every single type I do want to style is considerably longer than writing out a negation selector for the types I don't want, I'll go for the shorter selector.

:not can be chained like any other simple selector or pseudo-class

a[class^="title-"]:not(.folder)
于 2012-12-24T18:30:26.480 に答える
0

これが私がすることです。各オブジェクトで ID を使用し、必要に応じてそれらを具体的に対象にしたいと考えています。クラスをターゲットにしている場合、特定のアイテムを指定するのが難しくなるため、この方法をお勧めします。

CSS:

.defaultCursor {
   cursor: default;
}

HTML:

<a id="ThisItemsID" ><span>Overview</span></a>

JS コード (必要に応じて、カーソルを適用する必要がある場所):

$("#ThisItemsID").addClass('defaultCursor');
于 2012-12-24T16:32:54.417 に答える