6、轮播图之rem|原生|jQuery、table表格(合并嵌套、固定栏、滑动栏、滚动条)、js画曲线、验证码 、发电报、css汇总(光标、改查、滚动条、兄弟叠加、tabIndex和a标签、清除浮动、悬停改样式、媒体查询、BEM、栅格布局、图片撑开盒子、变量--var、密码禁用、半包围、显式隐式点击事件、旋转正方体、太极图、单词破单词裹省略号、符号图标、伪类伪元素、三角形箭头)(2750行)

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
一、rem版轮播图
  <!DOCTYPE html>
  <html lang="en">
  <head>
      <meta charset="UTF-8">
      <title>rem版轮播图</title>
      <style>
          *{
              margin:0;
              padding:0;
          }
          html{
            font-size: 20px;
          }
          @keyframes aaa {
              from {left:0;}
              to {left:-400rem;}
          }
          #aaa{
              margin:0 auto;
              width:80rem;
              height:40rem;
              overflow: hidden;
              position: relative;
              background: red;
          }
          #bbb{
              position: absolute;
              width:400rem;
              height:40rem;
          }
          #bbb div{
              width:80rem;
              height:40rem;
              float:left;
          }
          #bbb div img{
              width:100%;
              height:100%;
          }
          #bbb:hover{
              animation: aaa 15s ease-in 0.5s infinite;
          }
      </style>
  </head>
  <body>
  <div id="aaa">
      <div id="bbb">
          <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517838828_mthumb.jpg" alt=""/></div>
          <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517841171_mthumb.jpg" alt=""/></div>
          <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517843343_mthumb.jpg" alt=""/></div>
          <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517845828_mthumb.jpg" alt=""/></div>
          <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517848093_mthumb.jpg" alt=""/></div>
          <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517850750_mthumb.jpg" alt=""/></div>
      </div>
  </div>
  <div style="text-align: center;font-size: 4rem;">将鼠标置于图片之上,图片就开始轮播</div>
  </body>
  </html>
 
二、原生版轮播图(面对对象)
1、代码分两个部分:
  (1)HTML部分,根据注释处理即可;
  (2)play.js插件部分,这里为了展示效果,直接写在<html></html>下的<script></script>标签里。
  (3)效果包含:自动轮播,焦点对齐,前进后退,直走不返,鼠标进入、轮播停止且前进后退图标出现,鼠标离开、轮播重启且前进后退图标隐藏。
  (4)这里可以预览效果。
2、轮播图原理说明:
  (1)轮播图(假设)有7张图片,“一”字排列,把第1张图片复制一次,放到第8张的位置,这样共有8张图片;轮播开始后,
  (2)整个第2秒内,第2张图片从开始出现到完全出现,耗时700毫秒,完全出现后再停留300毫秒;
  (3)整个第3秒内,第3张图片从开始出现到完全出现,耗时700毫秒,完全出现后再停留300毫秒;以此类推
  (4)整个第8秒内,第8张图片从开始出现到完全出现,耗时700毫秒,完全出现后再停留300毫秒;注意
  (5)整个第9秒内,轮播图急速回到第1张图片完全出现的状态,耗时约0毫秒(即运行autoMove方法中if语句块的耗时),然后立即开始(2)步骤。
3、使用时,id="boxQC",这个id不能改动;"可增减区域"里的div可增可减;new Banner('1000px', '500px'),这里的参数可以变化。
  (1)写法一:Banner.prototype={}
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>/*style标签及其内的内容,在实际项目中可以不要*/
        * {
            margin: 0;
            padding: 0;
        }
        </style>
    </head>
    <body>
    <!--body标签里的内容,没说可以增减或更改的,不要增减或更改-->
    <div id="boxQC">
        <div>
            <!--以下是可增减区域-->
            <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517838828_mthumb.jpg" alt=""/></div>
            <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517841171_mthumb.jpg" alt=""/></div>
            <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517843343_mthumb.jpg" alt=""/>
            </div>
            <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517845828_mthumb.jpg" alt=""/>
            </div>
            <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517848093_mthumb.jpg" alt=""/>
            </div>
            <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517850750_mthumb.jpg" alt=""/>
            </div>
            <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517853171_mthumb.jpg" alt=""/>
            </div>
            <!--以上是可增减区域-->
        </div>
    </div>
    </body>
    </html>
    <script>
        function Banner(width, height) {/*类*/
            /*以下最外层div*/
            var that = this;
            this.width = width;
            this.height = height;
            this.oBox = document.getElementById("boxQC");
            this.oBox.style.width = width;
            this.oBox.style.height = height;
            this.oBox.style.margin = "0 auto";
            this.oBox.style.overflow = "hidden";
            this.oBox.style.position = "relative";
            /*以下轮播区的div*/
            this.oBoxInner = this.oBox.getElementsByTagName('div')[0];
            this.oBoxInner.style.height = height;
            this.oBoxInner.style.position = "absolute";
            this.oBoxInner.style.left = 0;
            this.oBoxInner.style.right = 0;
            this.aDiv = this.oBoxInner.getElementsByTagName('div');//单个轮播图
            this.oBoxInner.innerHTML/* 轮播区的内部后面*/ += this.aDiv[0].outerHTML/*第一个轮播图片的外部*/;
            this.oBoxInner.style.width = parseFloat(width) * this.aDiv.length + "px";//轮播区的宽度
            for (var i = 0; i < this.aDiv.length; i++) {/*遍历轮播区的每个div及其内部的图片*/
                this.aDiv[i].style.width = width;
                this.aDiv[i].style.height = height;
                this.aDiv[i].style.float = "left";
                this.aDiv[i].aImg = this.aDiv[i].getElementsByTagName('img')[0];
                this.aDiv[i].aImg.style.width = "100%";
                this.aDiv[i].aImg.style.height = "100%";
            }
            /*以下是焦点区部分(定位在轮播区的右下方)*/
            var oUl = document.createElement('ul');
            for (i = 0; i < this.aDiv.length - 1; i++) {
                oUl.innerHTML += '<li class=' + i + '===1?"on":null></li>';
            }
            this.oBox.appendChild(oUl);
            this.oUl = this.oBox.getElementsByTagName('ul')[0];
            this.oUl.style.position = "absolute";
            this.oUl.style.right = "10px";
            this.oUl.style.bottom = "10px";
            this.aLi = this.oUl.getElementsByTagName('li');
            for (i = 0; i < this.aLi.length; i++) {/*遍历焦点区的每个焦点*/
                this.aLi[i].style.width = "18px";
                this.aLi[i].style.height = "18px";
                this.aLi[i].style.float = "left";
                this.aLi[i].style.listStyle = "none";
                this.aLi[i].style.background = "green";
                this.aLi[i].style.borderRadius = "50%";
                this.aLi[i].style.marginLeft = "10px";
                this.aLi[i].style.cursor = "pointer";
                this.aLi[i].index = i;
                this.aLi[i].onclick = function () {
                    that.step = this.index;
                    that.animate(that.oBoxInner, {left: -that.step * parseFloat(that.width)});
                    that.bannerTip();
                }
            }
            /*以下是向左向右两个箭头式按钮*/
            for (i = 0; i < 2; i++) {
                var oA = document.createElement('a');
                oA.href = "javascript:;"
                this.oBox.appendChild(oA);
            }
            /*以下是左按钮(点击它,图片向左运动)*/
            this.oBtnL = this.oBox.getElementsByTagName('a')[0];
            this.oBtnL.style.width = "30px";
            this.oBtnL.style.height = "30px";
            this.oBtnL.style.position = "absolute";
            this.oBtnL.style.top = (parseFloat(this.height) / 2 - 15) + "px";
            this.oBtnL.style.left = "30px";
            this.oBtnL.style.border = "10px solid red";
            this.oBtnL.style.borderLeft = "none";
            this.oBtnL.style.borderBottom = "none";
            this.oBtnL.style.opacity = "0.3";
            this.oBtnL.style.filter = "alpha(opacity=30)";
            this.oBtnL.style.display = "none";
            this.oBtnL.style.transform = "rotate(-135deg)";
            this.oBtnL.onclick = function () {
                if (that.step <= 0) {
                    that.step = that.aDiv.length - 1;
                    that.css(that.oBoxInner, 'left', -that.step * parseFloat(that.width));
                }
                that.step--;
                that.animate(that.oBoxInner, {left: -that.step * parseFloat(that.width)});
                that.bannerTip();
            };
            /*以下是右按钮(点击它,图片向右运动)*/
            this.oBtnR = this.oBox.getElementsByTagName('a')[1];
            this.oBtnR.style.width = "30px";
            this.oBtnR.style.height = "30px";
            this.oBtnR.style.position = "absolute";
            this.oBtnR.style.top = (parseFloat(this.height) / 2 - 15) + "px";
            this.oBtnR.style.right = "30px";
            this.oBtnR.style.border = "10px solid red";
            this.oBtnR.style.borderLeft = "none";
            this.oBtnR.style.borderBottom = "none";
            this.oBtnR.style.opacity = "0.3";
            this.oBtnR.style.filter = "alpha(opacity=30)";
            this.oBtnR.style.display = "none";
            this.oBtnR.style.transform = "rotate(45deg)";
            this.oBtnR.onclick = function () {
                if (that.step >= that.aDiv.length - 1) {
                    that.step = 0;
                    that.css(that.oBoxInner, 'left', 0)
                }
                that.step++;
                that.animate(that.oBoxInner, {left: -that.step * parseFloat(that.width)}, 1000);
                that.bannerTip();
            };
            /*以下是其它*/
            this.step = 0;//记录每次运动
            this.timer = null;//定时器
            this.init();//初始化轮播图
        }
        Banner.prototype = {//类的原型
            constructor: Banner,
            /*getCss:获取元素的属性值*/
            getCss: function (curEle, attr) {
                var val = null;
                var reg = null;
                if (getComputedStyle) {//标准浏览器
                    val = getComputedStyle(curEle, false)[attr];
                } else {//非标准浏览器
                    if (attr === 'opacity') {
                        val = curEle.currentStyle.filter; //'alpha(opacity=10)'
                        reg = /^alpha\(opacity[=:](\d+)\)$/i;
                        return reg.test(val) ? reg.exec(val)[1] / 100 : 1;
                    }
                    val = curEle.currentStyle[attr];
                }
                reg = /^[+-]?((\d|([1-9]\d+))(\.\d+)?)(px|pt|rem|em)$/i;
                return reg.test(val) ? parseInt(val) : val;
            },
            /*setCss:设置元素的属性值*/
            setCss: function (curEle, attr, value) {
                if (attr === 'float') {
                    curEle.style.cssFloat = value;
                    curEle.style.styleFloat = value;
                    return;
                }
                if (attr === 'opacity') {
                    curEle.style.opacity = value;
                    curEle.style.filter = 'alpha(opacity=' + (value * 100) + ')';
                    return;
                }
                var reg = /^(width|height|top|right|bottom|left|((margin|padding)(top|right|bottom|left)?))$/i;
                if (reg.test(attr)) {
                    if (!(value === 'auto' || value.toString().indexOf('%') !== -1)) {
                        value = parseFloat(value) + 'px';
                    }
                }
                curEle.style[attr] = value;
            },
            /*setGroupCss:设置元素的一组属性值*/
            setGroupCss: function (curEle, options) {
                if (options.toString() !== '[object Object]') return;
                for (var attr in options) {
                    this.setCss(curEle, attr, options[attr]);
                }
            },
            /*css:getCss、setCss、setGroupCss的合写*/
            css: function () {
                if (typeof arguments[1] === 'string') {
                    if (typeof  arguments[2] === 'undefined') {
                        return this.getCss(arguments[0], arguments[1]);//当第三个参数不存在,是获取;
                    } else {
                        this.setCss(arguments[0], arguments[1], arguments[2]);//当第三个参数存在时,是设置;
                    }
                }
                if (arguments[1].toString() === '[object Object]') {
                    this.setGroupCss(arguments[0], arguments[1]);//设置元素的一组属性值
                }
            },
            /*animate:轮播图动画函数*/
            /*定时器1里有自动播放,自动播放里有animation,animation里面又有定时器2:
            定时器1里设置的时间>参数时间duration,
            如果animate里不声明step变量step,里面使用step的地方,值不一致,
            那么就会导致animation运行一次所需要的时间不等于duration。
            */
            animate: function (curEle, target, duration) {
                /*1.定义动画的运行轨迹*/
                function tmpEffect(t, b, c, d) {
                    return b + c / d * t;//开始时的位置+总变化/总时间*已经过去的时间
                }
 
                /*2.为公式的每个参数做准备*/
                var begin = {};
                var change = {};
                for (var attr in target) {
                    begin[attr] = this.css(curEle, attr);
                    change[attr] = target[attr] - begin[attr];
                }
                duration = duration || 700;
                var time = 0;
                var that = this;
                var step = 10;
                /*初稿这里没有这个声明*/
                /*3.开启一个定时器,让时间不断累加;根据时间和公式,求出最新的位置;*/
                clearInterval(curEle.timer); //开起一个定时器前,先关闭没用的定时器
                curEle.timer = setInterval(function () {
                    time += step;
                    /*4.定时器停止运动的条件(time>=duration)*/
                    if (time >= duration) {
                        that.css(curEle, target);
                        clearInterval(curEle.timer);
                        return;
                    }
                    /*5.拿到每个属性的最新值,并且赋值给元素对应的属性;*/
                    for (var attr in target) {
                        /*现在位置=开始位置+总距离/参数时间duration*time*/
                        var curPos = tmpEffect(time, begin[attr], change[attr], duration);
                        that.css(curEle, attr, curPos);
                    }
                }, step)
            },
            /*初始化轮播图*/
            init: function () {
                var that = this;
                /*1.开启自动轮播*/
                /*定时器1里有自动播放,自动播放里有animation,animation里面又有定时器2:
                定时器1里设置的时间>参数时间duration,
                如果animate里不声明step变量step,里面使用step的地方,值不一致,
                那么就会导致animation运行一次所需要的时间不等于duration。
                */
                this.timer = setInterval(function () {
                    that.autoMove();
                }, 2000);
                /*2.开启焦点,每个焦点与每张轮播图对应*/
                this.bannerTip();
                /*3.鼠标移入轮播区,轮播暂停;鼠标移出轮播区,轮播恢复*/
                this.overOut();
            },
            autoMove: function () {
                if (this.step >= this.aDiv.length - 1) {
                    this.step = 0;
                    this.css(this.oBoxInner, 'left', 0)
                }
                this.step++;
                this.animate(this.oBoxInner, {left: -this.step * parseFloat(this.width)}, 1000);
                this.bannerTip();
            },
            bannerTip: function () {
                var tmpStep = this.step >= this.aLi.length ? 0 : this.step;
                for (var i = 0; i < this.aLi.length; i++) {
                    this.aLi[i].className = i === tmpStep ? 'on' : null;
                    if (this.aLi[i].className === "on") {
                        this.aLi[i].style.background = "red";
                    } else {
                        this.aLi[i].style.background = "green";
                    }
                }
            },
            overOut: function () {
                var that = this;
                that.oBox.onmouseover = function () {
                    clearInterval(that.timer);
                    that.oBtnL.style.display = 'block';
                    that.oBtnR.style.display = 'block';
                };
                that.oBox.onmouseout = function () {
                    that.timer = setInterval(function () {
                        that.autoMove()
                    }, 2000);
                    that.oBtnL.style.display = 'none';
                    that.oBtnR.style.display = 'none';
                }
            }
        };
    </script>
    <script>
        new Banner('1000px', '500px');
        /*这两个参数分别是轮播区的宽和高,可以根据需要更改*/
    </script>
    (2)写法二:Banner.prototype.
      <!DOCTYPE html>
      <html lang="en">
      <head>
          <meta charset="UTF-8">
          <title></title>
          <style>/*style标签及其内的内容,在实际项目中可以不要*/
          * {
              margin: 0;
              padding: 0;
          }
          </style>
      </head>
      <body>
      <!--body标签里的内容,没说可以增减或更改的,不要增减或更改-->
      <div id="boxQC">
          <div>
              <!--以下是可增减区域-->
              <div><img
                      src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517838828_mthumb.jpg"
                      alt=""/></div>
              <div><img
                      src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517841171_mthumb.jpg"
                      alt=""/></div>
              <div><img
                      src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517843343_mthumb.jpg"
                      alt=""/>
              </div>
              <div><img
                      src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517845828_mthumb.jpg"
                      alt=""/>
              </div>
              <div><img
                      src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517848093_mthumb.jpg"
                      alt=""/>
              </div>
              <div><img
                      src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517850750_mthumb.jpg"
                      alt=""/>
              </div>
              <div><img
                      src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517853171_mthumb.jpg"
                      alt=""/>
              </div>
              <!--以上是可增减区域-->
          </div>
      </div>
      </body>
      </html>
      <script>
          function Banner(width, height) {/*类*/
              /*以下最外层div*/
              var that = this;
              this.width = width;
              this.height = height;
              this.oBox = document.getElementById("boxQC");
              this.oBox.style.width = width;
              this.oBox.style.height = height;
              this.oBox.style.margin = "0 auto";
              this.oBox.style.overflow = "hidden";
              this.oBox.style.position = "relative";
              /*以下轮播区的div*/
              this.oBoxInner = this.oBox.getElementsByTagName('div')[0];
              this.oBoxInner.style.height = height;
              this.oBoxInner.style.position = "absolute";
              this.oBoxInner.style.left = 0;
              this.oBoxInner.style.right = 0;
              this.aDiv = this.oBoxInner.getElementsByTagName('div');//单个轮播图
              this.oBoxInner.innerHTML/* 轮播区的内部后面*/ += this.aDiv[0].outerHTML/*第一个轮播图片的外部*/;
              this.oBoxInner.style.width = parseFloat(width) * this.aDiv.length + "px";//轮播区的宽度
              for (var i = 0; i < this.aDiv.length; i++) {/*遍历轮播区的每个div及其内部的图片*/
                  this.aDiv[i].style.width = width;
                  this.aDiv[i].style.height = height;
                  this.aDiv[i].style.float = "left";
                  this.aDiv[i].aImg = this.aDiv[i].getElementsByTagName('img')[0];
                  this.aDiv[i].aImg.style.width = "100%";
                  this.aDiv[i].aImg.style.height = "100%";
              }
              /*以下是焦点区部分(定位在轮播区的右下方)*/
              var oUl = document.createElement('ul');
              for (i = 0; i < this.aDiv.length - 1; i++) {
                  oUl.innerHTML += '<li class=' + i + '===1?"on":null></li>';
              }
              this.oBox.appendChild(oUl);
              this.oUl = this.oBox.getElementsByTagName('ul')[0];
              this.oUl.style.position = "absolute";
              this.oUl.style.right = "10px";
              this.oUl.style.bottom = "10px";
              this.aLi = this.oUl.getElementsByTagName('li');
              for (i = 0; i < this.aLi.length; i++) {/*遍历焦点区的每个焦点*/
                  this.aLi[i].style.width = "18px";
                  this.aLi[i].style.height = "18px";
                  this.aLi[i].style.float = "left";
                  this.aLi[i].style.listStyle = "none";
                  this.aLi[i].style.background = "green";
                  this.aLi[i].style.borderRadius = "50%";
                  this.aLi[i].style.marginLeft = "10px";
                  this.aLi[i].style.cursor = "pointer";
                  this.aLi[i].index = i;
                  this.aLi[i].onclick = function () {
                      that.step = this.index;
                      that.animate(that.oBoxInner, {left: -that.step * parseFloat(that.width)});
                      that.bannerTip();
                  }
              }
              /*以下是向左向右两个箭头式按钮*/
              for (i = 0; i < 2; i++) {
                  var oA = document.createElement('a');
                  oA.href = "javascript:;"
                  this.oBox.appendChild(oA);
              }
              /*以下是左按钮(点击它,图片向左运动)*/
              this.oBtnL = this.oBox.getElementsByTagName('a')[0];
              this.oBtnL.style.width = "30px";
              this.oBtnL.style.height = "30px";
              this.oBtnL.style.position = "absolute";
              this.oBtnL.style.top = (parseFloat(this.height) / 2 - 15) + "px";
              this.oBtnL.style.left = "30px";
              this.oBtnL.style.border = "10px solid red";
              this.oBtnL.style.borderLeft = "none";
              this.oBtnL.style.borderBottom = "none";
              this.oBtnL.style.opacity = "0.3";
              this.oBtnL.style.filter = "alpha(opacity=30)";
              this.oBtnL.style.display = "none";
              this.oBtnL.style.transform = "rotate(-135deg)";
              this.oBtnL.onclick = function () {
                  if (that.step <= 0) {
                      that.step = that.aDiv.length - 1;
                      that.css(that.oBoxInner, 'left', -that.step * parseFloat(that.width));
                  }
                  that.step--;
                  that.animate(that.oBoxInner, {left: -that.step * parseFloat(that.width)});
                  that.bannerTip();
              };
              /*以下是右按钮(点击它,图片向右运动)*/
              this.oBtnR = this.oBox.getElementsByTagName('a')[1];
              this.oBtnR.style.width = "30px";
              this.oBtnR.style.height = "30px";
              this.oBtnR.style.position = "absolute";
              this.oBtnR.style.top = (parseFloat(this.height) / 2 - 15) + "px";
              this.oBtnR.style.right = "30px";
              this.oBtnR.style.border = "10px solid red";
              this.oBtnR.style.borderLeft = "none";
              this.oBtnR.style.borderBottom = "none";
              this.oBtnR.style.opacity = "0.3";
              this.oBtnR.style.filter = "alpha(opacity=30)";
              this.oBtnR.style.display = "none";
              this.oBtnR.style.transform = "rotate(45deg)";
              this.oBtnR.onclick = function () {
                  if (that.step >= that.aDiv.length - 1) {
                      that.step = 0;
                      that.css(that.oBoxInner, 'left', 0)
                  }
                  that.step++;
                  that.animate(that.oBoxInner, {left: -that.step * parseFloat(that.width)}, 1000);
                  that.bannerTip();
              };
              /*以下是其它*/
              this.step = 0;//记录每次运动
              this.timer = null;//定时器
              this.init();//初始化轮播图
          }
          Banner.prototype.getCss = function (curEle, attr) {/*getCss:获取元素的属性值*/
              var val = null;
              var reg = null;
              if (getComputedStyle) {//标准浏览器
                  val = getComputedStyle(curEle, false)[attr];
              } else {//非标准浏览器
                  if (attr === 'opacity') {
                      val = curEle.currentStyle.filter; //'alpha(opacity=10)'
                      reg = /^alpha\(opacity[=:](\d+)\)$/i;
                      return reg.test(val) ? reg.exec(val)[1] / 100 : 1;
                  }
                  val = curEle.currentStyle[attr];
              }
              reg = /^[+-]?((\d|([1-9]\d+))(\.\d+)?)(px|pt|rem|em)$/i;
              return reg.test(val) ? parseInt(val) : val;
          },
          Banner.prototype.setCss = function (curEle, attr, value) {/*setCss:设置元素的属性值*/
              if (attr === 'float') {
                  curEle.style.cssFloat = value;
                  curEle.style.styleFloat = value;
                  return;
              }
              if (attr === 'opacity') {
                  curEle.style.opacity = value;
                  curEle.style.filter = 'alpha(opacity=' + (value * 100) + ')';
                  return;
              }
              var reg = /^(width|height|top|right|bottom|left|((margin|padding)(top|right|bottom|left)?))$/i;
              if (reg.test(attr)) {
                  if (!(value === 'auto' || value.toString().indexOf('%') !== -1)) {
                      value = parseFloat(value) + 'px';
                  }
              }
              curEle.style[attr] = value;
          },
          Banner.prototype.setGroupCss = function (curEle, options) {/*setGroupCss:设置元素的一组属性值*/
              if (options.toString() !== '[object Object]') return;
              for (var attr in options) {
                  this.setCss(curEle, attr, options[attr]);
              }
          },
          Banner.prototype.css = function () {/*css:getCss、setCss、setGroupCss的合写*/
              if (typeof arguments[1] === 'string') {
                  if (typeof  arguments[2] === 'undefined') {
                      return this.getCss(arguments[0], arguments[1]);//当第三个参数不存在,是获取;
                  } else {
                      this.setCss(arguments[0], arguments[1], arguments[2]);//当第三个参数存在时,是设置;
                  }
              }
              if (arguments[1].toString() === '[object Object]') {
                  this.setGroupCss(arguments[0], arguments[1]);//设置元素的一组属性值
              }
          },
          /*animate:轮播图动画函数*/
          /*定时器1里有自动播放,自动播放里有animation,animation里面又有定时器2:
          定时器1里设置的时间>参数时间duration,
          如果animate里不声明step变量step,里面使用step的地方,值不一致,
          那么就会导致animation运行一次所需要的时间不等于duration。
          */
          Banner.prototype.animate = function (curEle, target, duration) {
              /*1.定义动画的运行轨迹*/
              function tmpEffect(t, b, c, d) {
                  return b + c / d * t;//开始时的位置+总变化/总时间*已经过去的时间
              }
              /*2.为公式的每个参数做准备*/
              var begin = {};
              var change = {};
              for (var attr in target) {
                  begin[attr] = this.css(curEle, attr);
                  change[attr] = target[attr] - begin[attr];
              }
              duration = duration || 700;
              var time = 0;
              var that = this;
              var step = 10;
              /*初稿这里没有这个声明*/
              /*3.开启一个定时器,让时间不断累加;根据时间和公式,求出最新的位置;*/
              clearInterval(curEle.timer); //开起一个定时器前,先关闭没用的定时器
              curEle.timer = setInterval(function () {
                  time += step;
                  /*4.定时器停止运动的条件(time>=duration)*/
                  if (time >= duration) {
                      that.css(curEle, target);
                      clearInterval(curEle.timer);
                      return;
                  }
                  /*5.拿到每个属性的最新值,并且赋值给元素对应的属性;*/
                  for (var attr in target) {
                      /*现在位置=开始位置+总距离/参数时间duration*time*/
                      var curPos = tmpEffect(time, begin[attr], change[attr], duration);
                      that.css(curEle, attr, curPos);
                  }
              }, step)
          },
          Banner.prototype.init = function () {/*初始化轮播图*/
              var that = this;
              /*1.开启自动轮播*/
              /*定时器1里有自动播放,自动播放里有animation,animation里面又有定时器2:
              定时器1里设置的时间>参数时间duration,
              如果animate里不声明step变量step,里面使用step的地方,值不一致,
              那么就会导致animation运行一次所需要的时间不等于duration。
              */
              this.timer = setInterval(function () {
                  that.autoMove();
              }, 2000);
              /*2.开启焦点,每个焦点与每张轮播图对应*/
              this.bannerTip();
              /*3.鼠标移入轮播区,轮播暂停;鼠标移出轮播区,轮播恢复*/
              this.overOrOut();
          },
          Banner.prototype.autoMove = function () {
              if (this.step >= this.aDiv.length - 1) {
                  this.step = 0;
                  this.css(this.oBoxInner, 'left', 0)
              }
              this.step++;
              this.animate(this.oBoxInner, {left: -this.step * parseFloat(this.width)}, 1000);
              this.bannerTip();
          },
          Banner.prototype.bannerTip = function () {
              var tmpStep = this.step >= this.aLi.length ? 0 : this.step;
              for (var i = 0; i < this.aLi.length; i++) {
                  this.aLi[i].className = i === tmpStep ? 'on' : null;
                  if (this.aLi[i].className === "on") {
                      this.aLi[i].style.background = "red";
                  } else {
                      this.aLi[i].style.background = "green";
                  }
              }
          },
          Banner.prototype.overOrOut = function () {
              var that = this;
              that.oBox.onmouseover = function () {
                  clearInterval(that.timer);
                  that.oBtnL.style.display = 'block';
                  that.oBtnR.style.display = 'block';
              };
              that.oBox.onmouseout = function () {
                  that.timer = setInterval(function () {
                      that.autoMove()
                  }, 2000);
                  that.oBtnL.style.display = 'none';
                  that.oBtnR.style.display = 'none';
              }
          }
      </script>
      <script>
          new Banner('1000px', '500px');
          /*这两个参数分别是轮播区的宽和高,可以根据需要更改*/
      </script>
 
三、jQuery版轮播图
1、代码分两个部分:
  (1)HTML部分,根据注释处理即可;
  (2)基于jQuery的play.js插件部分,这里为了展示效果,直接写在<html></html>下的<script></script>标签里。
  (3)效果包含:自动轮播,焦点对齐,前进后退,直走不返,鼠标进入、轮播停止且前进后退图标出现,鼠标离开、轮播重启且前进后退图标隐藏。(4)这里可以预览效果。
2、轮播图原理说明:
  (1)轮播图(假设)有7张图片,“一”字排列,把第1张图片复制一次,放到第8张的位置,这样共有8张图片;轮播开始后,
  (2)整个第2秒内,第2张图片从开始出现到完全出现,耗时700毫秒,完全出现后再停留300毫秒;
  (3)整个第3秒内,第3张图片从开始出现到完全出现,耗时700毫秒,完全出现后再停留300毫秒;以此类推
  (4)整个第8秒内,第8张图片从开始出现到完全出现,耗时700毫秒,完全出现后再停留300毫秒;注意
  (5)整个第9秒内,轮播图急速回到第1张图片完全出现的状态,耗时约0毫秒(即运行autoMove方法中if语句块的耗时),然后立即开始(2)步骤。
3、也可以用命名空间的方式进行扩展:
  (1)说明
    <script>
        $.myPlugin = { banner: function (width, height) {----插件代码---- } };
    </script>
    <script>
        $.myPlugin.banner('500px', '250px');
    </script>
  (2)示例
    <!DOCTYPE html>
    <html lang="en">
      <head>
          <meta charset="UTF-8">
          <title></title>
          <style>/*style标签及其内的内容,在实际项目中可以不要*/
          * {
              margin: 0;
              padding: 0;
          }
          </style>
      </head>
      <body>
      <!--body标签里的内容,没说可以增减或更改的,不要增减或更改-->
      <div id="box">
          <div>
              <!--以下是可增减区域-->
              <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517838828_mthumb.jpg" alt=""/></div>
              <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517841171_mthumb.jpg" alt=""/></div>
              <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517843343_mthumb.jpg" alt=""/>
              </div>
              <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517845828_mthumb.jpg" alt=""/>
              </div>
              <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517848093_mthumb.jpg" alt=""/>
              </div>
              <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517850750_mthumb.jpg" alt=""/>
              </div>
              <div><img src="http://img.pconline.com.cn/images/upload/upc/tx/photoblog/1509/06/c5/12226915_12226915_1441517853171_mthumb.jpg" alt=""/>
              </div>
              <!--以上是可增减区域-->
          </div>
      </div>
      </body>
    </html>
    <script src="//cdn.bootcss.com/jquery/3.1.1/jquery.js"></script>
    <script>
        (function($){
            $.fn.extend({
                banner: function (width, height) {
                    var $oBox = $("#box");
                    /*以下最外层div*/
                    $oBox.css({
                        "height": height,
                        "width": width,
                        "margin": "0 auto",
                        "overflow": "hidden",
                        "position": "relative"
                    });
                    /*以下轮播区的div*/
                    var $oBoxInner = $oBox.children('div');
                    var aDiv = $oBoxInner[0].innerHTML;
                    /* 轮播区内部原来的值*/
                    var aDiv0 = $oBoxInner.children('div')[0].outerHTML;
                    /*第一个轮播图片的外部*/
                    $oBoxInner.html(aDiv + aDiv0);
                    /* 用jQuery的方法给轮播区内部重新赋值*/
                    var $width = parseFloat(width) * $oBoxInner.children('div').length + "px";
                    $oBoxInner.css({
                        "height": height,
                        "width": $width,
                        "position": "absolute",
                        "left": 0,
                        "right": 0,
                        "float": "left"
                    });
                    $oBoxInner = $oBox.children('div');
                    var $aDiv = $oBoxInner.children("div");
                    $aDiv.css({"width": width, "height": height, "float": "left"});
                    $aDiv.children('img').css({"width": "100%", "height": "100%"});
                    /*以下是焦点区部分(定位在轮播区的右下方)*/
                    $oBox.append("<ul></ul>");
                    var $ul = $oBox.children("ul");
                    var $li = "";
                    $aDiv.each(function (index) {
                        if (index < $aDiv.length - 1) {
                            $li += '<li></li>';
                        }
                    });
                    $ul.append($li);
                    $ul = $oBox.children("ul");
                    $ul.css({"position": "absolute", "right": "10px", "bottom": "10px"});
                    $li = $ul.children("li");
                    $li.css({
                        "width": "18px",
                        "height": "18px",
                        "float": "left",
                        "listStyle": "none",
                        "background": "green",
                        "borderRadius": "50%",
                        "marginLeft": "10px",
                        "cursor": "pointer"
                    });
                    /*以下是向左向右两个箭头式按钮*/
                    var $a = "<a href = 'javascript:;'></a><a href = 'javascript:;'></a>";
                    $oBox.append($a);
                    /*以下是左按钮(点击它,图片向左运动)*/
                    var $oBtnL = $oBox.children('a').eq(0);
                    $oBtnL.css({
                        "width": "30px",
                        "height": "30px",
                        "position": "absolute",
                        "top": (parseFloat(height) / 2 - 15) + "px",
                        "left": "30px",
                        "border": "10px solid red",
                        "borderLeft": "none",
                        "borderBottom": "none",
                        "opacity": 0.6,
                        "filter ": "alpha(opacity=60)",
                        "display": "none",
                        "transform": "rotate(-135deg)"
                    });
                    $oBtnL.click(function () {
                        if ($step <= 0) {
                            $step = $aDiv.length - 1;
                            $oBoxInner.css('left', -$step * parseFloat(width));
                        }
                        $step--;
                        $oBoxInner.animate({left: -$step * parseFloat(width)});
                        $bannerTip();
                    });
                    /*以下是右按钮(点击它,图片向右运动)*/
                    var $oBtnR = $oBox.children('a').eq(1);
                    $oBtnR.css({
                        "width": "30px",
                        "height": "30px",
                        "position": "absolute",
                        "top": (parseFloat(height) / 2 - 15) + "px",
                        "right": "30px",
                        "border": "10px solid red",
                        "borderLeft": "none",
                        "borderBottom": "none",
                        "opacity": 0.6,
                        "filter": "alpha(opacity=60)",
                        "display": "none",
                        "transform": "rotate(45deg)"
                    });
                    $oBtnR.click(function () {
                        if ($step >= $aDiv.length - 1) {
                            $step = 0;
                            $oBoxInner.css('left', 0)
                        }
                        $step++;
                        $oBoxInner.animate({left: -$step * parseFloat(width)}, 1000);
                        $bannerTip();
                    });
                    var $step = 0;//记录每次运动
                    var $timer = null;//定时器
                    $init();//初始化轮播图
                    function $init() {
                        /*1.开启自动轮播*/
                        $timer = setInterval(function () {
                            $autoMove();
                        }, 2000);
                        /*2.开启焦点,每个焦点与每张轮播图对应*/
                        $bannerTip();
                        /*3.鼠标移入轮播区,轮播暂停;鼠标移出轮播区,轮播恢复*/
                        $overOut();
                    }
                    $li.each(function (index) {
                        $(this).on('click', function () {
                            $step = index;
                            $oBoxInner.animate({left: -$step * parseFloat(width)}, 1000);
                            $bannerTip();
                        })
                    });
                    function $autoMove() {
                        if ($step >= $aDiv.length - 1) {
                            $step = 0;
                            $oBoxInner.css('left', 0)
                        }
                        $step++;
                        $oBoxInner.animate({left: -$step * parseFloat(width)}, 1000);
                        $bannerTip();
                    }
                    function $bannerTip() {
                        var tmpStep = $step >= $li.length ? 0 : $step;
                        $li.each(function (index) {
                            $li.eq(index).attr("class",index === tmpStep ? 'on' : null);
                            if ($li.eq(index).attr("class") === "on") {
                                $li.eq(index).css("background","red");
                            } else {
                                $li.eq(index).css("background","green");
                            }
                        })
                    }
                    function $overOut() {
                        $oBox.mouseover(function () {
                            clearInterval($timer);
                            $oBtnL.css({"display": "block"});
                            $oBtnR.css({"display": "block"});
                        });
                        $oBox.mouseout(function () {
                            $timer = setInterval(function () {
                                $autoMove()
                            }, 2000);
                            $oBtnL.css({"display": "none"});
                            $oBtnR.css({"display": "none"});
                        });
                    }
                }
            })
        })(jQuery)
    </script>
    <script>
        $("#box").banner('500px', '250px');
    </script>
 
四、table表格
1、合并
  <html>
    <head>
      <style type="text/css">
        table{
          border-collapse: collapse;/* 单元格边框与边框之间_合并;separate;单元格边框与边框之间_分开 */
          border-spacing: 5px;/*  <table cellspacing="5"></table> 相邻单元格之间的距离 */
        }
        table tr th,table tr td{
          padding: 5px;/* <table cellpadding="5"></table> 单元格的内容与边框之间的距离 */
          border: 1px solid grey;/* 每个单元格框线_宽度 */
        }
      </style>
    </head>
    <body>
      <table>
        <thead>
          <tr>
            <th>栏1</th>
            <th>栏2</th>
            <th>栏3</th>
            <th>栏4</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td rowspan="2">第1行第1格,跨2行</td>
            <td>第1行第2格</td>
            <td>第1行第3格</td>
            <td>第1行第4格</td>
          </tr>
          <tr>
            <td>第2行第1格</td>
            <td>第2行第2格</td>
            <td>第2行第3格</td>
          </tr>
        </tbody>
        <tbody>
          <tr>
            <td colspan="2">第1行第1格,跨2栏</td>
            <td>第1行第2格</td>
            <td>第1行第3格</td>
          </tr>
          <tr>
            <td>第2行第1格</td>
            <td>第2行第2格</td>
            <td>第2行第3格</td>
            <td>第2行第4格</td>
          </tr>
        </tbody>
        <tfoot>
          <tr>
            <td colspan="4">被纵、横合并的单元格(th、td)及其右侧的单元格都会向右平移1格</td>
          </tr>
        </tfoot>
      </table>
    </body>
  </html>
2、嵌套合并
  <table class="table">
    <thead>
      <tr>
        <th>
          <button>序号</button>
        </th>
        <th ng-repeat="li in title track by $index">
          <button>{{li}}</button>
        </th>
      </tr>
    </thead>
    <tbody ng-repeat="li in list__detail track by $index">
      <tr>
        <td>
          <div>
            <img ng-src="{{''}}" alt=""/>
          </div>
        </td>
        <td ng-bind="li.name"></td>
        <td ng-bind="li.name"></td>
        <td ng-bind="li.name"></td>
        <td ng-bind="li.name"></td>
      </tr>
      <tr ng-if="li.is_show">
        <td colspan="9999"><!-- 这点很重要,td下面放div -->
          <div id="JSONData">
            <div>此处可以通过jquery.json-viewer.js,格式化JSON数据</div>
            <div>js代码为$('#JSONData').jsonViewer(JSON.parse(data))</div>
          </div>
        </td>
      </tr>
      <tr ng-if="li.is_show">
        <td colspan="9999"><!-- 这点很重要,td下面放table -->
          <table>
            <thead>
              <tr>
                <th>文字</th>
                <th>文字</th>
                <th>文字</th>
                <th>文字</th>
                <th>文字</th>
              </tr>
            </thead>
            <tbody>
              <tr ng-repeat="item in list track by $index">
                <td ng-bind="item.name"></td>
                <td ng-bind="item.name"></td>
                <td ng-bind="item.name"></td>
                <td ng-bind="item.name"></td>
                <td ng-bind="item.name"></td>
              </tr>
              <tr>
                <td colspan="9999" ng-if="list.length<1">暂无数据可显示。</td>
              </tr>
            </tbody>
          </table>
          <!-- 此处分页组件 -->
        </td>
      </tr>
    </tbody>
  </table>
3、table表格数据,嵌套变平级
  var allDatas = res.data[0];
  var fourMenuLast = [];
  var repeatA = '';
  var repeatB = '';
  angular.forEach(allDatas.children, function (item1) {//步骤1,40
    var fourMenu = {//步骤2,
      myMenu1: {},
      myMenu2: {},
      myMenu3: {}
    };
    fourMenu.myMenu1.name = item1.name;//步骤3,
    fourMenu.myMenu1.id = item1.id;//步骤4,
    fourMenu.myMenu1.showname = item1.name;//步骤5,
    angular.forEach(item1.children, function (item2) {//步骤6,20,
      fourMenu.myMenu2.name = item2.name;//步骤7,21,
      fourMenu.myMenu2.id = item2.id;//步骤8,22,
      fourMenu.myMenu2.showname = item2.name;//步骤9,23,
      angular.forEach(item2.children, function (item3) {//步骤10,15,24,30,35,
        fourMenu.myMenu3.name = item3.name;//步骤11,16,25,31,36,
        fourMenu.myMenu3.id = item3.id;//步骤12,17,26,27,32,37,
        fourMenu.myMenu3.showname = item3.name;//步骤13,18,28,33,38,
        fourMenuLast.push(angular.copy(fourMenu));//步骤14,19,29,34,39,
      });
    });
    //fourMenuLast=[fourMenu,fourMenu,fourMenu,fourMenu,fourMenu,fourMenu,fourMenu,fourMenu,fourMenu,fourMenu,fourMenu,fourMenu,fourMenu];
    $scope.rowSpan1 = {}; //某个一级导航合并的行数
    angular.forEach(fourMenuLast, function (item) {
      if ($scope.rowSpan1[item.myMenu1.id]) {
        $scope.rowSpan1[item.myMenu1.id] += 1;
      } else {
        $scope.rowSpan1[item.myMenu1.id] = 1;
      }
      if (item.myMenu1.id === repeatA) {
        item.myMenu1.name = '';
      } else {
        repeatA = item.myMenu1.id;
      }
    });
    $scope.rowSpan2 = {}; //某个二级导航合并的行数
    angular.forEach(fourMenuLast, function (item) {
      if ($scope.rowSpan2[item.myMenu2.id]) {
        $scope.rowSpan2[item.myMenu2.id] += 1;
      } else {
        $scope.rowSpan2[item.myMenu2.id] = 1;
      }
      if (item.myMenu2.id === repeatB) {
        item.myMenu2.name = '';
      } else {
        repeatB = item.myMenu2.id;
      }
    });
    $scope.allroles = fourMenuLast;
  })
4、table表格示例(含固定栏和滑动栏)
  <!DOCTYPE html>
  <html lang="en">
  <head>
    <title>左侧固定宽,右侧占满剩余宽</title>
    <meta charset="utf-8"/>
    <style>
      * {
        padding: 0;
        margin: 0;
      }
      /* 设置滚动条的样式 */
      ::-webkit-scrollbar {
        width: 17px;     
        height: 17px;
      }
      /* 滚动槽 */
      ::-webkit-scrollbar-track {
        background: #dabda2;
        border-radius: 10px;
        box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
        border-top-left-radius: 0
      }
      /* 滚动条滑块*/
      ::-webkit-scrollbar-thumb {
        background: #bb8459;
        border-radius: 10px;
        box-shadow: inset 0 0 6px gray;
      }
      table {
        border: 1px solid black;
        width: 1000px;
        color: #000000;
        text-align: center;
        border-collapse: collapse;
      }
      table thead tr th,
      table tbody tr td {
        border: 1px solid black;
        min-width: 100px;
        white-space: nowrap;
        padding: 5px 20px;
      }
      .leftDiv{
        width:300px;
        padding:20px;
        border-radius: 10px;
        border:1px solid gray
      }
      .leftDiv p{
        padding:10px;
        font-size: 20px;
      }
    </style>
    <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.js"></script>
    <script type="text/javascript">
      $(document).ready(function () {
        init();
        function init() {
          var str = makeTableBodyString();
          var width = document.body.clientWidth-300;
          $("tbody").html(str);
          fixColumnTable("myTable", 4, width, 600);
        }
        window.onresize = function () {
          init();
        }
        function fixColumnTable(tableID, fixColumnNumber, width, height) {
          //1、以下给"哥哥表格"添加1个"弟弟div"
          var tableIDSibling = "";
          tableIDSibling += "<div id='" + tableID + "sibling' style='overflow:hidden;height:" + height + "px;";
          tableIDSibling += " width:" + width + "px;border:1px solid gray;border-radius:10px;'></div>";
          $("#" + tableID).after(tableIDSibling);
          //2、在"弟弟div"内,插入4个"儿子div",并设置堆叠顺序
          var tableIDSiblingInner = "";
          tableIDSiblingInner += '<div id="' + tableID + 'HeadFix"></div>';
          tableIDSiblingInner += '<div id="' + tableID + 'HeadMove"></div>';
          tableIDSiblingInner += '<div id="' + tableID + 'BodyFix"></div>';
          tableIDSiblingInner += '<div id="' + tableID + 'BodyMove"></div>';
          $(tableIDSiblingInner).appendTo("#" + tableID + "sibling");
          $("#" + tableID + "HeadFix").css({ "overflow": "hidden", "z-index": "50", "background-color": "silver" });
          $("#" + tableID + "HeadMove").css({ "overflow": "hidden", "z-index": "45", "background-color": "silver", "width": width - 17 });
          $("#" + tableID + "BodyFix").css({ "overflow": "hidden", "z-index": "40", "background-color": "silver", "height": height - 17 });
          $("#" + tableID + "BodyMove").css({ "overflow": "scroll", "z-index": "35", "width": width, "height": height });
          //3、以下给"哥哥表格"和3个克隆,分别插入到4个"儿子div"中,生成4个"孙子表格"
          var oldTable = $("#" + tableID);
          var headFix = oldTable.clone(true);
          var headMove = oldTable.clone(true);
          var bodyFix = oldTable.clone(true);
          $("#" + tableID + "HeadFix").append(headFix);
          $("#" + tableID + "HeadMove").append(headMove);
          $("#" + tableID + "BodyFix").append(bodyFix);
          $("#" + tableID + "BodyMove").append(oldTable);
          //4、以下获取"哥哥表格"头部固定栏的高和左侧固定栏的宽
          var columnsWidth = 2;
          var headHeight = $("#" + tableID + " thead").height()+2;
          $("#" + tableID + " tr:last td:lt(" + fixColumnNumber + ")").each(function () {
            columnsWidth += $(this).outerWidth(true);
          });
          //5、以下设置其中3个"儿子div"的宽或高,高度变小后,下面的div会上升
          $("#" + tableID + "HeadFix").css("height", headHeight);//设置左上方"儿子div"的高
          $("#" + tableID + "HeadFix").css("width", columnsWidth);//设置左上方"儿子div"的宽
          $("#" + tableID + "HeadMove").css("height", headHeight);//设置上方"儿子div"的高
          $("#" + tableID + "BodyFix").css("width", columnsWidth);//设置左侧"儿子div"的宽
          //6、以下将4个"儿子div"定位到"弟弟div"的正上方
          //offset方法:“获取”或“设置”匹配元素相对于文档的偏移
          //(1)“获取”借助于getBoundingClientRect来实现
          //(2)“设置”借助于jQuery.offset.setOffset来实现,其内部用position“获取”父级定位元素的位置
          //(3)在setOffset源码中,相对定位和绝对定位走不同的逻辑,实现相同的定位效果
          $("#" + tableID + "HeadFix").offset($("#" + tableID + "sibling").offset());//$HeadFix.css({top: -1, left: -1})
          $("#" + tableID + "HeadMove").offset($("#" + tableID + "sibling").offset());//$HeadMove.css({top: -35, left: -1})
          $("#" + tableID + "BodyFix").offset($("#" + tableID + "sibling").offset());//$BodyFix.css({top: -69, left: -1})
          $("#" + tableID + "BodyMove").offset($("#" + tableID + "sibling").offset());//$BodyMove.css({top: -652, left: -1})
          //7、以下当第4个"儿子div"的滑动时,第2个或第3个"儿子div"同步滑动
          $("#" + tableID + "BodyMove").scroll(function () {
            $("#" + tableID + "HeadMove").scrollLeft($("#" + tableID + "BodyMove").scrollLeft());
            $("#" + tableID + "BodyFix").scrollTop($("#" + tableID + "BodyMove").scrollTop());
          });
        }
        function randomMath(n, m) {
          return Math.round(Math.random() * (m - n) + n);
        }
        function makeTableBodyString() {
          var firstName = '赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶江';
          var lastName = '枯藤老树昏鸦小桥流水人家古道西风瘦马夕阳西下断肠人在天涯马致远天净沙秋思';
          var ary = [];
          for (var i = 1; i <= 60; i++) {
            var obj = {
              name: firstName[randomMath(0, 31)] + lastName[randomMath(0, 35)] + lastName[randomMath(0, 35)],
              yuwenScore: randomMath(60, 100) + "分",
              shuxueScore: randomMath(60, 100) + "分",
              yingyuScore: randomMath(60, 100) + "分",
              zhengzhiScore: randomMath(60, 100) + "分",
              lishiScore: randomMath(60, 100) + "分",
              diliScore: randomMath(60, 100) + "分",
              wuliScore: randomMath(60, 100) + "分",
              huaxueScore: randomMath(60, 100) + "分",
              shengwuScore: randomMath(60, 100) + "分",
              tiyuScore: randomMath(60, 100) + "分",
              yingyueScore: randomMath(60, 100) + "分",
              meishuScore: randomMath(60, 100) + "分"
            };
            ary.push(obj);
          }
          var str = ""
          $.each(ary, function (index, item) {
            str += "<tr>";
            str += "<td>" + item.name + "</td>";
            str += "<td>" + item.yuwenScore + "</td>";
            str += "<td>" + item.shuxueScore + "</td>";
            str += "<td>" + item.yingyuScore + "</td>";
            str += "<td>" + item.zhengzhiScore + "</td>";
            str += "<td>" + item.lishiScore + "</td>";
            str += "<td>" + item.diliScore + "</td>";
            str += "<td>" + item.wuliScore + "</td>";
            str += "<td>" + item.huaxueScore + "</td>";
            str += "<td>" + item.shengwuScore + "</td>";
            str += "<td>" + item.tiyuScore + "</td>";
            str += "<td>" + item.tiyuScore + "</td>";
            str += "<td>" + item.meishuScore + "</td>";
            str += "<td>" + "===================================" + "</td>";
            str += "</tr>";
          })
          return str;
        }
      });
    </script>
  </head>
  <body>
    <div style="display: flex;">
      <div class="leftDiv">
        <p>效果说明:</p>
        <p>左侧固定宽,</p>
        <p>右侧表格占满余下宽,</p>
        <p>窗口宽度变化时,</p>
        <p>依然保持这个效果。</p>   
      </div>
      <div style="flex:1;height:600px">
        <table id="myTable">
          <thead>
            <tr>
              <th>姓名</th>
              <th>语文</th>
              <th>数学</th>
              <th>英语</th>
              <th>政治</th>
              <th>历史</th>
              <th>地理</th>
              <th>物理</th>
              <th>化学</th>
              <th>生物</th>
              <th>体育</th>
              <th>音乐</th>
              <th>美术</th>
              <th>备注</th>
            </tr>
          </thead>
          <tbody>
          </tbody>
        </table>   
      </div>
    </div>
    <!-- 模仿来源https://blog.csdn.net/qq_29170981/article/details/79221644 -->
  </body>
  </html>
 
五、js根据表达式画曲线
示例一:
  <!DOCTYPE html>
  <html lang="en">
  <head>
      <meta charset="UTF-8">
      <title></title>
      <script src="https://unpkg.com/d3@3/d3.min.js"></script>
      <script src="https://unpkg.com/function-plot@1/dist/function-plot.js"></script>
  </head>
  <body>
  <div id="box" style="width:500px;height:1000px"></div>
  <script>
  //参数说明 https://www.javascriptcn.com/read-36947.html
  functionPlot({
      target:document.getElementById("box"),
      data:[
          {fn:"x^4+x^3+x^2+x+1"}
      ],
      title:"ddddddd",
      xAxis:{
          domain:[-5,5],
      },
      yAxis:{
          domain:[0,70],
      }
  })
  </script>
  </body>
  </html>
示例二:
  <!DOCTYPE html>
  <html lang="en">
  <head>
      <meta charset="UTF-8">
      <title></title>
      <script src="https://unpkg.com/d3@3/d3.min.js"></script>
      <script src="https://unpkg.com/function-plot@1/dist/function-plot.js"></script>
  </head>
  <body>
  <div id="box" style="width:500px;height:1000px"></div>
  <script>
  functionPlot({
      target:document.getElementById("box"),
      data:[
              {fn:"sqrt(4-x^2)"},
              {fn:"-sqrt(4-x^2)"},
      ],
      title:"ddddddd",
      xAxis:{
          domain:[-5,5],
      },
      yAxis:{
          domain:[-3,3],
      },
      grid:true,
      disableZoom:true 
  })
  </script>
  </body>
  </html>
示例三:
  <!DOCTYPE html>
  <html>
  <head>
    <meta charset="UTF-8">
    <title>plot 绘制图像</title>
  </head>
  <body>
  <div id="tester" style="width:600px;height:250px;"></div>
  </body>
  <script src="https://cdn.plot.ly/plotly-1.2.0.min.js"></script>
  <!-- test -->
  <script>
    TESTER = document.getElementById('tester');
    Plotly.plot(TESTER, [{
      x: [1, 2, 3, 4, 5],
      y: [1, 2, 4, 8, 16]
    }], {
      margin: {t: 0}
    });
  </script>
  </html>
示例四:
  <!DOCTYPE html>
  <html>
  <head>
    <meta charset="UTF-8">
    <title>plot 绘制图像</title>
  </head>
  <body>
  <div id="math-function" style="width:600px;height:250px;"></div>
  </body>
  <script src="https://cdn.plot.ly/plotly-1.2.0.min.js"></script>
  <!-- test -->
  <script>
    TESTER = document.getElementById('math-function');
   
  var x = [], y = [];
 
  for(var i = -10; i < 10; i += 1) {
    x.push(i);
    y.push(2*i+1);
  }
 
  Plotly.plot(TESTER, [{
    x: x,
    y: y
  }], {
    margin: {t: 0}
  });
  </script>
  </html>
 
  
六、10行实现不重复验证码
  不重复的6位随机验证码非常常用,这里是最简单的两种实现方式:(1)自动生成,(2)点击更新。
1、自动生成:每隔1秒自动生成1次。
  <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
  </head>
  <style>
    #yard{
      font-size: 170px;
      background: grey;
    }
  </style>
  <body>
  <div id="yard"></div>
  </body>
  </html>
  <script>
    var div = document.getElementById("yard");
    function fn(){
      var strCode = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
      var str = '';
      while (str.length < 6) {
        var str1 = strCode.charAt(Math.round(Math.random() * 61));
        if (str.indexOf(str1) === -1) {
            str += str1;
        }
      }
      div.innerHTML=str;
    }
    fn();
    var timer=setInterval(fn,1000)
  </script>
2、点击更新
  <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
  </head>
  <style>
    #yard{
      font-size: 170px;
      background: grey;
      cursor: pointer;/*比“1、自动生成”多出的代码*/
      -webkit-user-select:none;/*比“1、自动生成”多出的代码*/
    }
  </style>
  <body>
  <div id="yard"></div>
  </body>
  </html>
  <script>
    var div = document.getElementById("yard");
    div.onclick=fn;
    function fn(){
      var strCode = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
      var str = '';
      while (str.length < 6) {
        var str1 = strCode.charAt(Math.round(Math.random() * 61));
        if (str.indexOf(str1) === -1) {
            str += str1;
        }
      }
      div.innerHTML=str;
    }
    fn();
  </script>
 
七、8行实现发电报效果,电视剧中经常出现文字一个一个地出现的显示屏上,好像是发电报一样,方案2用8行代码实现。
  <!DOCTYPE html>
  <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title></title>
      <style>
        * {
            background: #000;
            padding: 0;
            margin: 0;
        }
        p {
            color: white;
            font-size: 65px;
            text-indent: 130px;
            font-family:"kaiti";
        }
      </style>
    </head>
    <body>
      <p id="transmitter"></p>
    </body>
  </html>
  <script>
    //以下方案1:
    var now = new Date();
    var past = new Date('2016-01-01 00:00:00');
    var nowMilliseconds = now.getTime();
    var pastMilliseconds = past.getTime();
    var seconds = Math.floor((nowMilliseconds - pastMilliseconds)/1000)
    var year = Math.floor(seconds / (86400*365)) + '年';// 3600*24 = 86400;
    var month = Math.floor((seconds % (86400*365)) / (86400*30)) + '个月';
    var str = year + month;
    //以下方案2:
    //var str = new Date().getFullYear() - 2016 + '年';
    //以下公共部分:
    var transmitter = document.getElementById("transmitter");
    var allCharacters = "钱成,河南省固始县人,2016年初至今,从事前端工作"+ str +"有余,现在是人类最优秀的前端工程师。联系电话:137  1616  4418。完!";
    var n = 0;
    var timer = setInterval(function () {
        transmitter.innerHTML += allCharacters.charAt(n);
        n++;
        console.log( n );
        if (n >= allCharacters.length)clearInterval(timer);
    }, 100);
  </script>
 
八、css样式汇总
1、光标、选中、空白
 (1)cursor: pointer;光标类型:小手
 (2)user-select: none;用户选择:禁止选中文字
 (3)white-space: nowrap;超宽:不换行
2、改查
 (1)obj.style可读(写在元素标签中,style属性里的样式)、可写(如下)
    A、obj.style.width = '400px';
    B、obj.style.cssText = "width:400px; height:300px";
 (2)getComputedStyle可读(元素的所有样式,如下)、不可写 
    A、var first=document.getElementById("first");
    B、window.getComputedStyle(first,null).backgroundColor
3、滚动条
 (1)破坏布局,
   A、现象,当内容增多,滚动条从无到有时,它的出现挤压了内容宽度,导致原来设计好的布局被破坏
   B、原因,滚动条的宽度是计算到内容 content 里的
   C、解决,增加一个中间层,使得外部容器宽度保持设计宽度,内部元素排列保持不变
 (2)隐藏
    A、*::-webkit-scrollbar {
        display: none;
      }
    B、::-webkit-scrollbar {
        width: 0;
      }
4、兄弟叠加
  (1)需求:
    A、哥哥盒子不隐藏,弟弟盒子放在哥哥盒子上,
    B、哥哥盒子隐藏,弟弟元素占据哥哥盒子的位置,
  (2)实现:
    <div class="up" v-if="!showList"></div>
    <div></div>
    .up{
      margin-bottom: -90px;
    }
5、tabIndex和a标签
  (1)给div标签添加属性tabIndex=-1,可以使该div有onfocus与onblur事件
  (2)a标签focus()不聚焦解决方案,给它添加属性href为#
  (3)a标签有黑框解决方案,设置样式outline为none
  (4)a标签点击后,响应用户自定义的点击事件
    <a href="javascript:void(0);" onclick="doSomething()">test</a>
    <a href="javascript:;" onclick="doSomething()">test</a>
    <a href="####" onclick="doSomething()">test</a>
6、a标签之target属性的取值
  示例:<a target="_blank|_self|_parent|_top|framename"></a>
  (1)_self:默认,当前页面跳转
  (2)_blank:新窗口打开
  (3)_parent:在父窗口中打开链接
  (4)_top:在当前窗体打开链接,并替换当前的整个窗体(框架页)
7、清除浮动的7种方法
  原因:父元素不浮动,子元素浮动,引发父元素塌陷
  解决方案:
  (1)子级结尾处加空div标签 clear:both
  (2)父级div 也一起浮动
  (3)父级div定义 width
  (4)父级div定义 伪类:after .clearfloat:after{display:block;clear:both;content:"";visibility:hidden;height:0}
  (5)父级div定义 overflow: hidden 或者 auto
  (6)父级div定义 display:table
8、块级元素A及其内部的块级元素B,
  (1)A浮动,B不浮动,B的宽度为B实际需要的宽度,A的宽度由B决定;
  (2)A不浮动,B浮动,会引发A塌陷。
  (3)A和B都浮动,不会引发A塌陷。
9、块级元素A及其弟弟块级元素B的默认宽度是100%;
  (1)A浮动,B不浮动,A的宽度为A实际需要的宽度,B会插到A的下面;
  (2)A不浮动,B浮动,B浮到A的上方。
  (3)A和B都浮动,则A和B同行,宽度为它们实际需要的宽度
10、hover悬停与否,内部显示不同区域
  <!DOCTYPE html>
  <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>样式</title>
      <style>
        .outer .black{
          display: block;
          color: black;
        }
        .outer .gray{
          display: none;
        }
        .outer:hover .black{
          display: none;
        }
        .outer:hover .gray{
          display: block;
          color: gray;
        }
      </style>
    </head>
    <body>
      <div class="outer" >
        <div class="black">正常样式</div>
        <div class="gray">悬停样式</div>
      </div>
    </body>
  </html>
11、媒体查询
  (1)参数实例说明
    @media (width: 900px) {
      body{
        font-size: 50px;
      }
    }
    @media screen and (min-width: 960px) {
      //all,所有设备;print,打印机等设备;screen,彩色屏幕(手机,电脑,平板)
      body {
        font-size: 50px;
      }
    }
    @media only screen and (min-width: 600px) { //仅适用于屏幕设备
      body {
        background-color: lightblue;
      }
    }
    @media not screen and (max-width: 600px) { //当设备不是屏幕设备
      body {
        background-color: lightgreen;
      }
    }
    @media screen and (min-width: 400px) and (max-width: 800px) and (orientation: landscape) {
      //portrait,竖屏;landscape,横屏
      body {
        font-size: 200px;
      }
    }
    @media screen and (prefers-reduced-motion:reduce) { //用户在操作系统中启用了减少动画的设置
      .form-control {
        transition: none
      }
    }
  (2)媒体查询的实例
    <!DOCTYPE html>
    <html lang="zh-CN">
      <head>
        <title>媒体查询的实例</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <style>
          @media (min-width: 400px) {
            body{
              font-size: 50px;
            }
          }
          @media (min-width: 800px) {
            body{
              font-size: 100px;
            }
          }
          @media (min-width: 1200px) {
            body{
              font-size: 150px;
            }
          }
          @media (min-width: 1600px) {
            body{
              font-size: 200px;
            }
          }
        </style>
      </head>
      <body>
        <div> 最小宽度,只能从小往大写 </div>
      </body>
    </html>
12、BEM
  (1)CSS命名规范,缺点是名称很长
  (2)BEM,块(block)、元素(element)、修饰符(modifier)
  (3)CSS示例
    .overview{} /* 块 */
    .overview__row{} /* 元素 */
    .overview__row--right{} /* 修饰符 */
  (4)HTML示例
    <div class="overview">
      <div class="overview__row overview__row--right"></div>
      <div class="overview__row overview__row--right"></div>
      <div class="overview__row overview__row--right"></div>
    </div>
13、栅格布局的说明
  (1)col-6,任何网页,占6栏
  (2)col-xs-6,超小网页,占6栏,<768px
  (3)col-sm-6,小网页,占6栏,>=768px
  (4)col-md-6,中等网页,占6栏,>=992px
  (5)col-lg-6,大网页,占6栏,>=1200px
  (6)层级:container-->row-->col-6-->form-inline-->form-group-->form-control
    <body>
      <div class="container">
        <div class="row">
          <div class="col-6">
            <form class="form-inline">
              <div class="form-group">
                <label>todotext</label>
                <input class="form-control" type="text">
              </div>
            </form>
          </div>
        </div>
      </div>
    </body>
  (7)栅格布局的实例
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <title>栅格布局实例</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
      <style>
        .border{
          border:1px solid gray
        }
        div{
          font-size: 14px;
        }
      </style>
    </head>
    <body>
      <div class="container">
        <div class="row">
        <div class="border col-xs-4 padding" style="padding:0 15px;">.col-xs-4,"网页的宽"小于768px时,占4格</div>
        </div> 
        <div class="row">
        <div class="border col-sm-4">.col-sm-4,"网页的宽"大于等于768px时,占4格</div>
        <div class="border col-sm-4"></div>
        <div class="border col-sm-4"></div>
        </div> 
        <div class="row">
        <div class="border col-md-4">.col-md-4,"网页的宽"大于等于992px时,占4格</div>
        <div class="border col-md-4"></div>
        <div class="border col-md-4"></div>
        </div> 
        <div class="row">
        <div class="border col-lg-4">.col-lg-4,"网页的宽"大于等于1200px,占4格</div>
        <div class="border col-lg-4"></div>
        <div class="border col-lg-4"></div>
        </div> 
        <div class="row">
        <div class="border col-4">.col-4,不管"网页的宽"是多少,都占4格</div>
        <div class="border col-4"></div>
        <div class="border col-4"></div>
        </div>
      </div>
    </body>
    </html>
14、背景图片撑开盒子
  <!DOCTYPE html>
  <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>盒子的宽可以是百分比,盒子内部不可以添加内容</title>
      <style>
        * {
          padding: 0;
          margin: 0;
        }
        .outer {
          width: 40%;
          background: url(https://bkimg.cdn.bcebos.com/pic/faf2b2119313b07e1dc9e56303d7912397dd8c61) no-repeat;/* 纯灰色图片 */
          background-size: 100%;
          /* 以上为PC端和移动端公用,以下为PC端私用 */
          border: 10px green dashed;
          margin: 0 auto;
        }
        .outer::before {
          content: "";
          display: block;
          padding-top: 66.6%;
        }
      </style>
    </head>
    <body>
      <div class="outer"></div>
      <div style="border:10px green dashed; width: 900px; margin: 20px auto;">
        <h2>1、背景图片撑开盒子,实施方案1</h2>
        <div>padding-top:66.6% 也可以用 padding-bottom:66.6%;66.6%=图片的高/宽</div>
        <div>.outer::before 也可以用 .outer::after</div>
        <h2>2、背景图片撑开盒子,实施方案2</h2>
        <div>根据盒子宽度和“图片的高/宽”计算出盒子的高度</div>
      </div>
    </body>
  </html>
15、变量--var
  <!DOCTYPE html>
  <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>样式变量和禁用密码框的背景色</title>
      <style>
        :root {
          --colorGreen:green;
        }
        html{
          --fontSize40:20px;
        }
        .div{
          color:var(--colorGreen);
          font-size:var(--fontSize40);
        }
        .other{
          --colorGreen:green;
          --fontSize40:20px;
          color:var(--colorGreen);
          font-size:var(--fontSize40);
        }
      </style>
    </head>
    <body>
      <div class="div">
        <pre>
          全局定义样式变量
            :root {
              --colorGreen:green;
            }
            html{
              --fontSize40:40px;
            }
          局部使用样式变量
            .div{
              color:var(--colorGreen);
              font-size:var(--fontSize40);
            }
        </pre>
      </div>
      <div class="other">
        <pre>
          局部定义、使用样式变量
            .other{
              --colorGreen:green;
              --fontSize40:20px;
              color:var(--colorGreen);
              font-size:var(--fontSize40);
            }
        </pre>
      </div>
    </body>
  </html>
16、密码框
  (1)禁用样式
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <title>样式变量和禁用密码框的背景色</title>
        <style>
          input[type=password]:disabled{
            width: 200px;
            height: 30px;
            font-size: 20px;
            border-radius: 6px;
            background: gray;
          }
        </style>
      </head>
      <body>
        <div>
          <pre>
            <label>禁用密码框样式:</label>
            <input disabled type="password" value="这是我的密码"/>
            input[type=password]:disabled{
               
            }
          </pre>
        </div>
      </body>
    </html>
  (2)各种禁止
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>密码框的各种禁止</title>
    </head>
    <body>
      <input
        id="pwd"
        name="pwd"
        type="password"
        autocomplete="off"
        oncut="return false"
        oncopy="return false"
        onpaste="return false"
        onselectstart="return false"
        oncontextmenu="return false"
        style="width:400px;height:30px;"
      />
      <p>
        <span>禁用自动完成功能:</span>
        <span>autocomplete="off"</span>
      </p>
      <p>
        <span>禁止剪贴:</span>
        <span>oncut = "return false"</span>
      </p>
      <p>
        <span>禁止复制:</span>
        <span>oncopy = "return false"</span>
      </p>
      <p>
        <span>禁止粘贴:</span>
        <span>onpaste = "return false"</span>
      </p>
      <p>
        <span>禁止选中:</span>
        <span>onselectstart="return false"</span>
      </p>
      <p>
        <span>禁止右键:</span>
        <span>oncontextmenu="return false"</span>
      </p>
    </body>
    </html>
17、半包围效果:
  <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <title></title>
  </head>
  <body>
  <p>
    <span style="color:red;">被包围者</span>
    <span style="color:green;">包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者包围者</span>
  </p>
  </body>
  </html>
18、点击事件之显示执行与隐式执行示例:
  <!DOCTYPE html>
  <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Title</title>
      <style>
        div{width:100px;height:100px;background:red;margin:20px;}
      </style>
    </head>
    <body>
      <div onclick="myClick(event,'second','third')" ></div>
      <div id="myDiv" ></div>
        <!--这是显示执行,有定义,有执行。执行时,除了浏览器向其传参'event',还可以人为传参'second''third'-->
    </body>
  </html>
  <script>
    function myClick(first,second,third){
      console.log(first);
      console.log(second);
      console.log(third);
    }
    document.getElementById("myDiv").onclick=function (myEvent) {
    /*这是隐式执行,有定义,无执行。执行时,除了浏览器向其传参'event',没办法人为传参'second'、'third'*/
      console.log(myEvent);
    }
  </script>
19、旋转的正方体
  实现思路:(1)把6个正方形通过定位叠放在一起;(2)1个不动,4个旋转90度与前者垂直,形成1个无盖盒子,最后1个通过平移作为盒盖!(3)添加CSS3动画,实现旋转。
  <!DOCTYPE html>
  <html>
    <head lang="en">
      <meta charset="UTF-8">
      <title>旋转的正方体</title>
      <style type="text/css">
        *{
          margin: 0;
          padding:0
        }
        .wrap{
          perspective:2000px;
        }
        .wrap ul{
          width: 200px;
          height: 200px;
          margin: 100px auto;
          position: relative;
          animation: move 5s infinite;
          transform-style: preserve-3d;
          transform-origin: 100px 100px -100px;
        }
        .wrap ul li{
          left: 0;
          top: 0;
          width: 196px;
          height: 196px;
          color: #fff;
          font-size: 60px;
          list-style: none;
          text-align: center;
          line-height: 196px;
          position: absolute;
          border:2px solid #000;
          background: rgba(000,000,000,0.5);
     
        }
        .wrap ul li:nth-child(1){
          transform-origin: top;
          transform: rotateX(-90deg);
        }
        .wrap ul li:nth-child(2){
          transform-origin: bottom;
          transform: rotateX(90deg);
        }
        .wrap ul li:nth-child(3){
          transform-origin: left;
          transform: rotateY(90deg);
        }
        .wrap ul li:nth-child(4){
          transform-origin: right;
          transform: rotateY(-90deg);
        }
        .wrap ul li:nth-child(5){
          transform: translateZ(-200px);
        }
        .wrap ul li:nth-child(6){
          transform:translateZ(0px);
        }
        @keyframes move {
          0%{
              transform: rotateX(0deg) rotateY(0deg);
          }
          100%{
              transform: rotateX(360deg) rotateY(360deg);
          }
        }
      </style>
    </head>
    <body>
    <div class="wrap">
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
      <li>6</li>
    </ul>
    </div>
    </body>
  </html>
20、太极图
  (1)三层div实现
    思路:
    A、通过渐变把外层圆形div的content分成上下黑白两个区域;
    B、用中间层两个圆形div的content颜色来改变本区域的颜色;
    C、用内层两个圆形div的content颜色来恢复本区域的颜色。鼠标置于太极图上,太极图还会旋转!
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8">
        <title>太极</title>
        <style class="cp-pen-styles">
          *{
            padding:0;
            margin:0;
          }
          .outer{
            background: linear-gradient(to bottom,white 50%,black 50%);
            margin:100px auto;
            width:200px;
            height:200px;
            border-radius: 50%;
            position:relative;
            border:1px solid black;
            transition: all 5s ease;
          }
          .outer:hover{
            transform: rotate(360deg) scale(1.5);
          }
          .outer .left{
            background: white;
            width:100px;
            height:100px;
            border-radius: 50%;
            position:absolute;
            left: 0;
            top:50px;
          }
          .outer .left .leftInner{
            background: black;
            width:40px;
            height:40px;
            border-radius: 50%;
            position:absolute;
            left: 30px;
            top:30px;
          }
          .outer .right{
            background: black;
            width:100px;
            height:100px;
            border-radius: 50%;
            position:absolute;
            right: 0;
            top:50px;
          }
          .outer .right .rightInner{
            background: white;
            width:40px;
            height:40px;
            border-radius: 50%;
            position:absolute;
            left:30px;
            top:30px;
          }
        </style>
      </head>
      <body>
        <div class="outer">
          <div class="left">
            <div class="leftInner"></div>
          </div>
          <div class="right">
            <div class="rightInner"></div>
          </div>
        </div>
      </body>
    </html>
  (2)伪类实现
    思路:
    A、通过渐变把外层圆形div分成上下黑白两个区域;
    B、添加伪类,用伪类的圆形边框颜色来改变本区域的颜色;
    C、通过伪类的圆形content颜色来恢复本区域的颜色。鼠标置于太极图上,太极图还会旋转!
    <!DOCTYPE html>
    <html>
    <head>
      <meta charset="UTF-8">
      <title>太极</title>
      <style>
        *{
          margin:0;
          padding:0;
        }
        div, :before, :after {
          box-sizing: border-box;
        }
        #taiji {
          position: absolute;
          top: 50%;
          left: 50%;
          width: 200px;
          height: 200px;
          margin: -100px 0 0 -100px;
          background: linear-gradient(0deg, black 50%, white 50%);
          border-radius: 50%;
          border:1px black solid;
        }
        @keyframes taiji {
          from{
              transform: rotate(0deg) scale(1);
          }
          to{
              transform: rotate(360deg) scale(2);
          }
        }
        #taiji:hover {
          animation: taiji 1s ease 0s infinite;
        }
        #taiji:before, #taiji:after {
          content: "";
          display: block;
          position: absolute;
          width: 50%;
          height: 50%;
          top: 25%;
          border-radius: 50%;
          border: 35px solid transparent;
        }
        #taiji:before {
          left: 0;
          border-color: black;
   
        }
        #taiji:after {
          right: 0;
          border-color: white;
   
        }
      </style>
    </head>
    <body>
    <div id="taiji"></div>
    </body>
    </html>
21、换行之单词破、单词裹、省略号、js改变html的样式、特殊符号或图标
  (1)全部示例
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <title>换行之单词破、单词裹、省略号、js改变html的样式</title>
        <style>
          *{
            margin: 0;
            padding: 10px;
          }
          html{
            font-size: 20px;
          }
          .commonA{
            margin: 0 auto;
            width: 700px;
            background: gray;
            margin-top: 20px;
          }
          .A1{
            word-break: normal;
          }
          .A2{
            word-break: break-all;
          }
          .A3{
            word-break: keep-all;
          }
          .commonB{
            margin: 0 auto;
            width: 900px;
            background: gray;
            margin-top: 20px;
          }
          .B1{
            word-wrap: normal
          }
          .B2{
            word-wrap: break-word
          }
          .commonC{
            margin: 0 auto;
            width: 1100px;
            background: gray;
            margin-top: 20px;
          }
          .C1{
            white-space: normal;
          }
          .C2{
            white-space: nowrap;
          }
          .C3{
            white-space: pre-line;
          }
          .C4{
            white-space: pre;
          }
          .C5{
            white-space: pre-wrap;
          }
          .commonD{
            margin: 0 auto;
            width: 900px;
            background: gray;
            margin-top: 20px;
          }
          .D1{
            /* 以下,限制容器 */
            width: 900px;
            overflow: hidden;
            /* 以下,限制文本 */
            white-space: nowrap; /* 文本不换行(利用了空白处理中的不换行) */
            text-overflow: ellipsis; /* 文本省略号(隐藏文本超出容器宽度的部分,并显示...) */
          }
          .D2{
            /* 以下,限制容器 */
            width: 900px;
            overflow: hidden;
            display: -webkit-box; /* 将容器设置为弹性盒子 */
            -webkit-box-orient: vertical; /* 子元素的排列方向,为垂直方向(orient) */
            /* 以下,限制文本 */
            -webkit-line-clamp: 2; /* 文本显示的行数,隐藏文本超出容器高度的部分,并显示... */
            /* 以下,附加内容 */
            line-height: 40px; /* 因为用这个样式*{padding: 10px;},所以需要这行代码,否则下一行的上半部分会显示 */
          }
          .commonE{
            margin: 20px auto;
            width: 1100px;
            background: gray;
          }
          .E1{
            width: 200px;
            background: #fff;
            white-space: pre;
            /* white-space: pre-wrap;  */
            /* white-space: pre-line; */
          }
          .commonF{
            margin: 0 auto;
            width: 1100px;
            background: gray;
            margin-top: 20px;
          }
          .commonZ{
            padding-bottom: 30px;
          }
        </style>
      </head>
      <body>
        <div class="commonA">1、单词破,https://www.w3school.com.cn/cssref/pr_word-break.asp</div>
        <div class="commonA A1">A1、word-break: normal;使用浏览器默认的换行规则</div>
        <div class="commonA A2">A2、word-break: break-all;允许在单词内换行。常用----------------------</div>
        <div class="commonA A3">A3、word-break: keep-all;只能在半角空格或连字符处换行</div>
        <div class="commonB">2、单词裹,https://www.w3school.com.cn/cssref/pr_word-wrap.asp</div>
        <div class="commonB B1">B1、word-wrap: normal;只在允许的断字点换行(浏览器保持默认处理)</div>
        <div class="commonB B2">B2、word-wrap: break-word;在长单词或URL地址内部进行换行</div>
        <div class="commonC">3、空白,https://www.w3school.com.cn/cssref/pr_text_white-space.asp</div>
        <div class="commonC C1">C1、white-space: normal;默认。空白会被浏览器忽略。以下从<b>“空白符、换行符、超宽”</b>说明</div>
        <div class="commonC C2">C2、white-space: nowrap;--合并空白符,不留换行符,超宽不换行,直到遇到br标签为止</div>
        <div class="commonC C3">C3、white-space: pre-line;合并空白符,保留换行符,超宽会换行。</div>
        <div class="commonC C4">C4、white-space: pre;-----保留空白符,保留换行符,超宽不换行。其行为方式类似HTML中的pre标签</div>
        <div class="commonC C5">C5、white-space: pre-wrap;保留空白符,保留换行符,超宽会换行。常用----------------------</div>
        <div class="commonD">4、省略号</div>
        <div class="commonD D1">
          单行-省-略-号1;单行-省-略-号2;单行-省-略-号3;单行-省-略-号4;单行-省-略-号5;单行-省-略-号6;单行-省-略-号7;
        </div>
        <div class="commonD D2">
          多行-省-略-号1;多行-省-略-号1;多行-省-略-号1;多行-省-略-号1;多行-省-略-号1;多行-省-略-号1;多行-省-略-号1;
          多行-省-略-号2;多行-省-略-号2;多行-省-略-号2;多行-省-略-号2;多行-省-略-号2;多行-省-略-号2;多行-省-略-号2;
          多行-省-略-号3;多行-省-略-号3;多行-省-略-号3;多行-省-略-号3;多行-省-略-号3;多行-省-略-号3;多行-省-略-号3;
        </div>
        <div class="commonE">
          <div>5、换行测试</div>
          <div class="E1">
            右侧有5个空     格,且看超宽是否换行!
             
            2个换行
 
            .el-table .cell{//留出padding换行
              padding: 4px 8px;
              white-space: normal;
            }
          </div>
        </div>
        <div class="commonF">
          <div>6、js改变html样式</div>
          <div>
            <div>(1)\n:换行符;</div>
            <div>(2)\r:回车符(显示为换行);</div>
            <div>(3)\xa0:空白符,插入几个就显示几个空白符</div>
          </div>
          <div>7、html维持样式</div>
          <div>
            <div>(1)br:换行标签</div>
            <div>(2)没有:回车标签</div>
            <div>(3)&-nbsp;:一个转义字符,表示一个不间断的空格。多个显示1个,想显示多个,用pre标签</div>
            <div>(4)pre:定义预格式化文本的标签,保留空格和换行符。以下pre和&-nbsp;示例</div>
            <div>
              <pre>A、111         222</pre>
              <pre>B、111 222</pre>
            </div>
          </div>
          <div>8、常用css</div>
          <div>
            <div>(1)cursor: pointer</div>
            <div>(2)user-select: none</div>
            <div>(3)white-space: nowrap</div>
          </div>
        </div>
        <div class="commonZ"></div>
      </body>
    </html>     
  (2)html和css中的特殊符号或图标
    <html>
      <head>
        <style type="text/css">
          table{
            border-collapse: collapse;
          }
          table tr th,table tr td{
            border:1px solid grey;
            padding: 5px;
          }
          table tr td.color{
            color: green;
          }
          table tr td.empty::before {
            content: "\261E";
            display: inline-block;
            margin-right: 5px;
          }
        </style>
      </head>
      <body>
        <table>
          <thead>
            <tr>
              <th colspan="5">百度:在前端编程中&-nbsp;和&-#160;的区别</td>
            </tr>
            <tr>
              <th colspan="5">HTML代码和CSS代码来源:https://unicode-table.com/cn/</td>
            </tr>
            <tr>
              <th colspan="5">HTML代码和CSS代码来源:https://symbl.cc/cn/html-entities/</td>
            </tr>
            <tr>
              <th colspan="5">实体和html代码,去掉第2个字符“-”,就显示为图形</td>
            </tr>
            <tr>
              <th>图形</th>
              <th>实体</th>
              <th>html代码</th>
              <th>css代码</th>
              <th>css示例</th>
            </tr>
          </thead>
          <tbody>
            <tr class="color">
              <td class="color">  </td>
              <td class="color">&-nbsp;</td>
              <td class="color">&-#160;</td>
              <td class="color">\00A0</td>
              <td class="empty"></td>
            </tr>
            <tr>
              <td class="color"><</td>
              <td class="color">&-lt;</td>
              <td class="color">&-#60;</td>
              <td class="color">\003C</td>
              <td class="empty"></td>
            </tr>
            <tr>
              <td class="color">></td>
              <td class="color">&-gt;</td>
              <td class="color">&-#62;</td>
              <td class="color">\003E</td>
              <td class="empty"></td>
            </tr>
            <tr>
              <td class="color">&</td>
              <td class="color">&-amp;</td>
              <td class="color">&-#38;</td>
              <td class="color">\0026</td>
              <td class="empty"></td>
            </tr>
          </tbody>
        </table>
      </body>
    </html>
22、CSS伪类伪元素选择器
 来源:https://www.w3school.com.cn/css/css_pseudo_elements.asp
  (1)个例
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>伪元素</title>
        <style>
          .outer{
            display: flex;
            position: relative;
            align-items: center;
          }
          .inner {
            position: relative;
          }
          .inner+.inner {
            margin-left: 30px;
          }
          .active::after {
            content: '';
            display: block;
            width: 60%;
            height: 2px;
            background: #4582FF;
            /* 以上,伪元素形状;以下,伪元素位置 */
            margin-top: 4px;
            position: absolute;
            left: 20%;
          }
        </style>
      </head>
      <body>
        <div>以下,通过伪元素给元素添加下划线</div>
        <div class="outer">
          <div class="inner active">一二三</div>
          <div class="inner">一二三四五六</div>
          <div class="inner active">一二三四五六七八九</div>
        </div>
      </body>
    </html>
  (2)全部
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>伪类与伪元素</title>
        <style>
          h3:first-child{
            background-color: rgb(172, 219, 231);
          }
          div:nth-child(2){
            background-color: rgb(195, 219, 164);
          }
          div:nth-of-type(2){
            background-color: rgb(79, 177, 139);
          }
          p{
            font-size: 16px;
          }
          p::first-line {
            color: #ff0000;
          }
          p::after {
            content: '';
            display: inline-block;
            width: 10px;
            height: 10px;
            background: #ff0000;
          }
          ::selection { /* 使所选文本在蓝色背景上显示为红色 */
            color: red;
            background: blue;
          }
        </style>
      </head>
      <body>
        <p>p元素第1行<br/>p元素第2行</p>
        <pre>
          <h3>1、基本选择器</h3>
          <div>
            (1)*:通配选择器
            (2)E:元素选择器 选择指定类型的HTML元素
            (3)#id:ID选择器 选择指定ID属性值为“id”的任意类型元素
            (4).class:类选择器
            (5)selector1,selectorN:群组选择器
          </div>
          <h3>2、层次选择器</h3>
          <div>
            (1)E F:后代选择器
            (2)E>F:子选择器
            (3)E+F:相邻兄弟选择器
            (4)E~F:通用选择器,选择E元素后的所有匹配的F元素
          </div>
          <h3>3、伪类选择器</h3>
          <div>
            A、说明,
              (1)定义,为“在”文档树中的元素,添加不同状态,添加不同样式
              (2)语法,只能是:
            B、使用情形
              (1)链接
              (2)悬停
              (3)焦点
            C、示例1
              (1)a:link,选择所有未被访问的链接
              (2)a:hover,选择鼠标悬停其上的链接,:hover选择器可用于所有元素,不只是链接
              (3)a:active,选择活动的链接,鼠标按下去之后、弹起来之前的状态
              (4)a:visited,选择所有已访问的链接
              (5)input:checked,选择每个被选中的input元素
              (6)input:disabled,选择每个被禁用的input元素
              (7)input:enabled,选择每个已启用的input元素
              (8)input:focus,选择获得焦点的input元素
              (9)input:in-range,选择具有指定范围内的值的input元素
              (10)input:invalid,选择所有具有无效值的input元素
              (11)input:optional,选择不带"required"属性的input元素
              (12)input:out-of-range,选择值在指定范围之外的input元素
              (13)input:read-only,选择指定了"readonly"属性的input元素
              (14)input:read-write,选择不带"readonly"属性的input元素
              (15)input:required,选择指定了"required"属性的input元素
              (16)input:valid,选择所有具有有效值的input元素
            D、示例2
              (1)p:first-child,p作为子元素第1个出现时,则选中p元素
              (2)p:nth-child(2),p作为子元素第2个出现时,则选中p元素
              (3)p:last-child,p作为子元素倒数第1个出现时,则选中p元素
              (4)p:nth-last-child(2),p作为子元素倒数第2个出现时,则选中p元素
              (5)p:only-child,p作为子元素唯一1个出现时,则选中p元素
                h3:first-child{
                  background-color:rgb(172, 219, 231);
                }
                div:nth-child(2){
                  background-color:rgb(195, 219, 164);
                }
            E、示例3
              (1)p:first-of-type,p作为子元素第1次出现时,则选中p元素
              (2)p:nth-of-type(2),p作为子元素第2次出现时,则选中p元素
              (3)p:last-of-type,p作为子元素倒数第1次出现时,则选中p元素
              (4)p:nth-last-of-type(2),p作为子元素倒数第2次出现时,则选中p元素
              (5)p:only-of-type,p作为子元素唯一1种出现时,则选中p元素
                div:nth-of-type(2){
                  background-color:rgb(79, 177, 139);
                }
            F、示例4
              (1)p:empty,p元素没有子元素,则选中p元素
              (2)p:lang(it),p元素的lang属性值以"it"开头,则选中p元素;(span lang="fr")这里包含一些法语(/span)
              (3):not(p),不是p元素,则选中该元素
              (4):root,是根元素,则选中该元素
              (5)#news:target,选择当前活动的#news元素(单击包含该锚名称的 URL)
          </div>
          <h3>4、伪元素选择器</h3>
          <div>
            A、说明,
              (1)定义,创建“不在”文档树中的元素,创建虚拟元素,添加样式
              (2)语法,应该是::,可以是:
            B、使用情形
              (1)首字母、首行的样式
              (2)之前、之后插入内容
            C、示例1
              (1)p::after,在每个p元素内部的后面插入内容
              (2)p::before,在每个p元素内部的前面插入内容
              (3)p::first-letter,选择每个p元素的首字母
              (4)p::first-line,选择每个p元素的首行
              (5)p::selection,选择用户选择的元素部分
                p{
                  font-size: 16px;
                }
                p::first-line {
                  color: #ff0000;
                }
                p::after {
                  content: '';
                  display: inline-block;
                  width: 10px;
                  height: 10px;
                  background: #ff0000;
                }
                ::selection { //使所选文本在蓝色背景上显示为红色
                  color: red;
                  background: blue;
                }
          </div>
        </pre>
      </body>
    </html>
  (2)个例效果
    <!DOCTYPE html>
    <html>
      <head>
        <style>
          p::first-letter {
            font-size: 2em;
            color: blue;
          }
          p::after {
            content: '';
            display: inline-block;
            width: 10px;
            height: 10px;
            background: #ff0000;
          }
        </style>
      </head>
      <body>
        <p>This is a sample paragraph</p>
        <p>这是一个简单的段落</p>
      </body>
    </html>
23、底部中间三角形
  <!DOCTYPE html>
  <html lang="zh-CN">
    <head>
      <title>底部中间三角</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <style>
        .detail {
          background: #726e6e;
          border-radius: 6px;
          padding: 10px;
          margin: 20px;
        }
        .detail .border {
          border: 50px solid transparent;/* 边框宽度; 边框颜色; */
          border-top-color: #ccc;
          border-bottom-color: #ccc;
          border-left-color: gray;
          border-right-color: gray;
          border-radius: 6px;
        }
        .detail .zero {
          width: 0px;
          height: 0px;
        }
        .detail .noZero {
          width: 300px;
          height: 100px;
        }
        /* 以上是上图,以下是下图 -------------------------- */
        .arrow-box {
          position: relative;
          height: 160px;
          background: #ccc;
          border: 2px solid gray;
          border-radius: 6px;
        }
        .arrow-box::before, .arrow-box::after{
          position: absolute;
          top: 100%;
          left: 50%;
          border: solid transparent;
          content: "";
          height: 0;
          width: 0;
        }
        .arrow-box::before { /* 箭头自身颜色 */
          border-width: 15px; /* 边框宽度; */
          border-color: transparent; /* 边框颜色; */
          border-top-color: gray; /* 上边框颜色; */
          margin-left: -15px;
        }
        .arrow-box::after { /* 箭头内部颜色 */
          border-width: 12px; /* 边框宽度; */
          border-color: transparent; /* 边框颜色; */
          border-top-color: #ccc; /* 上边框颜色; */
          margin-left: -12px;
        }
        /* 说明:
            1、2个伪类元素的内容宽都为0,
            2、只能显示4个边框,每个边框都是指向中心的三角形
        */
      </style>
    </head>
    <body>
      <div class="detail">
        <div>(1)width、height都为0时,上下左右的border都是三角形。如下图</div>
        <div class="border zero"></div>
        <br/>
        <br/>
        <div>(2)width、height都不为0时,上下左右的border都是梯形。如下图</div>
        <div class="border noZero"></div>
      </div>
      <div class="arrow-box">底部中间三角。来源,https://www.wetools.com/css-arrow</div>
    </body>
  </html>
  
  

  

posted @ 2019-07-28 15:38  WEB前端工程师_钱成  阅读(3836)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示