-
Notifications
You must be signed in to change notification settings - Fork 0
/
css3_box-sizing.html
1145 lines (1097 loc) · 57.1 KB
/
css3_box-sizing.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="en-US">
<!-- Mirrored from www.w3schools.com/css/css3_box-sizing.asp by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 04 Jun 2018 20:20:40 GMT -->
<head>
<title>CSS Box Sizing</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Keywords" content="HTML,CSS,JavaScript,SQL,PHP,jQuery,XML,DOM,Bootstrap,Web development,W3C,tutorials,programming,training,learning,quiz,primer,lessons,references,examples,source code,colors,demos,tips">
<meta name="Description" content="Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, and XML.">
<link rel="icon" href="https://www.w3schools.com/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="../w3css/4/w3.css">
<style>
a:hover,a:active{color:#4CAF50}
table.w3-table-all{margin:20px 0}
/*OPPSETT AV TOP, TOPNAV, SIDENAV, MAIN, RIGHT OG FOOTER:*/
.top {
position:relative;
background-color:#ffffff;
height:68px;
padding-top:20px;
line-height:50px;
overflow:hidden;
z-index:2;
}
.w3schools-logo {
font-family:fontawesome;
text-decoration:none;
line-height:1;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale;
font-size:37px;
letter-spacing:3px;
color:#555555;
display:block;
position:absolute;
top:17px;
}
.w3schools-logo .dotcom {color:#4CAF50}
.topnav {
position:relative;
z-index:2;
font-size:17px;
background-color:#5f5f5f;
color:#f1f1f1;
width:100%;
padding:0;
letter-spacing:1px;
font-family:"Segoe UI",Arial,sans-serif;
}
.topnav a{
padding:10px 15px 9px 15px !important;
}
.topnav .w3-bar a:hover,.topnav .w3-bar a:focus{
background-color:#000000 !important;
color:#ffffff !important;
}
.topnav .w3-bar a.active {
background-color:#4CAF50;
color:#ffffff;
}
a.topnav-icons {
width:52px !important;
font-size:20px !important;
padding-top:11px !important;
padding-bottom:13px !important;
}
a.topnav-icons.fa-home {font-size:22px !important}
a.topnav-icons.fa-menu {font-size:22px !important}
a.topnav-localicons {
font-size:20px !important;
padding-top:6px !important;
padding-bottom:12px !important;
}
i.fa-caret-down,i.fa-caret-up{width:10px}
#sidenav h2 {
font-size:21px;
padding-left:16px;
margin:-4px 0 4px 0;
width:204px;
}
#sidenav a {font-family:"Segoe UI",Arial,sans-serif;text-decoration:none;display:block;padding:2px 1px 1px 16px}
#sidenav a:hover,#sidenav a:focus {color:#000000;background-color:#cccccc;}
#sidenav a.active {background-color:#4CAF50;color:#ffffff}
#leftmenuinner {
position:fixed;
top:0;
padding-top:112px;
padding-bottom:0;
height:100%;
width:220px;
background-color:transparent;
}
#leftmenuinnerinner {
height:100%;
width:100%;
overflow-y:scroll;
overflow-x:hidden;
padding-top:20px;
}
#main {padding:16px}
#mainLeaderboard {height:90px}
#right {text-align:center;padding:16px 16px 0 0}
#right a {text-decoration:none}
#right a:hover {text-decoration:underline}
#skyscraper {min-height:600px}
.sidesection {margin-bottom:32px;}
.bottomad {padding:0 16px 16px 0;float:left;width:auto;}
.footer a {text-decoration:none;}
.footer a:hover{text-decoration:underline;}
#nav_tutorials,#nav_references,#nav_examples{-webkit-overflow-scrolling:touch;overflow:auto;}
#nav_tutorials::-webkit-scrollbar,#nav_references::-webkit-scrollbar,#nav_examples::-webkit-scrollbar {width: 12px;}
#nav_tutorials::-webkit-scrollbar-track,#nav_references::-webkit-scrollbar-track,#nav_examples::-webkit-scrollbar-track {background:#555555;}
#nav_tutorials::-webkit-scrollbar-thumb,#nav_references::-webkit-scrollbar-thumb,#nav_examples::-webkit-scrollbar-thumb {background: #999999;}
#nav_tutorials,#nav_references,#nav_examples {
display:none;
letter-spacing:0;
margin-top:44px;
}
#nav_tutorials a,#nav_references a,#nav_examples a{
padding:2px 0 2px 6px!important;
}
#nav_tutorials a:focus,#nav_references a:focus,#nav_examples a:focus{
color: #000;
background-color: #ccc;
}
#nav_tutorials h3,#nav_references h3,#nav_examples h3{
padding-left:6px;
}
.w3-example{background-color:#f1f1f1;padding:0.01em 16px;margin:20px 0;box-shadow:0 2px 4px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12)!important}
.nextprev a {font-size:17px;border:1px solid #cccccc;}
.nextprev a:link,.nextprev a:visited {background-color:#ffffff;color:#000000;}
.w3-example a:focus,.nextprev a:focus{box-shadow:0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);}
.nextprev a.w3-right,.nextprev a.w3-left {background-color:#4CAF50;color:#ffffff;border-color:#4CAF50}
.w3-theme {color:#fff !important;background-color:#73AD21 !important;background-color:#4CAF50 !important}
.w3-theme-border {border-color:#4CAF50 !important}
.sharethis a:hover {color:inherit;}
.fa-facebook-square,.fa-twitter-square,.fa-google-plus-square {padding:0 8px;}
.fa-facebook-square:hover, .fa-thumbs-o-up:hover {color:#3B5998;}
.fa-twitter-square:hover {color:#55acee;}
.fa-google-plus-square:hover {color:#dd4b39;}
#google_translate_element img {margin-bottom:-1px;}
#googleSearch {color:#000000;}
#googleSearch a {padding:0 !important;}
.searchdiv {max-width:400px;margin:auto;text-align:left;font-size:16px}
div.cse .gsc-control-cse, div.gsc-control-cse {background-color:transparent;border:none;padding:6px;margin:0px}
td.gsc-search-button input.gsc-search-button {background-color:#4CAF50;border-color:#4CAF50}
td.gsc-search-button input.gsc-search-button:hover {background-color:#46a049;}
input.gsc-input, .gsc-input-box, .gsc-input-box-hover, .gsc-input-box-focus, .gsc-search-button {
box-sizing:content-box; line-height:normal;}
.gsc-tabsArea div {overflow:visible;}
/*"nullstille" w3css:*/
.w3-main{transition:margin-left 0s;}
/*"nullstilling" slutt*/
@media (min-width:1675px) {
#main {width:79%}
#right {width:21%}
}
@media (max-width:992px) {
.top {height:100px}
.top img {display:block;margin:auto;}
.top .w3schools-logo {position:relative;top:0;width:100%;text-align:center;margin:auto}
.toptext {width:100%;text-align:center}
#sidenav {width:260px;}
#sidenav h2 {font-size:26px;width:100%;}
#sidenav a {padding:3px 2px 3px 24px;font-size:17px}
#leftmenuinner {
box-shadow:0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
overflow:auto;
-webkit-overflow-scrolling:touch;
height:100%;
position:relative;
width:auto;
padding-top:0;
background-color:#f1f1f1;
}
#leftmenuinnerinner {overflow-y:scroll}
.bottomad {float:none;text-align:center}
#skyscraper {min-height:60px}
}
@media screen and (max-width:600px) {
.top {height:68px}
.toptext {display:none}
}
@font-face {
font-family:'fontawesome';
src: url('https://www.w3schools.com/lib/fonts/fontawesome.eot?14663396');
src:url('https://www.w3schools.com/lib/fonts/fontawesome.eot?14663396#iefix') format('embedded-opentype'),
url('https://www.w3schools.com/lib/fonts/fontawesome.woff?14663396') format('woff'),
url('https://www.w3schools.com/lib/fonts/fontawesome.ttf?14663396') format('truetype'),
url('https://www.w3schools.com/lib/fonts/fontawesome.svg?14663396#fontawesome') format('svg');
font-weight:normal;
font-style:normal;
}
.fa {
display:inline-block;
font:normal normal normal 14px/1 FontAwesome;
font-size:inherit;
text-rendering:auto;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale;
transform:translate(0, 0);
}
.fa-2x {
font-size:2em;
}
.fa-home:before {content:'\e800';}
.fa-menu:before {content: '\f0c9';}
.fa-globe:before {content:'\e801';}
.fa-search:before {content:'\e802'; }
.fa-thumbs-o-up:before {content:'\e803';}
.fa-left-open:before {content:'\e804';}
.fa-right-open:before {content:'\e805';}
.fa-facebook-square:before {content:'\e806';}
.fa-google-plus-square:before {content:'\e807';}
.fa-twitter-square:before {content:'\e808';}
.fa-caret-down:before {content:'\e809';}
.fa-caret-up:before {content:'\e80a';}
span.marked, span.deprecated {
color:#e80000;
background-color:transparent;
}
.intro {font-size:16px}
.w3-btn, .w3-btn:link, .w3-btn:visited {color:#FFFFFF;background-color:#4CAF50}
a.w3-btn[href*="exercise.asp"] {margin:10px 5px 0 0}
a.btnplayit,a.btnplayit:link,a.btnplayit:visited {background-color:#FFAD33;padding:1px 10px 2px 10px}
a.btnplayit:hover,a.btnplayit:active {background-color:#ffffff;color:#FFAD33}
a.btnplayit:hover {box-shadow:0 4px 8px 0 rgba(0,0,0,0.2);}
a.btnsmall:link,a.btnsmall:visited,a.btnsmall:active,a.btnsmall:hover {
float:right;padding:1px 10px 2px 10px;font:15px Verdana, sans-serif;}
a.btnsmall:hover {box-shadow:0 4px 8px 0 rgba(0,0,0,0.2);}
a.btnsmall:active,a.btnsmall:hover {color:#4CAF50;background-color:#ffffff}
@media screen and (max-width:700px) {
#mainLeaderboard {height:60px}
#div-gpt-ad-1422003450156-0 {float:none;margin-left:auto;margin-right:auto}
#div-gpt-ad-1422003450156-3 {float:none;margin-left:auto;margin-right:auto}
}
@media (max-width:1700px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(17){display:none;}}
@media (max-width:1600px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(13){display:none;}}
@media (max-width:1510px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(12){display:none;}}
@media (max-width:1450px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(11){display:none;}}
@media (max-width:1330px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(10){display:none;}}
@media (max-width:1200px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(9){display:none;}}
@media (max-width:1100px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(8){display:none;}}
@media (max-width:1000px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(7){display:none;}}
@media (max-width:992px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(6){display:none;}}
@media (max-width:930px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(18){display:none;}}
@media (max-width:800px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(19){display:none;}}
@media (max-width:650px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(5){display:none;} #topnav .w3-bar:nth-of-type(1) a:nth-of-type(16){display:none;}}
@media (max-width:460px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(4){display:none;}}
@media (max-width:400px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(3){display:none;}}
.w3-note{background-color:#ffffcc;border-left:6px solid #ffeb3b}
.w3-warning{background-color:#ffdddd;border-left:6px solid #f44336}
.w3-info{background-color:#ddffdd;border-left:6px solid #4CAF50}
hr[id^="ez-insert-after-placeholder"] {margin-top: 0;}
</style>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','../../www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-3855518-1', 'auto');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
<script async="async" type="text/javascript" src="../../static.h-bid.com/w3schools.com/20180525/snhb-w3schools.min.js"></script>
<script type='text/javascript'>
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
gads.src = '../../www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
var snhb = snhb || {}; snhb.queue = snhb.queue || [];
snhb.options = {
logOutputEnabled : false,
autoStartAuction: false,
gdpr: {
mainGeo: "us",
reconsiderationAppealIntervalSeconds: 0
}
};
// GPT slots
var gptAdSlots = [];
googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
googletag.pubads().enableSingleRequest();
var leaderMapping = googletag.sizeMapping().
// Mobile ad
addSize([0, 0], [320, 50]).
// Vertical Tablet ad
addSize([480, 0], [468, 60]).
// Horizontal Tablet
addSize([780, 0], [728, 90]).
// Small Desktop
addSize([993, 0], [468, 60]).
// Normal Desktop
addSize([1150, 0], [728, 90]).
// Large Desktop and bigger ad
addSize([1425, 0], [[728, 90], [970, 90]]).build();
gptAdSlots[0] = googletag.defineSlot('/16833175/MainLeaderboard', [[728, 90], [970, 90]], 'div-gpt-ad-1422003450156-2').
defineSizeMapping(leaderMapping).addService(googletag.pubads());
var skyMapping = googletag.sizeMapping().
// Mobile ad
addSize([0, 0], [320, 50]).
// Tablet ad
addSize([975, 0], [120, 600]).
// Desktop
addSize([1135, 0], [160, 600]).
// Large Desktop
addSize([1675, 0], [[160, 600], [300, 600], [300, 1050]]).build();
gptAdSlots[1] = googletag.defineSlot('/16833175/WideSkyScraper', [[160, 600], [300, 600], [300, 1050]], 'div-gpt-ad-1422003450156-5').
defineSizeMapping(skyMapping).addService(googletag.pubads());
var stickyMapping = googletag.sizeMapping().
// Mobile ad
addSize([0, 0], []).
// Tablet ad
addSize([975, 0], [120, 600]).
// Desktop
addSize([1135, 0], [160, 600]).
// Large Desktop
addSize([1675, 0], [[160, 600], [300, 600], [300, 250]]).build();
gptAdSlots[4] = googletag.defineSlot('/16833175/StickySkyScraper', [[300, 600], [120, 600], [300, 250], [160, 600]], 'div-gpt-ad-1472547360578-0').
defineSizeMapping(stickyMapping).addService(googletag.pubads());
var mcontMapping = googletag.sizeMapping().
// Mobile ad
addSize([0, 0], [[300, 250], [336, 280], [320, 50]]).
// Vertical Tablet ad
addSize([490, 0], [[300, 250], [336, 280], [468, 60]]).
// Horizontal Tablet
addSize([750, 0], [728, 90]).
// Small Desktop
addSize([993, 0], [[300, 250], [336, 280], [468, 60]]).
// Normal Desktop
addSize([1135, 0], [728, 90]).
// Large Desktop and bigger ad
addSize([1440, 0], [[728, 90], [970, 90], [970, 250]]).build();
gptAdSlots[5] = googletag.defineSlot('/16833175/MidContent', [[300, 250], [336, 280]], 'div-gpt-ad-1493883843099-0').
defineSizeMapping(mcontMapping).setCollapseEmptyDiv(true).addService(googletag.pubads());
var bmrMapping = googletag.sizeMapping().
// Smaller
addSize([0, 0], [[300, 250], [336, 280]]).
// Large Desktop
addSize([1240, 0], [[300, 250], [336, 280], [970, 250]]).build();
gptAdSlots[2] = googletag.defineSlot('/16833175/BottomMediumRectangle', [[300, 250], [336, 280], [970, 250]], 'div-gpt-ad-1422003450156-0').
defineSizeMapping(bmrMapping).setCollapseEmptyDiv(true).addService(googletag.pubads());
var rbmrMapping = googletag.sizeMapping().
// Smaller
addSize([0, 0], []).
// Large Desktop
addSize([975, 0], [[300, 250], [336, 280]]).build();
gptAdSlots[3] = googletag.defineSlot('/16833175/RightBottomMediumRectangle', [[300, 250], [336, 280]], 'div-gpt-ad-1422003450156-3').
defineSizeMapping(rbmrMapping).setCollapseEmptyDiv(true).addService(googletag.pubads());
googletag.pubads().setTargeting("content",(function () {
var folder = location.pathname;
folder = folder.replace("https://www.w3schools.com/", "");
folder = folder.substr(0, folder.indexOf("https://www.w3schools.com/"));
return folder;
})()
);
snhb.queue.push(function(){
snhb.addAdditionalAdSlotsToRefresh(gptAdSlots);
});
googletag.enableServices();
});
</script>
<script src="../../static.h-bid.com/gdpr/cmp.stub.js" type="text/javascript"></script>
<script type='text/javascript'>
var stickyadstatus = "";
function fix_stickyad() {
document.getElementById("stickypos").style.position = "sticky";
var elem = document.getElementById("stickyadcontainer");
if (!elem) {return false;}
if (document.getElementById("skyscraper")) {
var skyWidth = Number(w3_getStyleValue(document.getElementById("skyscraper"), "width").replace("px", ""));
}
else {
var skyWidth = Number(w3_getStyleValue(document.getElementById("right"), "width").replace("px", ""));
}
elem.style.width = skyWidth + "px";
if (window.innerWidth <= 992) {
elem.style.position = "";
elem.style.top = stickypos + "px";
return false;
}
var stickypos = document.getElementById("stickypos").offsetTop;
var docTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
var adHeight = Number(w3_getStyleValue(elem, "height").replace("px", ""));
if (stickyadstatus == "") {
if ((stickypos - docTop) < 60) {
elem.style.position = "fixed";
elem.style.top = "60px";
stickyadstatus = "sticky";
document.getElementById("stickypos").style.position = "sticky";
}
} else {
if ((docTop + 60) - stickypos < 0) {
elem.style.position = "";
elem.style.top = stickypos + "px";
stickyadstatus = "";
document.getElementById("stickypos").style.position = "static";
}
}
if (stickyadstatus == "sticky") {
if ((docTop + adHeight + 60) > document.getElementById("footer").offsetTop) {
elem.style.position = "absolute";
elem.style.top = (document.getElementById("footer").offsetTop - adHeight) + "px";
document.getElementById("stickypos").style.position = "static";
} else {
elem.style.position = "fixed";
elem.style.top = "60px";
stickyadstatus = "sticky";
document.getElementById("stickypos").style.position = "sticky";
}
}
}
function w3_getStyleValue(elmnt,style) {
if (window.getComputedStyle) {
return window.getComputedStyle(elmnt,null).getPropertyValue(style);
} else {
return elmnt.currentStyle[style];
}
}
</script>
<style>
#div1 {
width: 300px;
height: 100px;
border: 1px solid blue;
box-sizing: content-box;
}
#div2 {
width: 300px;
height: 100px;
padding: 50px;
border: 1px solid red;
box-sizing: content-box;
}
#div3 {
width: 300px;
height: 100px;
border: 1px solid blue;
box-sizing: border-box;
}
#div4 {
width: 300px;
height: 100px;
padding: 50px;
border: 1px solid red;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class='w3-container top'>
<a class='w3schools-logo' href='http://www.w3schools.com/'>w3schools<span class='dotcom'>.com</span></a>
<div class='w3-right w3-hide-small w3-wide toptext' style="font-family:'Segoe UI',Arial,sans-serif">THE WORLD'S LARGEST WEB DEVELOPER SITE</div>
</div>
<div style='display:none;position:absolute;z-index:4;right:52px;height:44px;background-color:#5f5f5f;letter-spacing:normal;' id='googleSearch'>
<div class='gcse-search'></div>
</div>
<div style='display:none;position:absolute;z-index:3;right:111px;height:44px;background-color:#5f5f5f;text-align:right;padding-top:9px;' id='google_translate_element'></div>
<div class='w3-card-2 topnav' id='topnav'>
<div style="overflow:auto;">
<div class="w3-bar w3-left" style="width:100%;overflow:hidden;height:44px">
<a href='javascript:void(0);' class='topnav-icons fa fa-menu w3-hide-large w3-left w3-bar-item w3-button' onclick='open_menu()' title='Menu'></a>
<a href='https://www.w3schools.com/default.asp' class='topnav-icons fa fa-home w3-left w3-bar-item w3-button' title='Home'></a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/html/default.asp' title='HTML Tutorial'>HTML</a>
<a class="w3-bar-item w3-button" href='default.html' title='CSS Tutorial'>CSS</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/js/default.asp' title='JavaScript Tutorial'>JAVASCRIPT</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/sql/default.asp' title='SQL Tutorial'>SQL</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/php/default.asp' title='PHP Tutorial'>PHP</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/bootstrap/default.asp' title='Bootstrap Tutorial'>BOOTSTRAP</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/howto/default.asp' title='How To'>HOW TO</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/jquery/default.asp' title='jQuery Tutorial'>JQUERY</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/w3css/default.asp' title='W3.CSS Tutorial'>W3.CSS</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/angular/default.asp' title='Angular Tutorial'>ANGULARJS</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/default.asp' title='XML Tutorial'>XML</a>
<a class="w3-bar-item w3-button" id='topnavbtn_tutorials' href='javascript:void(0);' onclick='w3_open_nav("tutorials")' title='Tutorials'>MORE <i class='fa fa-caret-down'></i><i class='fa fa-caret-up' style='display:none'></i></a>
<a href='javascript:void(0);' class='topnav-icons fa w3-right w3-bar-item w3-button' onclick='open_search(this)' title='Search W3Schools'></a>
<a href='javascript:void(0);' class='topnav-icons fa w3-right w3-bar-item w3-button' onclick='open_translate(this)' title='Translate W3Schools'></a>
<a class="w3-bar-item w3-button w3-right" href='https://www.w3schools.com/forum/default.asp'>FORUM</a>
<a class="w3-bar-item w3-button w3-right" id='topnavbtn_examples' href='javascript:void(0);' onclick='w3_open_nav("examples")' title='Examples'>EXAMPLES <i class='fa fa-caret-down'></i><i class='fa fa-caret-up' style='display:none'></i></a>
<a class="w3-bar-item w3-button w3-right" id='topnavbtn_references' href='javascript:void(0);' onclick='w3_open_nav("references")' title='References'>REFERENCES <i class='fa fa-caret-down'></i><i class='fa fa-caret-up' style='display:none'></i></a>
</div>
<div id='nav_tutorials' class='w3-bar-block w3-card-2' style="display:none;">
<span onclick='w3_close_nav("tutorials")' class='w3-button w3-xlarge w3-right' style="position:absolute;right:0;font-weight:bold;">×</span>
<div class='w3-row-padding' style="padding:24px 48px">
<div class='w3-col l3 m4'>
<h3>HTML and CSS</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/html/default.asp'>Learn HTML</a>
<a class="w3-bar-item w3-button" href='default.html'>Learn CSS</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/w3css/default.asp'>Learn W3.CSS</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/colors/default.asp'>Learn Colors</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/bootstrap/default.asp'>Learn Bootstrap 3</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/bootstrap4/default.asp'>Learn Bootstrap 4</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/graphics/default.asp'>Learn Graphics</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/icons/default.asp'>Learn Icons</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/howto/default.asp'>Learn How To</a>
</div>
<div class='w3-col l3 m4'>
<h3>JavaScript</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/js/default.asp'>Learn JavaScript</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/jquery/default.asp'>Learn jQuery</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/angular/default.asp'>Learn AngularJS</a>
<a class="w3-bar-item w3-button" href="https://www.w3schools.com/js/js_json_intro.asp">Learn JSON</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/js/js_ajax_intro.asp'>Learn AJAX</a>
<div class="w3-hide-small"><br><br></div>
</div>
<div class='w3-col l3 m4'>
<h3>Server Side</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/sql/default.asp'>Learn SQL</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/php/default.asp'>Learn PHP</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/python/default.asp'>Learn Python</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/asp/default.asp'>Learn ASP</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/nodejs/default.asp'>Learn Node.js</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/nodejs/nodejs_raspberrypi.asp'>Learn Raspberry Pi</a>
<h3>Web Building</h3>
<a class="w3-bar-item w3-button" href="https://www.w3schools.com/w3css/w3css_templates.asp">Web Templates</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/browsers/default.asp'>Web Statistics</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/cert/default.asp'>Web Certificates</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/tryit/default.asp'>Web Editor</a>
</div>
<div class='w3-col l3 m4'>
<h3>XML</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/default.asp'>Learn XML</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/ajax_intro.asp'>Learn XML AJAX</a>
<a class="w3-bar-item w3-button" href="https://www.w3schools.com/xml/dom_intro.asp">Learn XML DOM</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/xml_dtd_intro.asp'>Learn XML DTD</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/schema_intro.asp'>Learn XML Schema</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/xsl_intro.asp'>Learn XSLT</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/xpath_intro.asp'>Learn XPath</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/xquery_intro.asp'>Learn XQuery</a>
</div>
</div>
<br>
</div>
<div id='nav_references' class='w3-bar-block w3-card-2'>
<span onclick='w3_close_nav("references")' class='w3-button w3-xlarge w3-right' style="position:absolute;right:0;font-weight:bold;">×</span>
<div class='w3-row-padding' style="padding:24px 48px">
<div class='w3-col m4'>
<h3>HTML</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/tags/default.asp'>HTML Tag Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/tags/ref_eventattributes.asp'>HTML Event Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/colors/default.asp'>HTML Color Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/tags/ref_attributes.asp'>HTML Attribute Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/tags/ref_canvas.asp'>HTML Canvas Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/graphics/svg_reference.asp'>HTML SVG Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/graphics/google_maps_reference.asp'>Google Maps Reference</a>
<h3>Charsets</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/charsets/default.asp'>HTML Character Sets</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/charsets/ref_html_ascii.asp'>HTML ASCII</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/charsets/ref_html_ansi.asp'>HTML ANSI</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/charsets/ref_html_ansi.asp'>HTML Windows-1252</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/charsets/ref_html_8859.asp'>HTML ISO-8859-1</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/charsets/ref_html_symbols.asp'>HTML Symbols</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/charsets/ref_html_utf8.asp'>HTML UTF-8</a>
</div>
<div class='w3-col m4'>
<h3>CSS</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/cssref/default.asp'>CSS Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/cssref/css3_browsersupport.asp'>CSS Browser Support</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/cssref/css_selectors.asp'>CSS Selector Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/w3css/w3css_references.asp'>W3.CSS Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/bootstrap/bootstrap_ref_all_classes.asp'>Bootstrap Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/icons/icons_reference.asp'>Icon Reference</a>
<h3>XML</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/dom_nodetype.asp'>XML Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/dom_http.asp'>XML Http Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/xsl_elementref.asp'>XSLT Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/schema_elements_ref.asp'>XML Schema Reference</a>
</div>
<div class='w3-col m4'>
<h3>JavaScript</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/jsref/default.asp'>JavaScript Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/jsref/default.asp'>HTML DOM Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/jquery/jquery_ref_selectors.asp'>jQuery Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/angular/angular_ref_directives.asp'>AngularJS Reference</a>
<h3>Server Side</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/php/php_ref_array.asp'>PHP Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/sql/sql_quickref.asp'>SQL Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/python/python_ref_functions.asp'>Python Reference</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/asp/asp_ref_response.asp'>ASP Reference</a>
</div>
</div>
<br>
</div>
<div id='nav_examples' class='w3-bar-block w3-card-2'>
<span onclick='w3_close_nav("examples")' class='w3-button w3-xlarge w3-right' style="position:absolute;right:0;font-weight:bold;">×</span>
<div class='w3-row-padding' style="padding:24px 48px">
<div class='w3-col l3 m6'>
<h3>HTML/CSS</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/html/html_examples.asp'>HTML Examples</a>
<a class="w3-bar-item w3-button" href='css_examples.html'>CSS Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/w3css/w3css_examples.asp'>W3.CSS Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/w3css/w3css_templates.asp'>W3.CSS Templates</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/bootstrap/bootstrap_examples.asp'>Bootstrap Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/howto/default.asp'>How To Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/graphics/svg_examples.asp'>SVG Examples</a>
</div>
<div class='w3-col l3 m6'>
<h3>JavaScript</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/js/js_examples.asp' target='_top'>JavaScript Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/js/js_dom_examples.asp' target='_top'>HTML DOM Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/jquery/jquery_examples.asp' target='_top'>jQuery Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/angular/angular_examples.asp' target='_top'>AngularJS Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/js/js_ajax_examples.asp' target='_top'>AJAX Examples</a>
</div>
<div class='w3-col l3 m6'>
<h3>Server Side</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/php/php_examples.asp' target='_top'>PHP Examples</a>
<a class="w3-bar-item w3-button" href="https://www.w3schools.com/asp/asp_examples.asp" target="_top">ASP Examples</a>
<h3>XML</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/xml_examples.asp' target='_top'>XML Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/xsl_examples.asp' target='_top'>XSLT Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/xpath_examples.asp' target='_top'>XPath Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/xml/schema_example.asp' target='_top'>XML Schema Examples</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/graphics/svg_examples.asp' target='_top'>SVG Examples</a>
</div>
<div class='w3-col l3 m6'>
<h3>Quizzes</h3>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/quiztest/quiztest.asp?Qtest=HTML' target='_top'>HTML Quiz</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/quiztest/quiztest.asp?Qtest=CSS' target='_top'>CSS Quiz</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/quiztest/quiztest.asp?Qtest=JavaScript' target='_top'>JavaScript Quiz</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/quiztest/quiztest.asp?Qtest=Bootstrap' target='_top'>Bootstrap Quiz</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/quiztest/quiztest.asp?Qtest=jQuery' target='_top'>jQuery Quiz</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/quiztest/quiztest.asp?Qtest=PHP' target='_top'>PHP Quiz</a>
<a class="w3-bar-item w3-button" href="https://www.w3schools.com/quiztest/quiztest.asp?Qtest=SQL" target="_top">SQL Quiz</a>
<a class="w3-bar-item w3-button" href='https://www.w3schools.com/quiztest/quiztest.asp?Qtest=XML' target='_top'>XML Quiz</a>
</div>
</div>
<br>
</div>
</div>
</div>
<div class='w3-sidebar w3-collapse' id='sidenav'>
<div id='leftmenuinner'>
<div class='w3-light-grey' id='leftmenuinnerinner'>
<a href='javascript:void(0)' onclick='close_menu()' class='w3-button w3-hide-large w3-large w3-display-topright' style='right:16px;padding:3px 12px;font-weight:bold;'>×</a>
<h2 class="left"><span class="left_h2">CSS</span> Tutorial</h2>
<a target="_top" href="default.html">CSS HOME</a>
<a target="_top" href="css_intro.html">CSS Introduction</a>
<a target="_top" href="css_syntax.html">CSS Syntax</a>
<a target="_top" href="css_howto.html">CSS How To</a>
<a target="_top" href="css_colors.html">CSS Colors</a>
<a target="_top" href="css_background.html">CSS Backgrounds</a>
<a target="_top" href="css_border.html">CSS Borders</a>
<a target="_top" href="css_margin.html">CSS Margins</a>
<a target="_top" href="css_padding.html">CSS Padding</a>
<a target="_top" href="css_dimension.html">CSS Height/Width</a>
<a target="_top" href="css_boxmodel.html">CSS Box Model</a>
<a target="_top" href="css_outline.html">CSS Outline</a>
<a target="_top" href="css_text.html">CSS Text</a>
<a target="_top" href="css_font.html">CSS Fonts</a>
<a target="_top" href="css_icons.html">CSS Icons</a>
<a target="_top" href="css_link.html">CSS Links</a>
<a target="_top" href="css_list.html">CSS Lists</a>
<a target="_top" href="css_table.html">CSS Tables</a>
<a target="_top" href="css_display_visibility.html">CSS Display</a>
<a target="_top" href="css_max-width.html">CSS Max-width</a>
<a target="_top" href="css_positioning.html">CSS Position</a>
<a target="_top" href="css_overflow.html">CSS Overflow</a>
<a target="_top" href="css_float.html">CSS Float</a>
<a target="_top" href="css_inline-block.html">CSS Inline-block</a>
<a target="_top" href="css_align.html">CSS Align</a>
<a target="_top" href="css_combinators.html">CSS Combinators</a>
<a target="_top" href="css_pseudo_classes.html">CSS Pseudo-class</a>
<a target="_top" href="css_pseudo_elements.html">CSS Pseudo-element</a>
<a target="_top" href="css_image_transparency.html">CSS Opacity</a>
<a target="_top" href="css_navbar.html">CSS Navigation Bar</a>
<a target="_top" href="css_dropdowns.html">CSS Dropdowns</a>
<a target="_top" href="css_image_gallery.html">CSS Image Gallery</a>
<a target="_top" href="css_image_sprites.html">CSS Image Sprites</a>
<a target="_top" href="css_attribute_selectors.html">CSS Attr Selectors</a>
<a target="_top" href="css_form.html">CSS Forms</a>
<a target="_top" href="css_counters.html">CSS Counters</a>
<a target="_top" href="css_website_layout.html">CSS Website Layout</a>
<a target="_top" href="css_units.html">CSS Units</a>
<a target="_top" href="css_specificity.html">CSS Specificity</a>
<br>
<h2 class="left"><span class="left_h2">CSS Advanced</span></h2>
<a target="_top" href="css3_borders.html">CSS Rounded Corners</a>
<a target="_top" href="css3_border_images.html">CSS Border Images</a>
<a target="_top" href="css3_backgrounds.html">CSS Backgrounds</a>
<a target="_top" href="css3_colors.html">CSS Colors</a>
<a target="_top" href="css3_gradients.html">CSS Gradients</a>
<a target="_top" href="css3_shadows.html">CSS Shadows</a>
<a target="_top" href="css3_text_effects.html">CSS Text Effects</a>
<a target="_top" href="css3_fonts.html">CSS Web Fonts</a>
<a target="_top" href="css3_2dtransforms.html">CSS 2D Transforms</a>
<a target="_top" href="css3_3dtransforms.html">CSS 3D Transforms</a>
<a target="_top" href="css3_transitions.html">CSS Transitions</a>
<a target="_top" href="css3_animations.html">CSS Animations</a>
<a target="_top" href="css_tooltip.html">CSS Tooltips</a>
<a target="_top" href="css3_images.html">CSS Style Images</a>
<a target="_top" href="css3_object-fit.html">CSS object-fit</a>
<a target="_top" href="css3_buttons.html">CSS Buttons</a>
<a target="_top" href="css3_pagination.html">CSS Pagination</a>
<a target="_top" href="css3_multiple_columns.html">CSS Multiple Columns</a>
<a target="_top" href="css3_user_interface.html">CSS User Interface</a>
<a target="_top" href="css3_variables.html">CSS Variables</a>
<a target="_top" href="css3_box-sizing.html">CSS Box Sizing</a>
<a target="_top" href="css3_flexbox.html">CSS Flexbox</a>
<a target="_top" href="css3_mediaqueries.html">CSS Media Queries</a>
<a target="_top" href="css3_mediaqueries_ex.html">CSS MQ Examples</a>
<br>
<h2 class="left"><span class="left_h2">CSS</span> Responsive</h2>
<a target="_top" href="css_rwd_intro.html">RWD Intro</a>
<a target="_top" href="css_rwd_viewport.html">RWD Viewport</a>
<a target="_top" href="css_rwd_grid.html">RWD Grid View</a>
<a target="_top" href="css_rwd_mediaqueries.html">RWD Media Queries</a>
<a target="_top" href="css_rwd_images.html">RWD Images</a>
<a target="_top" href="css_rwd_videos.html">RWD Videos</a>
<a target="_top" href="css_rwd_frameworks.html">RWD Frameworks</a>
<a target="_top" href="css_rwd_templates.html">RWD Templates</a>
<br>
<h2 class="left"><span class="left_h2">CSS</span> Grid</h2>
<a target="_top" href="css_grid.html">Grid Intro</a>
<a target="_top" href="css_grid_container.html">Grid Container</a>
<a target="_top" href="css_grid_item.html">Grid Item</a>
<br>
<h2 class="left"><span class="left_h2">CSS</span> Examples</h2>
<a target="_top" href="css_templates.html">CSS Templates</a>
<a target="_top" href="css_examples.html">CSS Examples</a>
<a target="_top" href="css_quiz.html">CSS Quiz</a>
<a target="_top" href="css_exercises.html">CSS Exercises</a>
<a target="_top" href="css_exam.html">CSS Certificate</a>
<br>
<h2 class="left"><span class="left_h2">CSS</span> References</h2>
<a target="_top" href="https://www.w3schools.com/cssref/default.asp">CSS Reference</a>
<a target="_top" href="https://www.w3schools.com/cssref/css_selectors.asp">CSS Selectors</a>
<a target="_top" href="https://www.w3schools.com/cssref/css_functions.asp">CSS Functions</a>
<a target="_top" href="https://www.w3schools.com/cssref/css_ref_aural.asp">CSS Reference Aural</a>
<a target="_top" href="https://www.w3schools.com/cssref/css_websafe_fonts.asp">CSS Web Safe Fonts</a>
<a target="_top" href="https://www.w3schools.com/cssref/css_animatable.asp">CSS Animatable</a>
<a target="_top" href="https://www.w3schools.com/cssref/css_units.asp">CSS Units</a>
<a target="_top" href="https://www.w3schools.com/cssref/css_pxtoemconversion.asp">CSS PX-EM Converter</a>
<a target="_top" href="https://www.w3schools.com/cssref/css_colors.asp">CSS Colors</a>
<a target="_top" href="https://www.w3schools.com/cssref/css_colors_legal.asp">CSS Color Values</a>
<a target="_top" href="https://www.w3schools.com/cssref/css_default_values.asp">CSS Default Values</a>
<a target="_top" href="https://www.w3schools.com/cssref/css3_browsersupport.asp">CSS Browser Support</a>
<br><br>
</div>
</div>
</div>
<div class='w3-main w3-light-grey' id='belowtopnav' style='margin-left:220px;'>
<div class='w3-row w3-white'>
<div class='w3-col l10 m12' id='main'>
<div id='mainLeaderboard' style='overflow:hidden;'>
<!-- MainLeaderboard-->
<div id='div-gpt-ad-1422003450156-2'>
<script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1422003450156-2'); });</script>
</div>
</div>
<h1>CSS <span class="color_h1">Box Sizing</span></h1>
<div class="w3-clear nextprev">
<a class="w3-left w3-btn" href="css3_variables.html">❮ Previous</a>
<a class="w3-right w3-btn" href="css3_flexbox.html">Next ❯</a>
</div>
<hr>
<h2>CSS Box Sizing</h2>
<p>The CSS <code class="w3-codespan">box-sizing</code> property allows us to include the padding and border in
an element's total width and height.</p>
<hr>
<h2>Without the CSS box-sizing Property</h2>
<p>By default, the width and height of an element is calculated like this:</p>
<p>width + padding + border = actual width of an element<br>
height + padding + border = actual height of an element</p>
<p>This means: When you set the width/height of an element, the element often appear
bigger than you have set (because the element's border and padding are added to the element's specified width/height).</p>
<p>The following illustration shows two <div> elements with the same
specified width and height:</p>
<div id="div1">This div is smaller (width is 300px and height is 100px).</div>
<br>
<div id="div2">This div is bigger (width is also 300px and height is 100px).</div>
<br>
<p>The two <div> elements above end up with different sizes in the result
(because div2 has a padding
specified):</p>
<div class="w3-example">
<h3>Example</h3>
<div class="w3-code notranslate cssHigh">
.div1 {<br> width: 300px;<br> height:
100px;<br> border: 1px solid blue; <br>}<br>
<br>.div2 {<br> width: 300px;<br>
height: 100px;<br> padding: 50px;<br>
border: 1px solid red;<br>} </div>
<a target="_blank" class="w3-btn w3-margin-bottom" href="tryitaba6.html?filename=trycss3_box-sizing_old">Try it Yourself »</a>
</div>
<p>The <code class="w3-codespan">box-sizing</code> property solves
this problem.</p>
<hr>
<div style="overflow:auto;text-align:center">
<!-- MidContent -->
<div id='div-gpt-ad-1493883843099-0' style="display: inline-block">
<script>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1493883843099-0'); });
</script>
</div>
</div>
<hr>
<h2>With the CSS box-sizing Property</h2>
<p>The <code class="w3-codespan">box-sizing</code> property allows us to include the padding and border in
an element's total width and height.</p>
<p>If you set <code class="w3-codespan">box-sizing: border-box;</code> on an element padding and border are
included in the width and height:</p>
<div id="div3">Both divs are the same size now!</div>
<br>
<div id="div4">Hooray!</div>
<br>
<p>Here is the same example as above, with <code class="w3-codespan">box-sizing: border-box;</code>
added to both <div> elements:</p>
<div class="w3-example">
<h3>Example</h3>
<div class="w3-code notranslate cssHigh">
.div1 {<br> width: 300px;<br> height:
100px;<br> border: 1px solid blue;<br>
box-sizing: border-box;<br>}<br>
<br>.div2 {<br> width: 300px;<br>
height: 100px;<br> padding: 50px;<br>
border: 1px solid red;<br> box-sizing: border-box;<br>} </div>
<a target="_blank" class="w3-btn w3-margin-bottom" href="tryitfbe1.html?filename=trycss3_box-sizing_new">Try it Yourself »</a>
</div>
<p>Since the result of using the <code class="w3-codespan">box-sizing: border-box;</code> is so much better, many developers want all elements on their
pages to work this way.</p>
<p>The code below ensures that all elements are sized in this more intuitive way.
Many browsers already use <code class="w3-codespan">box-sizing: border-box;</code> for
many form elements (but not all - which is why
inputs and text areas look different at width: 100%;). </p>
<p>Applying this to all elements is safe and wise:</p>
<div class="w3-example">
<h3>Example</h3>
<div class="w3-code notranslate cssHigh">
* {<br> box-sizing: border-box;<br>}
</div>
<a target="_blank" class="w3-btn w3-margin-bottom" href="tryit7877.html?filename=trycss3_box-sizing_all">Try it Yourself »</a>
</div>
<hr>
<h2>CSS Box Sizing Property</h2>
<table class="w3-table-all notranslate">
<tr>
<th style="width:28%">Property</th>
<th>Description</th>
</tr>
<tr>
<td><a href="https://www.w3schools.com/cssref/css3_pr_box-sizing.asp">box-sizing</a></td>
<td>Defines how the width and height of an element are calculated: should
they include padding and borders, or not</td>
</tr>
</table>
<br>
<div class="w3-clear nextprev">
<a class="w3-left w3-btn" href="css3_variables.html">❮ Previous</a>
<a class="w3-right w3-btn" href="css3_flexbox.html">Next ❯</a>
</div>
</div>
<div class="w3-col l2 m12" id="right">
<div class="sidesection">
<div id="skyscraper">
<div id="div-gpt-ad-1422003450156-5">
<script>
googletag.cmd.push(function() {
googletag.display('div-gpt-ad-1422003450156-5');
});
</script>
</div>
</div>
</div>
<div class="sidesection">
<h4><a href="https://www.w3schools.com/colors/colors_picker.asp">COLOR PICKER</a></h4>
<a href="https://www.w3schools.com/colors/colors_picker.asp">
<img src="../images/colorpicker.gif" alt="colorpicker"></a>
</div>
<div class="sidesection" id="moreAboutSubject">
</div>
<div class="sidesection">
<h4><a href="https://www.w3schools.com/howto/default.asp">HOW TO</a></h4>
<p>
<a href="https://www.w3schools.com/howto/howto_js_tabs.asp">Tabs</a><br>
<a href="https://www.w3schools.com/howto/howto_css_dropdown.asp">Dropdowns</a><br>
<a href="https://www.w3schools.com/howto/howto_js_accordion.asp">Accordions</a><br>
<a href="https://www.w3schools.com/howto/howto_js_weight_converter.asp">Convert Weights</a><br>
<a href="https://www.w3schools.com/howto/howto_css_animate_buttons.asp">Animated Buttons</a><br>
<a href="https://www.w3schools.com/howto/howto_js_sidenav.asp">Side Navigation</a><br>
<a href="https://www.w3schools.com/howto/howto_js_topnav.asp">Top Navigation</a><br>
<a href="https://www.w3schools.com/howto/howto_css_modals.asp">Modal Boxes</a><br>
<a href="https://www.w3schools.com/howto/howto_js_progressbar.asp">Progress Bars</a><br>
<a href="https://www.w3schools.com/howto/howto_css_parallax.asp">Parallax</a><br>
<a href="https://www.w3schools.com/howto/howto_css_login_form.asp">Login Form</a><br>
<a href="https://www.w3schools.com/howto/howto_html_include.asp">HTML Includes</a><br>
<a href="https://www.w3schools.com/howto/howto_google_maps.asp">Google Maps</a><br>
<a href="https://www.w3schools.com/howto/howto_js_rangeslider.asp">Range Sliders</a><br>
<a href="https://www.w3schools.com/howto/howto_css_tooltip.asp">Tooltips</a><br>
<a href="https://www.w3schools.com/howto/howto_js_slideshow.asp">Slideshow</a><br>
<a href="https://www.w3schools.com/howto/howto_js_filter_lists.asp">Filter List</a><br>
<a href="https://www.w3schools.com/howto/howto_js_sort_list.asp">Sort List</a><br>
</p>
</div>
<div class="sidesection">
<h4>SHARE</h4>
<div class="w3-text-grey sharethis">
<script>
<!--
try{
loc=location.pathname;
if (loc.toUpperCase().indexOf(".ASP")<0) loc=loc+"default.asp";
txt='<a href="http://www.facebook.com/sharer.php?u=https://www.w3schools.com'+loc+'" target="_blank" title="Facebook"><span class="fa fa-facebook-square fa-2x"></span></a>';
txt=txt+'<a href="https://twitter.com/home?status=Currently reading https://www.w3schools.com'+loc+'" target="_blank" title="Twitter"><span class="fa fa-twitter-square fa-2x"></span></a>';
txt=txt+'<a href="https://plus.google.com/share?url=https://www.w3schools.com'+loc+'" target="_blank" title="Google+"><span class="fa fa-google-plus-square fa-2x"></span></a>';
document.write(txt);
} catch(e) {}
//-->
</script>
<br><br>
<a href="javascript:void(0);" onclick="clickFBLike()" title="Like W3Schools on Facebook">
<span class="fa fa-thumbs-o-up fa-2x"></span></a>
<div id="fblikeframe" class="w3-modal">
<div class="w3-modal-content w3-padding-64 w3-animate-zoom" id="popupDIV"></div>
</div>
</div>
</div>
<div class="sidesection">
<h4><a target="_blank" href="http://www.w3schools.com/cert/default.asp">CERTIFICATES</a></h4>
<p>
<a href="https://www.w3schools.com/cert/cert_html.asp">HTML</a>,
<a href="https://www.w3schools.com/cert/cert_css.asp">CSS</a>,
<a href="https://www.w3schools.com/cert/cert_javascript.asp">JavaScript</a>,
<a href="https://www.w3schools.com/cert/cert_php.asp">PHP</a>,
<a href="https://www.w3schools.com/cert/cert_jquery.asp">jQuery</a>,
<a href="https://www.w3schools.com/cert/cert_bootstrap.asp">Bootstrap</a> and
<a href="https://www.w3schools.com/cert/cert_xml.asp">XML</a>.</p>
<a target="_blank" href="http://www.w3schools.com/cert/default.asp" class="w3-button w3-dark-grey" style="text-decoration:none">
Read More »</a>
</div>
<div id="stickypos" class="sidesection" style="text-align:center;position:sticky;top:50px;">
<div id="stickyadcontainer">
<div style="position:relative;margin:auto;">
<script>
if (Number(w3_getStyleValue(document.getElementById("main"), "height").replace("px", "")) > 2200) {
document.write("<div id='div-gpt-ad-1472547360578-0'>");
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1472547360578-0'); });
document.write("</div>");
}
</script>
</div>
</div>
</div>
<script>
window.addEventListener("scroll", fix_stickyad);
window.addEventListener("resize", fix_stickyad);
</script>
</div>
</div>
<div id="footer" class="footer w3-container w3-white">
<hr>
<div style="overflow:auto">