-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
ampshared.css
575 lines (500 loc) · 14.7 KB
/
ampshared.css
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
/**
* @fileoverview CSS shared across AMP4ADS and other formats.
*/
/**
* We intentionally break with HTML5's default [hidden] styling to apply
* !important.
*/
[hidden] {
/* This must be !important, else the toggle helper system would break down
due to specificity */
display: none !important;
}
.i-amphtml-element {
display: inline-block;
}
.i-amphtml-blurry-placeholder {
transition: opacity 0.3s cubic-bezier(0.0, 0.0, 0.2, 1) !important;
pointer-events: none;
}
/* layout=nodisplay are automatically hidden until JS initializes. */
[layout=nodisplay]:not(.i-amphtml-element) {
display: none !important;
}
/* Initialized layout=nodisplay contain [hidden] */
.i-amphtml-layout-nodisplay[hidden],
[layout=nodisplay][hidden]:not(.i-amphtml-layout-nodisplay)
{
/* Display is set/reset via the hidden attribute */
}
.i-amphtml-layout-nodisplay:not([hidden]),
[layout=nodisplay]:not(.i-amphtml-layout-nodisplay[hidden])
{
/* Display is set/reset via the hidden attribute */
}
/**
* layout=fixed does not have a unresolved implicit style, due to conflicts
* with non-amp elements.
* https://github.com/ampproject/amphtml/pull/28115#discussion_r419843723
*/
.i-amphtml-layout-fixed,
[layout=fixed][width][height]:not(.i-amphtml-layout-fixed)
{
display: inline-block;
position: relative;
}
.i-amphtml-layout-responsive,
[layout=responsive][width][height]:not(.i-amphtml-layout-responsive),
[width][height][sizes]:not(img):not([layout]):not(.i-amphtml-layout-responsive),
[width][height][heights]:not([layout]):not(.i-amphtml-layout-responsive)
{
display: block;
position: relative;
}
.i-amphtml-layout-intrinsic,
[layout=intrinsic][width][height]:not(.i-amphtml-layout-intrinsic)
{
display: inline-block;
position: relative;
max-width: 100%;
}
.i-amphtml-layout-intrinsic .i-amphtml-sizer {
max-width: 100%;
}
.i-amphtml-intrinsic-sizer {
max-width: 100%;
display: block !important;
}
/**
* layout=fixed-height does not have a unresolved implicit style, due to
* conflicts with non-amp elements.
* https://github.com/ampproject/amphtml/pull/28115#discussion_r419843723
*/
.i-amphtml-layout-fixed-height,
[layout=fixed-height][height]:not(.i-amphtml-layout-fixed-height)
{
display: block;
position: relative;
}
/**
* layout=container does not have a unresolved implicit style, due to conflicts
* with non-amp elements.
* https://github.com/ampproject/amphtml/pull/28115#discussion_r419843723
*/
.i-amphtml-layout-container,
[layout=container]
{
display: block;
position: relative;
}
/* Fill layout requires higher specificity than i-amp-html-notbuilt
* so that the correct width/height can be applied before build.
*/
.i-amphtml-layout-fill,
.i-amphtml-layout-fill.i-amphtml-notbuilt,
[layout=fill]:not(.i-amphtml-layout-fill),
body noscript > *
{
display: block;
overflow: hidden !important;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
/* In previous rule and in this one, make sure noscript fallbacks get fill layout as if they are placeholders */
body noscript > * {
position: absolute !important;
/* Override width/height attributes defined on HTML elements in noscript. */
width: 100%;
height: 100%;
/* Supersede sibling [placeholder]/[fallback] z-index:1 */
z-index: 2;
}
body noscript {
display: inline !important;
}
.i-amphtml-layout-flex-item,
[layout=flex-item]:not(.i-amphtml-layout-flex-item)
{
display: block;
position: relative;
flex: 1 1 auto;
}
.i-amphtml-layout-fluid {
position: relative;
}
.i-amphtml-layout-size-defined {
overflow: hidden !important;
}
.i-amphtml-layout-awaiting-size {
position: absolute !important;
top: auto !important;
bottom: auto !important;
}
i-amphtml-sizer {
display: block !important;
}
/*
* Disable `i-amphtml-sizer` when aspect ratio is supported by both the
* borwser and the optimizer.
*/
@supports (aspect-ratio: 1 / 1) {
i-amphtml-sizer.i-amphtml-disable-ar {
display: none !important;
}
}
.i-amphtml-fill-content,
.i-amphtml-blurry-placeholder {
display: block;
/* These lines are a work around to this issue in iOS: */
/* https://bugs.webkit.org/show_bug.cgi?id=155198 */
/* And: https://github.com/ampproject/amphtml/issues/11133 */
height: 0;
max-height: 100%;
max-width: 100%;
min-height: 100%;
min-width: 100%;
width: 0;
margin: auto;
}
.i-amphtml-layout-size-defined .i-amphtml-fill-content {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.i-amphtml-replaced-content {
padding: 0 !important;
border: none !important;
/* TODO(dvoytenko): explore adding here object-fit. */
}
/**
* Makes elements visually invisible but still accessible to screen-readers.
*
* This Css has been carefully tested to ensure screen-readers can read and
* activate (in case of links and buttons) the elements with this class. Please
* use caution when changing anything, even seemingly safe ones. For example
* changing width from 1 to 0 would prevent TalkBack from activating (clicking)
* buttons despite TalkBack reading them just fine. This is because
* element needs to have a defined size and be on viewport otherwise TalkBack
* does not allow activation of buttons.
*/
.i-amphtml-screen-reader {
position: fixed !important;
/* keep it on viewport */
top: 0px !important;
left: 0px !important;
/* give it non-zero size, VoiceOver on Safari requires at least 2 pixels
before allowing buttons to be activated. */
width: 4px !important;
height: 4px !important;
/* visually hide it with overflow and opacity */
opacity: 0 !important;
overflow: hidden !important;
/* remove any margin or padding */
border: none !important;
margin: 0 !important;
padding: 0 !important;
/* ensure no other style sets display to none */
display: block !important;
visibility: visible !important;
}
.i-amphtml-screen-reader ~ .i-amphtml-screen-reader {
left: 8px !important;
}
.i-amphtml-screen-reader ~ .i-amphtml-screen-reader ~ .i-amphtml-screen-reader {
left: 12px !important;
}
.i-amphtml-screen-reader ~ .i-amphtml-screen-reader ~ .i-amphtml-screen-reader ~ .i-amphtml-screen-reader {
left: 16px !important;
}
/* For author styling. */
.amp-unresolved {
}
.i-amphtml-unresolved {
position: relative;
overflow: hidden !important;
}
.i-amphtml-select-disabled {
user-select: none !important;
}
/* "notbuild" classes are set as soon as an element is created and removed
as soon as the element is built. */
.amp-notbuilt {
/* For author styling. */
}
/**
* [width][height][sizes] and [width][height][heights] imply layout=responsive
* before the element has resolved.
*/
.i-amphtml-notbuilt,
[layout]:not(.i-amphtml-element),
[width][height][sizes]:not(img):not([layout]):not(.i-amphtml-element),
[width][height][heights]:not([layout]):not(.i-amphtml-element)
{
position: relative;
overflow: hidden !important;
color: transparent !important;
}
/**
* Hide all children of non-container elements.
* [width][height][sizes] and [width][height][heights] imply layout=responsive
* before the element has resolved.
*/
.i-amphtml-notbuilt:not(.i-amphtml-layout-container) > *,
[layout]:not([layout=container]):not(.i-amphtml-element) > *,
[width][height][sizes]:not([layout]):not(.i-amphtml-element) > *,
[width][height][heights]:not([layout]):not(.i-amphtml-element) > *
{
display: none;
}
/**
* We special case the native <img> inside an SSR'd <amp-img>. We allow this to
* display using `block` defined by .i-amphtml-fill-content.
*
* As more elements get SSR, we'll need to add their special cases here.
*/
amp-img:not(.i-amphtml-element)[i-amphtml-ssr] > img.i-amphtml-fill-content
{
display: block;
}
/** Hide all text node children of non-container elements. */
.i-amphtml-notbuilt:not(.i-amphtml-layout-container),
[layout]:not([layout='container']):not(.i-amphtml-element),
[width][height][sizes]:not(img):not([layout]):not(.i-amphtml-element),
[width][height][heights]:not([layout]):not(.i-amphtml-element) {
color: transparent !important;
line-height: 0 !important;
}
.i-amphtml-ghost {
visibility: hidden !important;
}
.i-amphtml-layout {
/* Just state. */
}
.i-amphtml-error {
/* Just state. */
}
/**
* [width][height][sizes] and [width][height][heights] imply layout=responsive
* before the element has resolved.
*/
.i-amphtml-element > [placeholder],
[layout]:not(.i-amphtml-element) > [placeholder],
[width][height][sizes]:not([layout]):not(.i-amphtml-element) > [placeholder],
[width][height][heights]:not([layout]):not(.i-amphtml-element) > [placeholder] {
display: block;
/* line-height:normal overrides line-height:0 from the "hide all children of
non-container text node children" rule. This avoids a minor content jump during
element build since placeholders should be fully visible. */
line-height: normal;
}
.i-amphtml-element > [placeholder].hidden,
.i-amphtml-element > [placeholder].amp-hidden {
visibility: hidden;
}
/* Placeholder, by design, expands layout=container unlike other layouts where
it is position:absolute and overlays the layout box.
However, when it goes away it should no longer expand the parent, so instead
of visibility:hidden it must be display:none */
.i-amphtml-layout-container > [placeholder].hidden,
.i-amphtml-layout-container > [placeholder].amp-hidden {
display: none;
}
.i-amphtml-element:not(.amp-notsupported) > [fallback] {
display: none;
}
.i-amphtml-layout-size-defined > [placeholder],
.i-amphtml-layout-size-defined > [fallback] {
position: absolute !important;
top: 0 !important;
left: 0 !important;
right: 0 !important;
bottom: 0 !important;
z-index: 1;
}
/* We reset the z-index of blurry image placeholders for images that are
rendered by the server and are not (yet) controlled by JS to speed up
display of the real image. This conveniently also fixes the display of
the image when JS fails to load. */
amp-img[i-amphtml-ssr]:not(.i-amphtml-element) > [placeholder] {
z-index: auto;
}
.i-amphtml-notbuilt > [placeholder] {
display: block !important;
}
.i-amphtml-hidden-by-media-query {
display: none !important;
}
.i-amphtml-element-error {
background: red !important;
color: white !important;
position: relative !important;
}
.i-amphtml-element-error::before {
content: attr(error-message);
}
/**
* Wraps an element to make the contents scrollable. This is
* used to wrap iframes which in iOS always behave as if they had the
* seamless attribute.
* TODO(dvoytenko, #8464): cleanup old `i-amp-scroll-container`.
*/
i-amphtml-scroll-container, i-amp-scroll-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: block;
}
/**
* Overflow:auto will be set with delay due to iOS bug where iframe is not
* rendered.
* TODO(dvoytenko, #8464): cleanup old `i-amp-scroll-container`.
*/
i-amphtml-scroll-container.amp-active, i-amp-scroll-container.amp-active {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
.i-amphtml-loading-container {
display: block !important;
pointer-events: none;
z-index: 1;
}
.i-amphtml-notbuilt > .i-amphtml-loading-container {
display: block !important;
}
.i-amphtml-loading-container.amp-hidden {
visibility: hidden;
}
/**
* "overflow" element is an element shown when more content is available but
* not currently visible. Typically tapping on this element shows the full
* content.
*/
.i-amphtml-element > [overflow] {
cursor: pointer;
/* position:relative is critical to ensure that [overflow] is displayed
above an iframe; z-index is not enough. */
position: relative;
z-index: 2;
visibility: hidden;
/* display:initial overrides display:none from the "hide all children of
non-container elements" rule. Similarly, line-height:normal overrides
line-height:0 for text node children. This avoids a minor content jump after
element build since overflows increase the height of their parents. */
display: initial;
line-height: normal;
}
/**
* "overflow" element must not contribute space to a size-defined element.
*/
.i-amphtml-layout-size-defined > [overflow] {
position: absolute;
}
.i-amphtml-element > [overflow].amp-visible {
visibility: visible;
}
/* Polyfill for IE and any other browser that don't understand templates. */
template {
display: none !important;
}
/**
* Authors can set this class on their html tags to provide `border-box` box-sizing
* to every element in their document. Individual elements can override as necessary.
*/
.amp-border-box,
.amp-border-box *,
.amp-border-box *:before,
.amp-border-box *:after {
box-sizing: border-box;
}
/* amp-pixel is always non-displayed. */
amp-pixel {
display: none !important;
}
/**
* Analytics & amp-story-auto-ads tags should never be visible. keep them hidden.
*/
amp-analytics, amp-story-auto-ads, amp-auto-ads {
/* Fixed to make position independent of page other elements. */
position: fixed !important;
top: 0 !important;
width: 1px !important;
height: 1px !important;
overflow: hidden !important;
visibility: hidden;
}
html.i-amphtml-fie > amp-analytics {
/* Remove position fixed if it's in iframe.
* So runtime can measure layoutBox correctly
*/
position: initial !important;
}
/**
* Forms error/success messaging containers should be hidden at first.
*/
form [submitting],
form [submit-success],
form [submit-error] {
display: none;
}
/**
* Form validation error messages should be hidden at first.
*/
[visible-when-invalid]:not(.visible) {
display: none;
}
/**
* amp-accordion to avoid FOUC.
*/
/* Non-overridable properties */
amp-accordion {
display: block !important;
}
/**
* This media query is used instead of @supports due to low compatibility.
* At the time of this change (4/6/2021) no version of Webkit support @supports queries.
* These provide low-specificity UI styles to prevent CLS for the header and content
* segments of accordions. The same styles are later set and extended with interactive
* styles for older browsers via the `i-amphtml-accordion-header` class in both 0.1 and
* the 1.0 version of accordion.
*/
@media (min-width: 1px) {
:where(amp-accordion > section) > :first-child {
margin: 0;
background-color: #efefef;
padding-right: 20px;
border: 1px solid #dfdfdf;
}
:where(amp-accordion > section) > :last-child {
margin: 0;
}
}
/* Make sections non-floatable */
amp-accordion > section {
float: none !important;
}
/* Display the first 2 elements (heading and content) */
amp-accordion > section > * {
float: none !important;
display: block !important;
overflow: hidden !important; /* clearfix */
position: relative !important;
}
amp-accordion,
amp-accordion > section {
margin: 0;
}
/* Collapse content by default. */
amp-accordion:not(.i-amphtml-built) > section > :last-child {
display: none !important;
}
/* Expand content when needed. */
amp-accordion:not(.i-amphtml-built) > section[expanded] > :last-child {
display: block !important;
}