CSS 組合器( CSS combinators )

CSS Combinators 包括:

  1. 後代選擇器(Descendant Combinator): 「 」
  2. 子選擇器(Child Combinator):「 > 」
  3. 相鄰兄弟選擇器(Adjacent Sibling Combinator):「 + 」
  4. 一般兄弟選擇器(General Sibling Combinator):「 – 」
  5. 組合選擇器(Group Selector):「 , 」

1. 後代選擇器(Descendant Combinator):(空格)

  • 用法A B
  • 作用:選擇所有位於 A 元素內部的 B 元素,不論它們之間有多少層嵌套。
  • 例子
<div class="container">
  <p>我是第一個段落</p>
  <div>
    <p>我是嵌套的段落</p>
  </div>
</div>
.container p {
  color: red;
}

codepen 實測

結果:選擇 .container 內的所有 p 元素,無論它們是否直接位於 .container 內。例子中,兩個 p 元素都會變成紅色。

2. 子選擇器(Child Combinator)>

語法A > B

  • 作用:選擇 A直接子元素 B,不會選擇後代元素(孫元素及更深層次的後代元素)。
  • 例子
<div class="container">
  <p>我是直接子元素</p>
  <div>
    <p>我是嵌套的段落</p>
  </div>
</div>
.container > p {
  color: blue;
}

codepen 實測

結果:只會選擇 .container 的直接子元素 p,即第一個 p 會變成藍色。嵌套在 div 中的第二個 p 不會被選中。

3. 相鄰兄弟選擇器(Adjacent Sibling Combinator)+

語法A + B

  • 作用:選擇緊接在 A 元素後面的相鄰兄弟元素 B,中間不能有其他元素。
  • 例子
<h1>標題</h1>
<p>我是第一個段落</p>
<p>我是第二個段落</p>
h1 + p {
  color: green;
}

codepen 實測

結果:只會選擇緊接在 h1 後面的第一個 p,即第一個 p 會變成綠色。第二個 p 不會被影響,因為它不是緊鄰的兄弟元素。

4. 一般兄弟選擇器(General Sibling Combinator)~

語法A ~ B

  • 作用:選擇 A 元素後面的所有兄弟元素 B,不要求它們緊鄰在一起。
  • 例子
<h1>標題</h1>
<p>我是第一個段落</p>
<p>我是第二個段落</p>
<div>我是另一個元素</div>
<p>我是第三個段落</p>
h1 ~ p {
  color: orange;
}

codepen 實測

結果:所有位於 h1 後面的 p 元素都會變成橙色,包括第一個、第二個和第三個 p,即使它們中間隔著其他元素(如 <div> )。

組合選擇器(Group Selector),(逗號)

語法A, B, C

  • 作用:將多個選擇器組合在一起,使它們共享相同的樣式。
  • 例子
<h1>我是標題</h1>
<h2>我是副標題</h2>
<p>我是段落</p>
h1, h2, p {
  color: purple;
}

codepen 實測

結果:h1、h2 和 p 都會變成紫色,因為這三個選擇器共享相同的樣式。

6. 否定偽類選擇器(:not)(雖然不是組合器,但它常用於選擇元素時排除特定元素)

語法:not(A)

  • 作用:選擇除了 A 之外的所有元素。
  • 例子
<ul>
  <li>項目 1</li>
  <li>項目 2</li>
  <li class="special">特殊項目</li>
  <li>項目 3</li>
</ul>
li:not(.special) {
  color: gray;
}

codepen 實測

結果:除了類為 specialli 元素外,所有的 li 元素都會變成灰色。

7. 伺機選擇器(Universal Selector)*

語法*

  • 作用:選擇所有元素。
  • 例子
<div>
  <p>段落 1</p>
  <p>段落 2</p>
</div>
* {
  margin: 0;
  padding: 0;
  color: red;
}

codepen 實測

結果:所有的元素(包括 divp 等)都會把內邊距和外邊距設置為 0,並且文字顏色為紅色。

小結:所有 CSS 組合器及部分常用選擇器

  1. (空格):後代選擇器,選擇 A 內部的所有 B 元素。
  2. >:子選擇器,選擇 A 的直接子元素 B
  3. +:相鄰兄弟選擇器,選擇緊接在 A 後面的兄弟元素 B
  4. ~:一般兄弟選擇器,選擇 A 之後的所有兄弟元素 B
  5. ,:組合選擇器,將多個選擇器組合在一起,使它們共享相同的樣式。
  6. :not:否定偽類選擇器,用來排除特定元素。
  7. *:伺機選擇器,選擇所有元素。

Power over Ethernet, PoE 的標準電壓

PoE 的標準電壓有以下幾種:

PoE (IEEE 802.3af):
標準電壓: 48 V DC
最大功率: 15.4 W

PoE+ (IEEE 802.3at):
標準電壓: 48 V DC
最大功率: 30 W

PoE++ (IEEE 802.3bt):
標準電壓:
Type 3: 48 V DC
Type 4: 54 V DC

最大功率:
Type 3: 60 W
Type 4: 100 W

所以對於標準的 PoE 設備而言,常見的標準電壓是 48 V DC,這是 IEEE 802.3af 和 802.3at 標準中指定的。後來的 802.3bt 標準則提供了更高功率的 PoE++ 選項。

Linux Find Command

ExamplesCreated by @dan_nanni on Instagram

find . -name “my.txt” find all files named “my.txt”

find .-type d-name “mydir” find all directories named “mydir”

find . -type f-name “*.jpg” find all “.jpg” files

find . -type f-size +100M find all files larger than 100MB

find . -type f-size +100M-size -500M find files with a specific size range

find . -type f-mtime-1 find all files modified in last 24 hours

find .-mtime-7-mtime +1 find files modified betn yesterday & a week ago

find . -type f-name “*.tmp” -delete find and remove all “.tmp” files

find . -type f-perm 0777 find all files with “777” permission

find . -type f-perm-u+x find all files executed by the user

find . -type f-name “*.txt” -exec cat {} \; find and cat all “*.txt” files

find . -type f-amin-60 find all files accessed within the last hour

find . -type f-user dan find all files owned by the user “dan”

find .-type f-ctime -2 find files created within last 2 days

find .-maxdepth 1 -name “my.txt” search only in current dir

find . -type f-name “*.txt” | xargs chmod 644 chmod all “.txt” to 644

find . -type f-name “*.jpg” | xargs tar -cf img.tgz archive all “.jpg” files

find . -type f-name “*.png” | xargs -I {} mv {} /tmp move all “.png” files

find . -type f-name “*.txt” | xargs grep “Hello” search for Hello in “.txt”

find .-xtypel-delete find and remove all broken symbolic links

find .-type d-empty-delete find and remove all empty directories

find .-newermt “2024-01-01”! -newermt “2024-03-15” use a time range

做人要學會保護自己

  1. 你不讓他佔便宜,就是你自私。
  2. 你不接受他們的價值觀,就是你固執。
  3. 你不肯接受他們的指揮,就是你強勢。
  4. 你一旦站在道理上不肯退讓了,就是你態度問題。
  5. 你差到他們的陰謀時,你太敏感了。
  6. 他們一旦發現你沒有那麼好騙,就是你們不懂事。
  7. 你一旦要勝利了,他們發現了就要輸,你就是世界第一大反派。

別因為一時的成功,而得以忘形

別因為一時的成功,而得以忘形 ,隨便發表自己的個人想法,從而導致身邊的人感受不良好,不舒服。這會直接為自己造成重大影響,損害個人形象。我們必須要記住,沒有人喜歡聽另一個人講大道理,特別是這些道理他們不接受,為了自己,讓自己成為一個謙虛的人謙卑的人,就是保護自己最好的方法。 別忘記,當你成功時,同時代表人家失敗。人家為什麼要高興呢? 不喜歡人家過得比自己好,是很多人的內心世界,沒必要讓這些人不高興,以為自己造成傷害。再溝,只不過是一些少許的成就,有必要炫耀嗎?就算要炫耀,都必須要對自己有幫助下,才有意義,傷害自己毫無意義也可言。

避免無目的地開玩笑

為了顯得幽默風趣,有些人經常刻意地逗人開心,但這種行為往往會因思考速度不夠快而不慎冒犯他人,這些無意義的言論不僅傷害了別人,也傷害了自己。

我們需要認真思考一下,開玩笑是否具有必要性和重要性?除了讓對話變得有趣外,其餘的效果往往是負面的。

有一位女士曾經說過,如果說的話不好聽,不如不說,只說些正面的話語。這種做法對於自己和他人都是有益的。

讓我們來分析一下,拿別人的缺點開玩笑有意義嗎?還是用他人的優點來逗人開心更好一些?

通過思考,看來已經找到答案。

nextCloud upgrade hints

Use command line for upgrade nextCloud was bester than using Web Upgrade. Some reason not work with Web upgrade.

Using the command line for upgrading NextCloud is more efficient than using the web upgrade interface. There are several reasons why the command line method is preferable:

Upgrade Duration: Upgrading NextCloud can take several hours, and when using the web upgrade, it’s difficult to gauge whether the process is progressing or if it has encountered issues and halted.

Error Handling: Upgrades can sometimes result in errors that require intervention. When using the command line, it provides more detailed information about any issues encountered, making it easier to take corrective actions. In contrast, the web upgrade may not provide sufficient information to diagnose and fix problems effectively.

PHP Configuration: To upgrade NextCloud, PHP often requires the apc.enable_cli=1 configuration. This configuration may not always be set correctly when using the web upgrade, causing upgrade issues.

In summary, utilizing the command line for NextCloud upgrades offers better control, error visibility, and ensures the necessary PHP configurations are in place for a smoother upgrade process compared to the web upgrade interface.

Make the nextCloud Folder work with same User and same permission

My Web Directory: /var/www/nextcloud
My Apache user: apache2

chown -R apache2: /var/www/nextcloud

nextCloud Upgrade

sudo -u apache2 php --define apc.enable_cli=1 /var/www/nextcloud/updater/updater.phar

sudo -u apache2 php --define apc.enable_cli=1 /var/www/nextcloud/occ upgrade

sudo -u apache2  php --define apc.enable_cli=1 /var/www/nextcloud/occ maintenance:mode --off

The database is missing some indexes

sudo -u apache2  php --define apc.enable_cli=1 /var/www/nextcloud/occ db:add-missing-indices