Code screenshot

CSS 入門:background-clip: text

今次介紹 background-clip: text,可以為文字加上背景圖片,或者配合 background: linear-gradient(); 做漸變色文字。 .text-bg-clip { background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: rgba(0, 0, 0, 0); } See the Pen CSS Text Portrait by littlecodeguy (@littlecodeguy) on CodePen.

July 8, 2022 · 1 min · 29 words · Me
Code screenshot

Javascript 入門:Object.keys() vs Object.getOwnPropertyNames()

一般情況用 Object.keys 就可以滿足到返回自定義 property names,但有時你想得到所有 inherited 嘅 property 比如 Array.prototype.length 又或者 object 本身有 define 咗 non-enumerable property,Object.keys 就滿足唔到。 const 公務員加薪 = { 加幅: 0.025 }; Object.keys(公務員加薪); // ['加幅'] Object.getOwnPropertyNames(公務員加薪); // ['加幅'] // Array const 公務員團體 = ['失望', '驚訝', '要求追回通脹']; Object.keys(公務員團體); // ['0', '1', '2'] Object.getOwnPropertyNames(公務員團體); // ['0', '1', '2', 'length'] // Non-enumerable property Object.defineProperties(公務員加薪, { 林志偉: { enumerable: false, value: '要見特首', }, }); Object.keys(公務員加薪); // ['加幅'] Object.getOwnPropertyNames(公務員加薪); // ['加幅', '林志偉']

July 7, 2022 · 1 min · 70 words · Me
Curse

被詛咒嘅村莊

Stranger Things 第四季好睇,集齊四隻可以打開另一個世界。

July 6, 2022 · 1 min · 3 words · Me
Code screenshot

Javascript中伏記:sorting default behavior

const nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; nums.sort(); // [1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9] 🤯 nums.sort((a, b) => a - b); // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] 😌

July 5, 2022 · 1 min · 50 words · Me
Code screenshot

css 一行 reset 所有 element properties

button { all: unset; } See the Pen css all unset by littlecodeguy (@littlecodeguy) on CodePen.

July 4, 2022 · 1 min · 16 words · Me