Open evantianx opened 7 years ago
<mark>
用来指示相关性,比如搜索某个词,将搜索结果中的相同词汇标记出来<small>
一般我们只是用来减小文字大小,而这个标签的真正用法是用来降低权重的<q>
/<blockquote>
引用,小的用<q>
,大的用<blockquote>
,同时可以配合<cite>
来使用<ins>
/<del>
/<s>
<ins>
和<del>
标签都是用来描述更改和删除事件,它们有两个属性cite
(指向更改原因地址)和datetime
(时间) => 可以用timestamp
来代替
<s>
标签用来指明某段文字,链接等已被废弃<optgroup>
将options分组,必须包含于<select>
标签内,有两个属性label
和disabled
<label for="comp-price-filter">
Select the price range of your next computer
</label>
<select
class="price-filter"
name="comp-price-filter"
id="comp-price-filter">
<optgroup label="Low End">
<option value="100-300">$100 - $300</option>
<option value="301-500">$301 - $500</option>
<option value="501-700">$501 - $700</option>
</optgroup>
<optgroup label="Middle Range">
<option value="701-1200">$701 - $1200</option>
<option value="1201-1600">$1201 - $1600</option>
</optgroup>
<optgroup label="High End">
<option value="1600-2500">$1600 - $2500</option>
<option value="2501-3200">$2501 - $3200</option>
</optgroup>
</select>
<datalist>
预选项
<label for="favourite-sites">
Select your favorite website!
</label>
<input
type="url"
name="favourite-sites"
id="favourite-sites"
list="site-list"/>
<datalist id="site-list">
<option value="http://www.google.com.au">
<option value="http://www.reddit.com">
<option value="http://www.sitepoint.com">
</datalist>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--<title>是<head>唯一强制要求的标签-->
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="css/styles.css?v=1.0">
<!--It should be noted that if you’re using a JavaScript library that
deals with HTML5 features or the new APIs, it’s possible that it will
already have the HTML5-enabling script present; in this case,
you could remove reference to the script. One example of this would
be Modernizr, a JavaScript library that detects modern HTML and CSS features.
Modernizr gives you the option to include code that enables the HTML5
elements in older versions of IE, so the shiv would be redundant.
We take a closer look at Modernizr in Appendix A.-->
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<script src="js/scripts.js"></script>
</body>
</html>
作者将debug分为三个阶段:
查找bug可以说是整项Debug流程中最为艰难的一部分。
Ctrl
+Shift
+ N
)在我理解就是隔离某些可疑代码,来筛选出bug的确切位置
修复bug
所谓的Heisenbug
display
吗?display: none
将该元素及其子元素从普通文档流中移除。文档会忽略它的存在来开始渲染,这意味着它所占据的空间会塌陷。屏幕阅读器也会无视该元素的内容。display: inline
元素会生成一个或多个inline水平盒子。display: block
元素会生成一个block水平盒子。所有的block水平元素都会以新的一行开头,水平方向上完全占据其容器的空间。display: list-item
元素为block水平,且可以通过设置list-style
来改变标记样式,位置等。display: inline-block
可以保持在同一行的块级元素
display: flex
display: grid
display: run-in
display: ruby
display: contents
The element itself does not generate any boxes, but its children and pseudo-elements still generate boxes as normal. For the purposes of box generation and layout, the element must be treated as if it had been replaced with its children and pseudo-elements in the document tree. —— CSS Display Module Level 3
Evolution of CSS Layout: 1990s to the Future How Browsers Work: Behind the scenes of modern web browsers
border-radius
属性可以使用斜杠语法
譬如:
.box {
border-radius: 35px 25px 30px 20px / 35px 30px 20px 25px;
}
官方文档中这样写道:
If values are given before and after the slash, then the values before the slash set the horizontal radius and the values after the slash set the vertical radius. If there is no slash, then the values set both radii equally.
font-weight
可以接受相关关键字
不仅可以设置为normal
,bold
或者是数字,还可以设置为border
和lighter
。
One font weight darker/lighter than the parent element (among the available weights of the font).
outline-offset
属性
以前只了解outline
这个属性:
Outlines differ from borders in the following ways:
- Outlines do not take up space, they are drawn above the content.
- Outlines may be non-rectangular. They are rectangular in Gecko/Firefox. But e.g. Opera draws a non-rectangular shape around a construct。(类似于包裹) 而
outline-offset
就是用来规定outline
与内容区域之间的距离,需要说明的一点是outline-offset
需要单独设定,不包括在outline
缩写之中。
table-layout
调整表格内容布置
vertical-align
When not applied to table cells, the vertical-align property follows these basic rules:
- It works only on inline or inline-block elements.
- It has no effect on the contents of an element but instead it changes the alignment of the element itself in relation to other inline or inline-block elements.
- It can be affected by text/font settings like line-height and by the size of adjacent inline or inline-block elements.
::first-letter
智能,不是很简单的取第一个字母
在HTML类名中可以使用非法字符
动画循环次数可以使用小数值
animation-iteration-count
的值不仅可以使用整数,还可以使用分数
动画属性简写时可能会因为动画名字而无法运行
@keyframes reverse {
from {
left: 0;
}
to {
left: 300px;
}
}
.example {
animation: reverse 2s 1s;
}
上述动画无法运行,因为reverse是animation-direction
的一个有效值,而将其作为动画名传给animation
属性简写,则会造成无法运行的情况(在不缩写的情况下可以运行)
可以选择一定范围的元素
/*选择7到14的元素*/
ol li:nth-child(n+7):nth-child(-n+14) {
background: lightpink;
}
To explain exactly what this is doing: In the first part of the chain, the expression says “select the 7th element, then every element after that”. The second part says “select the 14th element, and every element before that.” But since the selectors are chained, each limits the previous one’s scope. So the second part of the chain doesn’t allow the first part to go past 14 and the first part of the chain doesn’t allow the second part to go back past 7.
伪元素可以被应用于空元素 伪元素只能应用于非替换元素,而可以应用在某些空元素(无闭合标签)之上
某些属性值在选择器下是大小写敏感的
The issue is: how do we make a full-browser-width container when we're inside a limited-width parent?
以下为默认代码:
<!-- parent -->
<main>
<p>Stuff.</p>
<!-- container we want to be full width -->
<figure class="full-width">
<!-- could be whatever content -->
<img src="dog.jpg" alt="">
</figure>
</main>
那么我们就可以按照比例将container撑开:
main {
width: 60%;
margin: 0 auto;
/* creates 20% margins on either side */
}
.full-width {
/* 1/3 of 60% = the 20% margin on either side */
margin-left: -33.33%;
margin-right: -33.33%;
}
The amount we want to "pull" to the left and right is half the width of the browser window plus half the width of the parent. (Assuming the parent is centered.)
@media (min-width: 500px) { main { width: 500px; margin: 0 auto; } .full-width { margin-left: calc(-100vw / 2 + 500px / 2); margin-right: calc(-100vw / 2 + 500px / 2); } }
也可以使用
translate
属性:@media (min-width: 40em) { .full-width { width: 100vw; transform: translateX(calc((40em - 100vw)/2)); } }
更兼容的写法:
/*把回退样式写在该样式前面*/ @supports (width: 100vw) { .full-width { width: 100vw; } @media all and (min-width: 40rem) { .full-width { transform: translateX(calc((40rem - 100vw)/2)); } } }
据测试在Edge下无效,在Chrome下偶尔会应用,只有在FF下正常。
clac()
首先用left:50%
将container左侧边缘置于屏幕正中央,然后利用margin-left: -50vw
将其拉伸到左屏幕边缘:
.full-width {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}
需要设定right:50%
和margin-right: -50vw
的原因是,有可能网页设置了direction: rtl
。所以如上设置更为保险。
需要注意的是此方法同上述方法都需要父级元素完全居中
待读
“Program to an interface, not an implementation.” ——Design Patterns: Elements of Reusable Object Oriented Software
12个Chrome调试知识
Animation inspection 设置速度以检视动画,拖动可以到达某一帧,做动画的时候很有用
设备截图 通过开启
show device frame
,然后点击Capture screenshot
即可得到一个带有相应手机壳的截图console中的$0 在Console面板中输入
$0
,会给出你在Element
面板中选中元素的DOM形式展现的对象。若希望展现为JS对象格式,可以输入console.dir($0)
console中的箭头函数 主要是可以减少
Shift
+Enter
次数,文中还强调了在Chrome 56版本后,有一个特性smart return
可以在你按下Enter
后智能识别是需要换行还是执行代码(某些特定场景下才有效,如写循环的时候)选择器搜索 在Element面板中按下
Ctrl
+F
进行搜索,可以按照字符串,选择器以及XPath进行搜索调试颜色 可以使用吸管吸取颜色,或者选择页面已存在的某个颜色等等
检测被渲染的字体 在Element面板下Computed一栏中可以找到Rendered Fonts,在这里可以看到哪些字体被渲染
直接修改页面中的文字 在Console面板输入
document.designMode = 'on'
即可开启编辑模式,此时就可以随意编辑网页上的所有文字。Filmstrip 在Network面板中开启
Capture screenshots
可以记录网站从载入到完成的快照,双击查看快照。network面板下的过滤筛选 通过filter可以筛选资源列表,下方是资源类型,也可以通过域名domain来筛选。
黑色主题 在preference中选择主题
snippets