Rowan Liu's Tech
Home
Blog
CSS
JS
lib
Read
About
GitHub
Home
Blog
CSS
JS
lib
Read
About
GitHub
  • CSS
  • rem
  • CSS 选择器
  • inline-block
  • BFC 块格式化上下文
  • 认识Flex
  • Grid
  • 常用的布局实现
  • 响应式Web设计

CSS 选择器

标签选择器

body {
  color: blue;
}

类选择器

.btn {
  font-size: 14px;
}

后代选择器

.dialog .title {
  line-height: 1.5;
}

id 选择器

#myStyle {
  border: 1px solid #ddd;
}

兄弟选择器

选择紧接在一个元素后的元素,且二者有相同的父元素。

p + p {
  margin-left: 5px;
}

注意事项

.foo.bar
Edit this page
Last Updated: 2026/1/12 10:15
Contributors: Rowan Liu
Prev
rem
Next
inline-block