在CSS中使用not:first-child选择器
Introduction:
介紹:
Well, selectors are a very common term to deal with while we are developing a website or web page. You might know quite a few of them and might as well be implementing them. You might also have noticed that all the selectors are used for selecting some element or other, well that's their entire purpose and thus the name selectors. Although all the selectors share common characteristics but not all of them are the same. Their behaviors differ to a very great extent and one can only know after practical implementation. So, since we are discussing selectors, why don't we talk about one very specific selector? Although you might have come across this selector at some point of your time. The selector we will be focused on is not:first-child selector. To know more about this selector just keep reading on!
好吧,在我們開發網站或網頁時,選擇器是一個很常見的術語。 您可能知道很多,也可能正在實施它們。 您可能還已經注意到,所有選擇器都用于選擇某些元素或其他元素,這就是它們的全部用途,因此也就是名稱選擇器。 盡管所有選擇器都具有共同的特征,但并非所有選擇器都相同。 它們的行為差異很大,只有在實際實施后才能知道。 因此,既然我們正在討論選擇器,為什么不談論一個非常具體的選擇器呢? 盡管您可能在某個時候遇到了此選擇器。 我們將關注的選擇器不是:first-child選擇器 。 要了解有關此選擇器的更多信息,請繼續閱讀!
Well, the name sounds a bit weird, doesn't it? Not: first child. So, that brings us to the question of what does this selector does and how is this selector different from other selectors. Well, the functioning and behavior of this selector are not very tough to understand and you can easily figure out from the name itself that for what purpose this selector is put to use. So let us look at a more formal definition of this selector so that we get a better gist of it.
好吧,這個名字聽起來有些怪異,不是嗎? 不:第一個孩子。 因此,這就引出了這個選擇器的作用以及該選擇器與其他選擇器有何不同的問題。 好吧,這個選擇器的功能和行為并不是很難理解的,您可以很容易地從名稱本身中得知該選擇器用于什么目的。 因此,讓我們看一下這個選擇器的更正式定義,以便我們更好地了解它。
Definition:
定義:
The not:first-child selector as the name suggests is used to select every element which is not the first child element of it's deriving parent element. Pretty simple right? The selector is not used for choosing the first child of its parent element. This selector is usually represented as an argument and it is seen in the form of not(first-child). To help you understand this in a better way, why don't you go ahead and have a look at the syntax below,
顧名思義, not:first-child選擇器用于選擇不是其派生父元素的第一個子元素的每個元素。 很簡單吧? 選擇器不用于選擇其父元素的第一個子元素。 該選擇器通常表示為一個參數,并且以not(first-child)的形式出現。 為了幫助您更好地理解這一點,為什么不繼續閱讀下面的語法,
:not(element){//some CSS property}Example:
例:
In the above example the div element contains <ul> elements, so it selects all child elements of <div> tag except its first-child and applies the CSS styles.
在上面的示例中,div元素包含<ul>元素,因此它將選擇<div>標記的所有子元素(第一個孩子除外)并應用CSS樣式。
Piece of advice:
一點建議:
Now, it is time to make use of your new-found knowledge. But before you get on with that make sure you use this selector properly wherever required because you don't want your code to get ruined just because of a silly mistake right? Not just this one you must use every selector wisely to make your website or web page responsive and whenever in doubt, you will always have this article for your reference. Also, if you have some issues with our code and practice, we are always available to help you at https://ask.includehelp.com/.
現在,該利用您新發現的知識了。 但是在繼續之前,請確保在所需的任何地方正確使用此選擇器,因為您不希望僅僅因為一個愚蠢的錯誤而導致代碼被破壞嗎? 您不僅必須明智地使用每個選擇器,以使您的網站或網頁具有響應能力,而且如有疑問,您將始終可以將本文作為參考。 另外,如果您對我們的代碼和實踐有任何疑問,請訪問https://ask.includehelp.com/隨時可以為您提供幫助。
翻譯自: https://www.includehelp.com/code-snippets/using-a-not-first-child-selector-in-css.aspx
總結
以上是生活随笔為你收集整理的在CSS中使用not:first-child选择器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mcq 队列_MCQ | 8086微处理
- 下一篇: python中八进制_在Python中以