CSS
CSS
2022/06/21 (增加連結)
基本概念
CSS (吳濟聰老師web programming網站)
The Programmer’s Guide to the Stylesheet
Position
Gridding
Margin vs padding
Font size
Pseudo-classes
Media queries
Transitions and animations
Sanity tips
Temporary borders everywhere
Generic CSS classes
Keep visual and functional components separate
Essential CSS concepts every designer should know
Parents and children
Margin (personal space)
Padding (fur)
Flexbox (distribution)
Relative vs. absolute
The CSS Handbook: a handy guide to CSS for developers (非常完整的CSS手冊)
3 Easy Ways to Write Better CSS
TRBL
Apply the acronym TRBL (Top, Right, Bottom, Left) anytime you are trying to apply a style of varying dimensions such as padding, margins, and borders.
Shared Attributes
Using commas, you can consolidate shared styles with multiple elements without having to specify those styles multiple times for each element.
Combinators
Combinators can help you can avoid heavy use of class names and id’s in your HTML. This can make your HTML simpler, more flexible, as well as reduce the amount of programmatic operations needed should you want to incorporate JavaScript.
4 CSS Tips for Those Who Hate It
Essentials: Flexbox & Grid
Color Theory: Palleton and Coolors
Scalable CSS: BEM Methodology
A BLOCK is an independent part of a page that can be reused.
An ELEMENT is a part of a block that cannot be used independently of the block.
A MODIFIER is different in that it describes the behavior of the element it is changing.
Let Someone Else Do The Work: CSS Frameworks
4 CSS Tips and Tricks To Supercharge your Development
STOP Using !important: How CSS Hierarchy Works
Use Flexbox
SCSS or BEM scoping
Helper Classes
Top 8 CSS Tricks You’ve Never Used Before : Avoid using JavaScript along with RegEx — when CSS does it all for you!
7 cool and easy CSS tricks I don’t see many developers using
Picking Cursors
Dimming
Vertical Centering
That one thing I regret about my CSS code
Why should outline stay?
Accessibility issue
Keyboard navigation issue
Building a Pure CSS Animated Gradient Colour Button Is Easier Than You Think
How to make a background blur in CSS with one line of code
What is backdrop-filter?
Adding Multiple Filters
ArtBox
Improve Page Rendering Speed Using Only CSS
Content-visibility
Will-change property
Reducing the Render-blocking time
Avoiding @import to include multiple stylesheets
User-Tracking With CSS Only : Device type, operating system & movements on the website
Day/Night Colour Switching Using CSS3 Variables and Minimal Vanilla JavaScript
Properties
4 Key CSS Properties Explained in 4 Minutes
Display
Float
Background
Position
Understand These Two Properties and You’ll Never Fear CSS Again
position、display
You have to start using this CSS property in your websites
env(safe-area-inset-bottom)
10 useful CSS properties you can start using today : Keep up with new CSS features and refresh some old ones
CSS is Magic, It’s Time You Try 3D : CSS 3D transforms
CSS: The Fastest Way to Hide overflow : Should we hide, clip or paint overflows in CSS
4 Exciting New CSS Features in 2022
CSS parent selector :has()
Next CSS Transform
CSS @container
CSS Subgrid of Grid
How I made Google’s data grid scroll 10x faster with one line of CSS
table {
contain: strict;
}
Unit
Stop Using the Pixel Unit in CSS
They Are Just Optical Reference Units
They Are Absolute Values
Accessibility: They Don’t Adapt to the User’s Default Font Size
Your guidebook to CSS Units : An introduction to CSS Units — vh, vw, em, rem, %, px, and more!
Selector
The Ultimate Visual Guide to CSS Selectors : 9 things to understand about writing clean CSS
Adjacent Sibling Selection Combination
Attribute Selectors
Pseudo-Elements
State-Based Pseudo-Classes
Form and Validation Pseudo-Classes
Putting Two Ideas Together — Structural Pseudo-Classes
Miscellaneous Pseudo-Classes
Sidestepping a Little With :target and #someLinkHere
The Fun Side of CSS — nth-child Expression
Cascading: How to make your CSS work
Cascading Stylesheets
Order < Specificity < Inline < !important
element < class < ID < Inline < !important
How selective should I be when choosing selectors for CSS?
Types
Pseudo-elements
Mastering CSS ::before and ::after : A deep dive into the ::before and ::after pseudo-elements in CSS
Classes
Pseudo-classes
Attribute selectors
IDs
In-line styles
Avoid using in-line styles.
Understanding use of the +, >, and ~ symbols in CSS selectors
There are four different combinators in CSS:
Descendant Selector (space)
Child Selector (>)
Adjacent Sibling Selector (+)
General Sibling Selector (~)
div span
CSS Style Rules: Using the Right Terms: What is the proper term for <div> and <span>?
技巧
6 beginner HTML/CSS tips & guidelines to make your life easier
Use keyboard shortcuts
Optimize your development environment
Know and use HTML best practices
Know and use CSS best practices
Use the browser’s developer tools
Use online resources
Things nobody ever taught me about CSS
Terminology
CSS performance
Ordering
Resources
5 Little CSS Tricks to Make Plain Pages Look Awesome
Text Select Color
Drop Caps
Image Overlay
Colorize and Zoom Into Image on Hover
Play With Image Masking
10 cool things you might not know about CSS
The "CSS is awesome" meme
Filters and gradients
Emojis as class names (or ids)
CSS Units
Viewport Units
Alternative unit for rotate
CSS variables
Pointer events
Calc
Shorthand Properties
BEM
8 useful CSS tricks: Parallax images, sticky footers and more
Utility-first CSS: Ridiculously fast front-end development for almost every design
Here’s a List of the Top CSS Front-End Libraries
Ant Design
Foundation
Bulma
Spectre.css
Tailwind CSS
Shoelace
Semantic UI
Skeleton
Tachyons
Material Design
How to Remove Unused CSS: Reduce your CSS files more than 60% during your development workflow with Purgecss.
A solution to The Height Problem?
How Sticky works?
Scrolling
How To Control White Space in Text With CSS
White space within text:
white-space
line-height
text-align, text-indent, text-overflow
word-spacing
vertical-align
White space around text:
height and width
padding and margin
A Primer to Well-Structured CSS
Inverted Triangle CSS (ITCSS) Methodology
BEM Namespacing
Breathable and readable code formatting
Never use IDs for styling
Don’t over-indent
White space is free — use it
Document, document, document
SMACSS / Scalable and Modular Architecture for CSS
OOCSS / Object Oriented CSS
BEM / Block Element Modifier
How to create beautiful Shapes in CSS — A Teardown of 3 Shapes, purely made in CSS
Function
<link rel="stylesheet" href="/path/to/my.css" media="print" onload="this.media='all'">
5 Common CSS mistakes developers make
Using px when it’s not needed
** 建議使用em
Repeating the same code
Using color names
Not using shorthand properties
No font fallback
Top 5 CSS Mistakes To Avoid : Code smells, Browser Support, Pixels Unit, and More
Animations
Creating an animation using keyframes
Adding the animation to an element
Animate web page elements with Keyframes: It’s an extension, not @keyframes
A Simple Way to Create a Hover Animation for Your Buttons Using CSS
Border
Button
How to style the ubiquitous button with CSS: Create 4 common buttons and style them according to their states
Pure CSS to Make a Button “Shine” and Gently Change Colors Over Time
Cache
Chart
Color
Colour variable names that scale (SASS)
with Name that Color
How to Add Color to SVG Icons and Elements With CurrentColor
Box Model
The Box Model is made up of 4 core element
Content - The text, image, or other media content in the element.
Padding- The space between the box’s content and its border.
Borders - The line between the box’s padding and margin.
Margins - The space between the box and surrounding boxes.
The Basic Guide to the CSS Box Model
The Content Area
The Padding Area
The Border Area
The Margin Area
Determining the Size of a Box
By default, the width style in CSS is only applied to the content area, and applying a padding or borderstyle will appear to grow the element.
The box-sizing style
content-box (default)
border-box: use the padding and border sizes in its sizing calculations
Flexbox
How do we define a Flexbox?
Flex Direction
The Flex property
Flex Wrap
Flex Flow
Flex-Basis
Justify-Content
Align-Items
Align-content
Align-Self
Order
Creating a simple form with Flexbox
Making the form with Flexbox
When elements are of unequal height…
How I use CSS Grid and Flexbox to Create a One-page Website: CSS Grid for page layout and Flexbox for UI elements
How I Use CSS Grid and Flexbox to Create a One-Page Website — Part 2
How to Keep Your Footer At the Bottom of The Page, The Easy and Painless Way : with flexbox
Flexbox vs Grid
How To Boost Your CSS Learning
Flexbox、Grid
When you have a loosely defined layout that adapts to the size of your content, it’s recommended to use Flexbox. But when you have a fixed page layout, then it’s better to use the Grid model.
Flexbox vs. CSS Grid : What are the differences between the two and when should you be using them?
How I use CSS Grid and Flexbox to Create a One-page Website: CSS Grid for page layout and Flexbox for UI elements
Dimension
Flexbox is one dimensional (1D)
Grid is two dimensional (2D)
Font
Stop importing Multiple Fonts and Start using Variable Fonts
Link to the Font
Set the Weights
(extra) Change the Weights
Grid
Simple Ways to Fake Masonry in CSS : Building a masonry layout with CSS columns and grid
Use CSS Grid to Make a Fixed Sidebar with Scrollable Main Body
Top 3 CSS Grid Features To Start Using in Production
Grid Template Areas
Grid Gap
MinMax
Houdini
Image
Ways to style text on images in CSS: Six ways of styling, from adjusting opacity of image to adding background colour to text
Add Text on Image
Adjust Opacity or Clarity of Image
Add Background Colour to Text
Change the positioning of Text
Use Colour Blending of Image and Text
Darken Image and Use Light Text
Fix your Images with one line of CSS : CSS object-fit to the rescue!
Layout
Getting Started With CSS Layout
Normal Flow
Floats
Positioning
Flex Layout
Grid Layout
Visual And Document Order
Box Generation
Alignment
Multi-Column Layout
Fragmentation
Selecting Layout Types: How To Choose?
Website Design: Creating the Layout in HTML
Tables — Do Not Do This!
Float — The Classical Way
Flex — The Responsive Way
Grid — The Future
CSS tricks for validating layouts ** 常常有layout問題的同學可以試試這些技巧
Dealing with padding, margins, and layout structure
Update the style for a particular object
Chrome Developer Tools
Misalignment
Link
Menu
Position
How to center things with style in CSS
Text-Align Method
Margin Auto Method
Absolute Positioning Method
Transform/Translate Method
Flexbox Method
Five Ways to Center a Div With CSS
Centering a div horizontally
Text-Align
Margin
Centering a div both horizontally and vertically
Relative positioning
Absolute positioning
Display Flex
This is by far my favorite way of centering anything.
2 Common Problems With CSS Positioning: Static and relative and absolute, oh my!
Let’s Clear Up the Most Confusing Thing in CSS : Simplifying the display and position properties in CSS
Position
static
relative
fixed
absolute
sticky: The sticky property behaves both as fixed and relative
Display
inline
block
inline-block
none
Responsive
Responsive Web Design (吳濟聰老師 系統分析與設計課程教材)
Text
Theme
Time
Tooltips
Transitions
Variables
CSS Variables (Zito-Wolf): Define repeated styles without the use of a preprocessor
CSS Variables (Ming)
CSS Variable Syntax
Declaring a CSS variable
Using the CSS variable
Scopes in CSS Variable
Global Scope
Local Scope
Overriding CSS Variable Values
Setting Fallback Value
Using CSS Variable in JavaScript
Retrieve from inline style
Retrieve from inline or css file
Setting a CSS Variable with JS
5 Levels of Using CSS Variables
Declare a CSS Variable Like a Guru
Read a CSS Variable Properly
Know the Scope of a CSS Variable
Apply Different CSS Variables for Different Screen Sizes
Use JavaScript To Handle CSS Variables
W3.CSS
Getting Started With W3.CSS: Kick start your web-development project via a lightweight and responsive CSS framework called W3.CSS
W3.CSS Advanced Tutorial: Create your own responsive components via a lightweight CSS Framework called W3.CSS
Preprocesssors
LESS
安裝 LESS
起手式
&
import
變數
覆蓋變數
變數載入變數
變數字串結合
@media
mixin
mixin 的計算
把 mixin 當作樣式 class 使用
帶有參數的 mixin
+ 與 +_
extend
用 LESS 寫 CSS ( 判斷式、迴圈、Function )
判斷式
迴圈
function - 獲取圖片尺寸
function - 單位轉換
function - 陣列
function - 數學計算
function - 色彩轉換
Simplify your CSS — LESS is more
The Problems of CSS
LESS is more
using variables
nested statements
mixins
import statements
SASS / SCSS
Sass(Syntactically Awesome StyleSheets)是一種 CSS 的擴充,是為 CSS 的超集合。
Sass 的語法分為新的 SCSS (Sassy CSS、Sass 3,檔案名稱為 *.scss) 和舊的 SASS(向 Haml取經,具備不使用大括弧格式、使用縮排,不能直接使用 CSS 語法、學習曲線較高等特性,檔案名稱為 *.sass)。由於新的 SCSS 語法是 CSS3 的超集合,所以傳統的 CSS3 檔案就算直接複製過來也不會出錯,學習曲線相對較緩,因此我們將使用 SCSS 語法。
The Ultimate Guide to Learning Sass/SCSS : Variables, nesting, partials, modules, mixins, inheritance, operators, and more
What the CSS — Implementing Trigonometry in SCSS, and lessons learnt: CSS, at its core, is a style sheet language. But we can do so much more by using Sass with its SCSS syntax.
Sass finally introduced a new module system and nobody talks about it
工具
5 CSS Build Tools That You Should Know in 2021
Stylelint
Prettier
PurgeCSS
Autoprefixer
cssnano
8 Must-Use CSS Tools For Web Developers
Online-Creation Tools
EnjoyCSS
CSS Arrow Please!
CSSmatic
Patternizer and Patternify
Online-Learning Tools
CSS Grid
Grid Garden
Flexplorer
Image Effects with CSScust
9 Useful CSS Tools for Web Developers
Transition Generator
Transfonter
Flip Switch Generator
Flexbox.help
SASS to CSS
Pure CSS Image Effects
Generating Color Schemes
Style Guide Generator
Darken or Lighten a Certain Color
Stylify.dev. Dynamic CSS Generator for fluent and rapid web development.
10 Code Generation Tools for Web Devs : Front-end tools for creating modern and trendy designs easily
Chrome DevTools
Introduction to Chrome DevTools for CSS
View CSS in both Style and Sources tabs.
Edit and filter in the Style and Computed tabs.
Simulate a mobile viewport.
View unused CSS under the Coverage tab.
View print page.