学习笔记:前端基础查缺补漏(一)

来源于从网页搭建入门Java Web

好多基础的东西都忘记了,补起来!!


HTML基础

  • 锚点
1
2
<a href="#aaa"></a>
<div id="aaa"></div>
  • a标签禁止跳转
1
2
<a href="javascript:;"></a>
<a href="javascript:void(0);"></a>
  • 预格式标签
1
<pre>Code ...</pre>
  • 引用标签
1
<blockquote></blockquote>
  • 表格

相关的几个标签记熟了呀,用库都用忘了 table, thead, tbody, th, tr, td

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
margin: 0;
}
table {
margin: 0;
width: 100vw;
}
table, tr, th, td {
border: 1px solid #0e0000;
border-collapse: collapse;
padding: 5px;
}
</style>
</head>

<body>
<div>
<table>
<thead>
<tr>
<th>省份</th>
<th>城市</th>
<th>温度</th>
</tr>
</thead>
<tbody>
<tr>
<td>北京</td>
<td>北京</td>
<td>6</td>
</tr>
<tr>
<td rowspan="2">河北</td>
<td>石家庄</td>
<td>10</td>
</tr>
<tr>
<td>保定</td>
<td>7</td>
</tr>
<tr>
<td rowspan=2>福建</td>
<td>福州</td>
<td>18</td>
</tr>
<tr>
<td>厦门</td>
<td>22</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
  • button标签 type=“reset” 重置表单中的值

  • <select> 标签中 设置了multiple或size属性的话select是列表了,不是下拉菜单,不设置是下拉菜单,所以代码实现了一个列表,multiple多选,size显示可见选项数目,效果是这样的


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
select {
width: 200px;
height: 100px;
}

option {
padding: 10px;
text-align: center;
font-size: 1.2em;
background: #f0f0f0;
/* height: 50px; */
border: 1px solid #555;
}

</style>
</head>

<body>
<select name="city" size="2" multiple>
<option value="aa">aa</option>
<option value="bb">bb</option>
<option value="cc">cc</option>
<option value="cc">dd</option>
<option value="cc">ee</option>
<option value="cc">ff</option>
<option value="cc">gg</option>
</select>
</body>

</html>
  • form属性:enctype 提交的编码

CSS基础

  • 属性选择器 最基本:[属性] {…} ,还有更多的用法

  • 关系选择器

    • A E
      • E为A的子节点
    • A > E
      • E为A的直系子节点
    • B + E
      • B的任一下一个兄弟元素E
  • 伪元素

    • ::before
    • ::after

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
q::before {
content: "<<";
color: black;
}
q::after {
content: ">>";
color: black;
}
</style>
</head>
<body>
<q>海底两万里</q>
<q>上下五千年</q>
</body>
</html>
  • 选择器优先级

    • 行内样式 +1000
    • 一个id +100
    • 一个属性选择器/class或者伪类 +10
    • 一个元素名,或者伪元素 +1
    • !important 压倒一切
  • 如果background-position中如果仅规定了一个关键词,那么第二个值将是”center”。

  • 自定义字体样式

1
2
3
4
5
6
@front-face {
font-family: ...;
src: url() format();
font-weight: ...;
font-style: ...;
}
  • 关于字体大小

p标签的字体大小设置的值是1.5em,它的字体大小是其父元素div的1.5倍,是30px;

span标签的字体大小设置的值是150%,是它的父元素p标签的1.5倍,那么就是45px

  • 两行三列布局,使用浮动效果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
html,
body {
margin: 0;
}

header {
width: 100%;
height: 100px;
background-color: beige;
}

#container {
width: 100%;
height: 300px;
background-color: cadetblue;
}

nav {
width: 100px;
height: 100%;
background-color: aliceblue;
float: left;
}

aside {
width: 300px;
height: 100%;
background-color: brown;
float: right;
}

</style>
</head>

<body>
<header></header>
<div id="container">
<nav></nav>
<aside></aside>
<article>aaaaaaaa</article>
</div>
</body>

</html>
  • 三行两列布局

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
html,
body {
margin: 0;
}

header {
width: 100%;
height: 50px;
background-color: antiquewhite;
}
#container {
width: 100%;
height: 400px;
background-color: blue;
}
footer {
width: 100%;
height: 100px;
background-color: bisque;
}
nav {
width: 100px;
height: 100%;
float: left;
background-color: cornflowerblue;
}
article {
margin-left: 100px;
height: 100%;
background-color: aqua;
}
</style>
</head>

<body>
<header></header>
<div id="container">
<nav></nav>
<article></article>
</div>
<footer></footer>
</body>

</html>