-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1601 lines (1105 loc) · 92.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.3.0">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-shiff.jpg">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-shiff.jpg">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
<link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
<script src="/lib/pace/pace.min.js"></script>
<script id="hexo-configurations">
var NexT = window.NexT || {};
var CONFIG = {"hostname":"shiff.top","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":true},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
</script>
<meta name="description" content="千里之行,始于足下">
<meta property="og:type" content="website">
<meta property="og:title" content="微弱的光">
<meta property="og:url" content="http://shiff.top/index.html">
<meta property="og:site_name" content="微弱的光">
<meta property="og:description" content="千里之行,始于足下">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="shiff">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="http://shiff.top/">
<script id="page-configurations">
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome : true,
isPost : false,
lang : 'zh-CN'
};
</script>
<title>微弱的光</title>
<noscript>
<style>
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-header { opacity: initial; }
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
</style>
</noscript>
<link rel="alternate" href="/rss2.xml" title="微弱的光" type="application/rss+xml">
</head>
<body itemscope itemtype="http://schema.org/WebPage">
<div class="container use-motion">
<div class="headband"></div>
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<h1 class="site-title">微弱的光</h1>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger">
<i class="fa fa-search fa-fw fa-lg"></i>
</div>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="main-menu menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="fa fa-heart fa-fw"></i>首页</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>
</li>
<li class="menu-item menu-item-resources">
<a href="/resources/" rel="section"><i class="fa fa-download fa-fw"></i>资源</a>
</li>
<li class="menu-item menu-item-about">
<a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>
</li>
<li class="menu-item menu-item-search">
<a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
</a>
</li>
</ul>
</nav>
<div class="search-pop-overlay">
<div class="popup search-popup">
<div class="search-header">
<span class="search-icon">
<i class="fa fa-search"></i>
</span>
<div class="search-input-container">
<input autocomplete="off" autocapitalize="off"
placeholder="搜索..." spellcheck="false"
type="search" class="search-input">
</div>
<span class="popup-btn-close">
<i class="fa fa-times-circle"></i>
</span>
</div>
<div id="search-result">
<div id="no-result">
<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
</div>
</div>
</div>
</div>
</div>
</header>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
<main class="main">
<div class="main-inner">
<div class="content-wrap">
<div class="content index posts-expand">
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://shiff.top/2024/06/17/vue%E4%B8%AD%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E9%92%A9%E5%AD%90%E5%87%BD%E6%95%B0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars.githubusercontent.com/u/55538843?s=96&v=4">
<meta itemprop="name" content="shiff">
<meta itemprop="description" content="千里之行,始于足下">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="微弱的光">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/06/17/vue%E4%B8%AD%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E9%92%A9%E5%AD%90%E5%87%BD%E6%95%B0/" class="post-title-link" itemprop="url">vue中的生命周期钩子函数</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-06-17 13:27:59 / 修改时间:13:32:14" itemprop="dateCreated datePublished" datetime="2024-06-17T13:27:59+08:00">2024-06-17</time>
</span>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span>690</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span>1 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="vue中的生命周期钩子函数"><a href="#vue中的生命周期钩子函数" class="headerlink" title="vue中的生命周期钩子函数"></a>vue中的生命周期钩子函数</h1><p>在 Vue 3 中,生命周期函数总体上经历了一些改变,并引入了 Composition API,与 Vue 2.x 中的选项 API 有所不同。以下是 Vue 3 中常用的生命周期函数:</p>
<ol>
<li><p><strong>setup</strong>:组件创建阶段的入口,在组件实例创建之前执行,用于设置组件的初始状态、逻辑以及副作用操作等。</p>
</li>
<li><p><strong>beforeCreate</strong>:与 Vue 2.x 中的 <code>beforeCreate</code> 类似,在组件实例初始化之后,数据观测之前被调用。</p>
</li>
<li><p><strong>created</strong>:与 Vue 2.x 中的 <code>created</code> 类似,在实例创建完成后被调用,实例已完成数据观测、属性和方法运算。</p>
</li>
<li><p><strong>beforeMount</strong>:与 Vue 2.x 中的 <code>beforeMount</code> 类似,在挂载开始之前被调用,相关的 render 函数首次调用。</p>
</li>
<li><p><strong>mounted</strong>:与 Vue 2.x 中的 <code>mounted</code> 类似,在挂载结束后被调用,实例已挂载到 DOM 上。</p>
</li>
<li><p><strong>beforeUpdate</strong>:当数据更改导致虚拟 DOM 重新渲染之前调用。</p>
</li>
<li><p><strong>updated</strong>:当数据更改导致虚拟 DOM 重新渲染和打补丁后调用。</p>
</li>
<li><p><strong>beforeUnmount</strong>:在卸载组件之前调用。</p>
</li>
<li><p><strong>unmounted</strong>:在卸载组件后调用。</p>
</li>
<li><p><strong>errorCaptured</strong>:捕获组件子树中任何错误的处理器。</p>
</li>
</ol>
<p>除了上述生命周期函数外,Vue 3 还引入了 Composition API,开发者可以使用 <code>onMounted</code>、<code>onUpdated</code>、<code>onUnmounted</code> 等函数来实现类似生命周期钩子的功能。Composition API 提供了更灵活的方式来组织组件的逻辑。请注意,Vue 3 中的生命周期钩子函数与 Vue 2.x 中可能略有差异,主要是由于引入了 Composition API 的改变。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://shiff.top/2024/06/17/%E4%BD%BF%E7%94%A8%E7%BA%BF%E6%80%A7%E6%B8%90%E5%8F%98%E5%AE%9E%E7%8E%B0%E6%B8%90%E5%8F%98%E8%83%8C%E6%99%AF/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars.githubusercontent.com/u/55538843?s=96&v=4">
<meta itemprop="name" content="shiff">
<meta itemprop="description" content="千里之行,始于足下">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="微弱的光">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/06/17/%E4%BD%BF%E7%94%A8%E7%BA%BF%E6%80%A7%E6%B8%90%E5%8F%98%E5%AE%9E%E7%8E%B0%E6%B8%90%E5%8F%98%E8%83%8C%E6%99%AF/" class="post-title-link" itemprop="url">使用线性渐变实现渐变背景</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-06-17 09:57:06 / 修改时间:11:18:49" itemprop="dateCreated datePublished" datetime="2024-06-17T09:57:06+08:00">2024-06-17</time>
</span>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span>482</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span>1 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="使用线性渐变实现渐变背景"><a href="#使用线性渐变实现渐变背景" class="headerlink" title="使用线性渐变实现渐变背景"></a>使用线性渐变实现渐变背景</h1><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">background-image</span>: <span class="built_in">linear-gradient</span>(<span class="number">270deg</span>, <span class="number">#f66</span>, <span class="number">#ff9f9f</span>);</span><br></pre></td></tr></table></figure>
<p>这段CSS代码是用于设置元素的背景图片,但是这里使用的不是传统的图像文件,而是通过线性渐变(linear gradient)来实现背景效果。让我们来解释一下这段代码的含义:</p>
<ol>
<li><p><strong><code>background-image:</code></strong> 这是CSS属性,用于设置元素的背景图片。</p>
</li>
<li><p><strong><code>linear-gradient(270deg, #f66, #ff9f9f);</code></strong> 这是具体的背景图片值,表示使用线性渐变(从一个颜色过渡到另一个颜色)来创建背景。</p>
</li>
</ol>
<ul>
<li><p><strong><code>270deg</code></strong> 表示指定线性渐变的方向为270度,即从底部到顶部的垂直方向。</p>
</li>
<li><p><strong><code>#f66</code></strong> 和 <strong><code>#ff9f9f</code></strong> 是渐变的起始色和结束色。第一个颜色 <code>#f66</code> 代表浅红色,第二个是 <code>#ff9f9f</code> 代表淡红色。在这种情况下,从底部到顶部的背景将逐渐从浅红色过渡到淡红色。</p>
</li>
</ul>
<p>所以,这段代码的意思是设置元素的背景为从底部到顶部的垂直线性渐变,颜色过渡从浅红色(<code>#f66</code>)到淡红色(<code>#ff9f9f</code>)。这样的效果会创建一个具有渐变色的背景,使元素看起来更加丰富和动态。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://shiff.top/2024/06/17/Flex%E5%B8%83%E5%B1%80%E4%B8%8EGrid%E5%B8%83%E5%B1%80/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars.githubusercontent.com/u/55538843?s=96&v=4">
<meta itemprop="name" content="shiff">
<meta itemprop="description" content="千里之行,始于足下">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="微弱的光">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/06/17/Flex%E5%B8%83%E5%B1%80%E4%B8%8EGrid%E5%B8%83%E5%B1%80/" class="post-title-link" itemprop="url">Flex布局与Grid布局</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-06-17 09:46:29 / 修改时间:11:20:44" itemprop="dateCreated datePublished" datetime="2024-06-17T09:46:29+08:00">2024-06-17</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/CSS/" itemprop="url" rel="index"><span itemprop="name">CSS</span></a>
</span>
</span>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span>745</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span>1 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="Flex布局与Grid布局"><a href="#Flex布局与Grid布局" class="headerlink" title="Flex布局与Grid布局"></a>Flex布局与Grid布局</h1><p>Grid布局和Flex布局都是在CSS中用于进行页面布局的工具,它们各有优势和适用场景。以下是它们的一些异同点以及优缺点:</p>
<p><strong>异同点:</strong></p>
<ol>
<li><p><strong>相同点:</strong></p>
<ul>
<li>两者都是现代CSS布局工具,用于实现响应式布局和页面排版。</li>
<li>都支持对网格和弹性盒子进行灵活布局。</li>
<li>都可以在容器内部的子元素之间创建空间布局。</li>
</ul>
</li>
<li><p><strong>不同点:</strong></p>
<ul>
<li><p><strong>Flex布局(弹性布局):</strong></p>
<ul>
<li>适用于一维布局,例如在一条水平或垂直的轴线上布局元素。</li>
<li>适合于构建灵活的、水平或垂直居中的布局。</li>
<li>可以根据内容的大小来调整元素的尺寸。</li>
</ul>
</li>
<li><p><strong>Grid布局(网格布局):</strong></p>
<ul>
<li>适用于二维布局,可以在交叉轴上对元素进行定位,创建复杂的网格布局。</li>
<li>适用于规划复杂的网格结构,如页面布局的整体设计。</li>
<li>可以控制行与列交叉点的位置,实现更精确的布局设计。</li>
</ul>
</li>
</ul>
</li>
</ol>
<p><strong>优缺点:</strong></p>
<ol>
<li><p><strong>Flex布局优点:</strong></p>
<ul>
<li>简单实用,适合搭建基本的布局和页面结构。</li>
<li>支持响应式布局,更容易实现移动端适配,适合移动端开发。</li>
<li>配合弹性盒子布局的属性丰富,可以快速实现元素的排列和对齐。</li>
</ul>
<p><strong>缺点:</strong></p>
<ul>
<li>适用于相对简单布局,复杂的网格结构可能实现起来比较困难。</li>
<li>不太适合搭建复杂的多列布局。</li>
</ul>
</li>
<li><p><strong>Grid布局优点:</strong></p>
<ul>
<li>可以实现更复杂的网格布局,可以精确控制元素的位置和大小。</li>
<li>适合搭建大型网站和复杂的设计布局。</li>
<li>支持分区和定位,可以创建更灵活的页面结构。</li>
</ul>
<p><strong>缺点:</strong></p>
<ul>
<li>学习成本相对较高,语法相对复杂,初学者可能需要一定时间适应。</li>
<li>在一维布局方面不如Flex布局灵活,并不适用于所有布局场景。</li>
</ul>
</li>
</ol>
<p><strong>结论:</strong> </p>
<ul>
<li>如果页面结构相对简单,主要涉及到一维布局的元素排列和对齐,Flex布局是一个不错的选择。</li>
<li>如果需要实现复杂的二维布局,例如创建大型网格结构,Grid布局更适合用来实现。</li>
<li>在实际项目中,可以根据具体需求和布局复杂度来选择合适的布局方法,有时候也可以结合使用两者来实现更灵活和多样化的布局效果。</li>
</ul>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://shiff.top/2024/06/16/%E6%96%87%E6%9C%AC%E7%9A%84%E6%88%AA%E6%96%AD%E5%92%8C%E6%98%BE%E7%A4%BA%E6%8E%A7%E5%88%B6/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars.githubusercontent.com/u/55538843?s=96&v=4">
<meta itemprop="name" content="shiff">
<meta itemprop="description" content="千里之行,始于足下">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="微弱的光">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/06/16/%E6%96%87%E6%9C%AC%E7%9A%84%E6%88%AA%E6%96%AD%E5%92%8C%E6%98%BE%E7%A4%BA%E6%8E%A7%E5%88%B6/" class="post-title-link" itemprop="url">文本的截断和显示控制</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-06-16 23:32:11" itemprop="dateCreated datePublished" datetime="2024-06-16T23:32:11+08:00">2024-06-16</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-06-17 09:48:19" itemprop="dateModified" datetime="2024-06-17T09:48:19+08:00">2024-06-17</time>
</span>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span>392</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span>1 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="文本的截断和显示控制"><a href="#文本的截断和显示控制" class="headerlink" title="文本的截断和显示控制"></a>文本的截断和显示控制</h1><p>下面三个属性通常用于在Web开发中对文本进行截断和显示控制,主要用于控制文本在容器中的显示方式。具体含义如下:</p>
<ol>
<li><p><code>display: -webkit-box;</code>:这个属性用于指定元素应该生成一个块级容器框。在这种布局模型中,元素是一个块级容器,可以在内部容纳其他元素。在这种情况下,通常需要与其他属性结合使用。</p>
</li>
<li><p><code>-webkit-line-clamp: 2;</code>:这个属性用于指定显示的行数限制。在文本溢出时,只显示指定行数的文本内容。上面的例子中,只显示不超过两行的文本内容。</p>
</li>
<li><p><code> -webkit-box-orient: vertical;</code>:这个属性用于指定盒子的排列方向。在这种情况下,盒子内的元素垂直排列。</p>
</li>
</ol>
<p>这些属性通常与前缀 <code>-webkit-</code> 一起使用,表示这些属性是Webkit浏览器专有的CSS扩展。这些属性主要用于控制元素的显示方式,特别是在限制文本显示行数和盒子内元素排列方向方面。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://shiff.top/2024/06/14/text-overflow%E7%9A%84%E7%94%A8%E6%B3%95/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars.githubusercontent.com/u/55538843?s=96&v=4">
<meta itemprop="name" content="shiff">
<meta itemprop="description" content="千里之行,始于足下">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="微弱的光">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/06/14/text-overflow%E7%9A%84%E7%94%A8%E6%B3%95/" class="post-title-link" itemprop="url">text-overflow的用法</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-06-14 18:15:57 / 修改时间:18:16:26" itemprop="dateCreated datePublished" datetime="2024-06-14T18:15:57+08:00">2024-06-14</time>
</span>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span>444</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span>1 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="text-overflow的用法"><a href="#text-overflow的用法" class="headerlink" title="text-overflow的用法"></a>text-overflow的用法</h1><p><code>text-overflow</code>是CSS样式属性,用于控制当文本溢出容器时如何显示。</p>
<p>常见的取值有:</p>
<ul>
<li><code>clip</code>:默认值,表示将溢出的部分隐藏。</li>
<li><code>ellipsis</code>:表示将溢出的文本显示为省略号(…)。</li>
<li><code>inherit</code>:继承父元素的文本溢出样式。</li>
</ul>
<p>示例:</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.text-ellipsis</span> {</span><br><span class="line"> <span class="attribute">white-space</span>: nowrap; <span class="comment">/* 不换行 */</span></span><br><span class="line"> <span class="attribute">overflow</span>: hidden; <span class="comment">/* 溢出隐藏 */</span></span><br><span class="line"> <span class="attribute">text-overflow</span>: ellipsis; <span class="comment">/* 超出部分以省略号显示 */</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>在上面的示例中,当文本内容超出容器的宽度时,将以省略号的形式显示。需要注意的是,通常需要配合<code>white-space: nowrap;</code>和<code>overflow: hidden;</code>这两个样式属性一起使用,来确保省略号的效果正常显示。</p>
<p><code>text-overflow</code>通常用于单行文本或者内联元素,对于多行文本或块级元素,更适合使用<code>-webkit-line-clamp</code>结合<code>-webkit-box</code>来实现类似的效果。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://shiff.top/2024/06/14/less%E4%B8%AD%E7%9A%84&%E7%AC%A6%E5%8F%B7/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars.githubusercontent.com/u/55538843?s=96&v=4">
<meta itemprop="name" content="shiff">
<meta itemprop="description" content="千里之行,始于足下">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="微弱的光">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/06/14/less%E4%B8%AD%E7%9A%84&%E7%AC%A6%E5%8F%B7/" class="post-title-link" itemprop="url">less中的&符号</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-06-14 11:23:54 / 修改时间:11:25:56" itemprop="dateCreated datePublished" datetime="2024-06-14T11:23:54+08:00">2024-06-14</time>
</span>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span>1.4k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span>1 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="less中的-amp-符号"><a href="#less中的-amp-符号" class="headerlink" title="less中的&符号"></a>less中的&符号</h1><p>在 Less 预处理器中,<code>&</code> 符号用于引用当前选择器的父级。这在嵌套规则中非常有用,可以帮助生成更复杂的选择器,而不需要重复父选择器的名称。</p>
<h3 id="基本用法"><a href="#基本用法" class="headerlink" title="基本用法"></a>基本用法</h3><p>在 Less 中,<code>&</code> 符号代表父选择器,可以用来构建更复杂的选择器规则。例如:</p>
<figure class="highlight less"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">color</span>: black;</span><br><span class="line"> </span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-pseudo">:hover</span> {</span><br><span class="line"> <span class="attribute">color</span>: blue;</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-pseudo">::before</span> {</span><br><span class="line"> <span class="attribute">content</span>: <span class="string">"Prefix"</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>编译后的 CSS 如下:</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">color</span>: black;</span><br><span class="line">}</span><br><span class="line"><span class="selector-class">.container</span><span class="selector-pseudo">:hover</span> {</span><br><span class="line"> <span class="attribute">color</span>: blue;</span><br><span class="line">}</span><br><span class="line"><span class="selector-class">.container</span><span class="selector-pseudo">::before</span> {</span><br><span class="line"> <span class="attribute">content</span>: <span class="string">"Prefix"</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h3 id="具体示例"><a href="#具体示例" class="headerlink" title="具体示例"></a>具体示例</h3><p>以下是一些常见的 <code>&</code> 符号用法示例:</p>
<h4 id="1-伪类和伪元素"><a href="#1-伪类和伪元素" class="headerlink" title="1. 伪类和伪元素"></a>1. 伪类和伪元素</h4><figure class="highlight less"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.button</span> {</span><br><span class="line"> <span class="attribute">background-color</span>: green;</span><br><span class="line"> </span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-pseudo">:hover</span> {</span><br><span class="line"> <span class="attribute">background-color</span>: darkgreen;</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-pseudo">::after</span> {</span><br><span class="line"> <span class="attribute">content</span>: <span class="string">" (hover me)"</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>编译后的 CSS:</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.button</span> {</span><br><span class="line"> <span class="attribute">background-color</span>: green;</span><br><span class="line">}</span><br><span class="line"><span class="selector-class">.button</span><span class="selector-pseudo">:hover</span> {</span><br><span class="line"> <span class="attribute">background-color</span>: darkgreen;</span><br><span class="line">}</span><br><span class="line"><span class="selector-class">.button</span><span class="selector-pseudo">::after</span> {</span><br><span class="line"> <span class="attribute">content</span>: <span class="string">" (hover me)"</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h4 id="2-子选择器"><a href="#2-子选择器" class="headerlink" title="2. 子选择器"></a>2. 子选择器</h4><figure class="highlight less"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.nav</span> {</span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-tag">-item</span> {</span><br><span class="line"> <span class="attribute">color</span>: red;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>编译后的 CSS:</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.nav-item</span> {</span><br><span class="line"> <span class="attribute">color</span>: red;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h4 id="3-父选择器引用"><a href="#3-父选择器引用" class="headerlink" title="3. 父选择器引用"></a>3. 父选择器引用</h4><figure class="highlight less"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.list</span> {</span><br><span class="line"> <span class="selector-class">.list-item</span> {</span><br><span class="line"> <span class="attribute">color</span>: blue;</span><br><span class="line"> </span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-class">.active</span> {</span><br><span class="line"> <span class="attribute">color</span>: darkblue;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>编译后的 CSS:</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.list</span> <span class="selector-class">.list-item</span> {</span><br><span class="line"> <span class="attribute">color</span>: blue;</span><br><span class="line">}</span><br><span class="line"><span class="selector-class">.list</span> <span class="selector-class">.list-item</span><span class="selector-class">.active</span> {</span><br><span class="line"> <span class="attribute">color</span>: darkblue;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h4 id="4-嵌套媒体查询"><a href="#4-嵌套媒体查询" class="headerlink" title="4. 嵌套媒体查询"></a>4. 嵌套媒体查询</h4><figure class="highlight less"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">100%</span>;</span><br><span class="line"> </span><br><span class="line"> <span class="keyword">@media</span> (<span class="attribute">min-width</span>: <span class="number">768px</span>) {</span><br><span class="line"> <span class="selector-tag">&</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">50%</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>编译后的 CSS:</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">100%</span>;</span><br><span class="line">}</span><br><span class="line"><span class="keyword">@media</span> (<span class="attribute">min-width</span>: <span class="number">768px</span>) {</span><br><span class="line"> <span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">50%</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h3><p><code>&</code> 符号在 Less 中非常强大,可以帮助你避免重复代码,并使样式表更具可读性和可维护性。通过合理使用 <code>&</code> 符号,可以轻松创建复杂的选择器规则,提升 CSS 编写的效率和灵活性。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://shiff.top/2024/06/14/overflow%E7%9A%84%E7%94%A8%E6%B3%95/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars.githubusercontent.com/u/55538843?s=96&v=4">
<meta itemprop="name" content="shiff">
<meta itemprop="description" content="千里之行,始于足下">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="微弱的光">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/06/14/overflow%E7%9A%84%E7%94%A8%E6%B3%95/" class="post-title-link" itemprop="url">overflow的用法</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-06-14 11:05:16 / 修改时间:11:07:37" itemprop="dateCreated datePublished" datetime="2024-06-14T11:05:16+08:00">2024-06-14</time>
</span>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span>1.4k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span>1 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="Overflow的用法"><a href="#Overflow的用法" class="headerlink" title="Overflow的用法"></a>Overflow的用法</h1><p><code>overflow</code> 是 CSS 中的一个属性,用于控制元素内容在水平方向和垂直方向上的溢出行为。它决定了当内容溢出元素的尺寸时,是否显示滚动条、截断内容或其他处理方式。</p>
<h3 id="语法"><a href="#语法" class="headerlink" title="语法"></a>语法</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">overflow</span>: visible | hidden | scroll | auto;</span><br></pre></td></tr></table></figure>
<h3 id="属性值"><a href="#属性值" class="headerlink" title="属性值"></a>属性值</h3><ul>
<li><code>visible</code>:默认值。内容不会被剪裁,会呈现在元素框之外。</li>
<li><code>hidden</code>:溢出内容会被剪裁(隐藏),不会显示滚动条。</li>
<li><code>scroll</code>:无论内容是否溢出,都会显示滚动条。</li>
<li><code>auto</code>:如果内容溢出,浏览器会自动显示滚动条。</li>
</ul>
<h3 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h3><p>假设有一个包含大量文本的容器:</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag"><<span class="name">div</span> <span class="attr">class</span>=<span class="string">"container"</span>></span></span><br><span class="line"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.</span><br><span class="line"><span class="tag"></<span class="name">div</span>></span></span><br></pre></td></tr></table></figure>
<p>CSS 代码如下:</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow</span>: auto; <span class="comment">/* 自动显示滚动条 */</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>在这个例子中:</p>
<ul>
<li>当容器的内容宽度或高度超过 200px 或 100px 时,浏览器会自动显示水平或垂直滚动条,以便用户可以滚动查看内容。</li>
</ul>
<h3 id="各属性值示例"><a href="#各属性值示例" class="headerlink" title="各属性值示例"></a>各属性值示例</h3><ol>
<li><code>visible</code>:</li>
</ol>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow</span>: visible;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>内容会溢出容器,不会显示滚动条。</p>
<ol start="2">
<li><code>hidden</code>:</li>
</ol>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow</span>: hidden;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>内容会被剪裁,溢出部分不可见,不会显示滚动条。</p>
<ol start="3">
<li><code>scroll</code>:</li>
</ol>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow</span>: scroll;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>无论内容是否溢出,都会显示滚动条。</p>
<ol start="4">
<li><code>auto</code>:</li>
</ol>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow</span>: auto;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>当内容溢出时,浏览器会自动显示滚动条。</p>
<h3 id="组合使用-overflow-x-和-overflow-y"><a href="#组合使用-overflow-x-和-overflow-y" class="headerlink" title="组合使用 overflow-x 和 overflow-y"></a>组合使用 <code>overflow-x</code> 和 <code>overflow-y</code></h3><p>有时你可能需要分别控制水平方向和垂直方向的溢出行为,这时可以使用 <code>overflow-x</code> 和 <code>overflow-y</code> 属性。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow-x</span>: auto; <span class="comment">/* 水平方向自动显示滚动条 */</span></span><br><span class="line"> <span class="attribute">overflow-y</span>: hidden; <span class="comment">/* 垂直方向隐藏溢出内容 */</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h3 id="注意事项"><a href="#注意事项" class="headerlink" title="注意事项"></a>注意事项</h3><ul>
<li><code>overflow</code> 属性仅在元素具有限定的宽度和高度时起作用。</li>
<li><code>overflow</code> 属性常用于创建滚动区域,特别是在布局响应式设计中。</li>
</ul>
<p>通过合理使用 <code>overflow</code> 属性,可以更好地控制元素内容在水平方向和垂直方向上的显示方式,提升页面的可读性和用户体验。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="http://shiff.top/2024/05/24/Axios%E5%AD%A6%E4%B9%A0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars.githubusercontent.com/u/55538843?s=96&v=4">
<meta itemprop="name" content="shiff">
<meta itemprop="description" content="千里之行,始于足下">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="微弱的光">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/05/24/Axios%E5%AD%A6%E4%B9%A0/" class="post-title-link" itemprop="url">Axios学习</a>
</h2>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-05-24 16:32:36" itemprop="dateCreated datePublished" datetime="2024-05-24T16:32:36+08:00">2024-05-24</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-05-25 16:42:40" itemprop="dateModified" datetime="2024-05-25T16:42:40+08:00">2024-05-25</time>
</span>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span>3.3k</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span>3 分钟</span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="Axiso库"><a href="#Axiso库" class="headerlink" title="Axiso库"></a>Axiso库</h1><p><strong>官方介绍:</strong></p>