Skip to content

Commit 86890e8

Browse files
committed
7: Update <figure> CSS to new standards
1 parent 0358b29 commit 86890e8

File tree

1 file changed

+14
-62
lines changed

1 file changed

+14
-62
lines changed

7-high-level-structural-patterns.rst

+14-62
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,13 @@ Examples
12251225
Images
12261226
******
12271227

1228+
..
1229+
`<figure>` test cases:
1230+
1231+
https://standardebooks.org/ebooks/george-grey/polynesian-mythology
1232+
https://standardebooks.org/ebooks/lewis-carroll/a-tangled-tale
1233+
https://standardebooks.org/ebooks/geronimo/geronimos-story-of-his-life
1234+
12281235
#. Each :html:`<figure>` element has a unique :html:`id` attribute.
12291236

12301237
#. That attribute's name is :value:`illustration-` followed by :value:`-N`, where :value:`N` is the sequence number of the element starting at :value:`1`.
@@ -1275,24 +1282,27 @@ Images
12751282

12761283
#. An optional :html:`<figcaption>` element containing a concise context-dependent caption may follow the :html:`<img>` element within a :html:`<figure>` element. This caption depends on the surrounding context, and is not necessarily (or even ideally) identical to the :html:`<img>` element’s :html:`alt` attribute.
12771284

1278-
#. All figure elements, regardless of positioning, have this CSS:
1285+
#. All figure elements have this CSS:
12791286

12801287
.. code:: css
12811288
12821289
figure{
12831290
break-inside: avoid;
1291+
margin: 1em 2.5em;
12841292
}
12851293
12861294
figure img{
12871295
display: block;
12881296
margin: auto;
1297+
max-height: 100vh;
12891298
max-width: 100%;
12901299
}
12911300
12921301
figcaption{
12931302
font-size: smaller;
12941303
font-style: italic;
12951304
margin: 1em;
1305+
text-align: center;
12961306
}
12971307
12981308
figcaption p + p{
@@ -1306,38 +1316,6 @@ Images
13061316
figure.full-page{
13071317
break-after: page;
13081318
break-before: page;
1309-
margin: 0;
1310-
max-height: 100vh;
1311-
text-align: center;
1312-
}
1313-
1314-
@supports(display: flex){
1315-
figure.full-page{
1316-
display: flex;
1317-
flex-direction: column;
1318-
}
1319-
1320-
figure.full-page img{
1321-
height: 100vh;
1322-
object-fit: contain;
1323-
}
1324-
}
1325-
1326-
@supports(display: grid){
1327-
figure.full-page{
1328-
display: grid;
1329-
grid-template-rows: 1fr auto;
1330-
max-height: 100%;
1331-
}
1332-
}
1333-
1334-
#. :html:`<figure>` elements that are meant to be aligned block-level with the text have this additional CSS:
1335-
1336-
.. code:: css
1337-
1338-
figure{
1339-
margin: 1em 40px;
1340-
text-align: center;
13411319
}
13421320
13431321
.. class:: no-numbering
@@ -1351,52 +1329,26 @@ Examples
13511329
figure.full-page{
13521330
break-after: page;
13531331
break-before: page;
1354-
margin: 0;
1355-
max-height: 100vh;
1356-
text-align: center;
1357-
}
1358-
1359-
@supports(display: flex){
1360-
figure.full-page{
1361-
display: flex;
1362-
flex-direction: column;
1363-
}
1364-
1365-
figure.full-page img{
1366-
height: 100vh;
1367-
object-fit: contain;
1368-
}
1369-
}
1370-
1371-
@supports(display: grid){
1372-
figure.full-page{
1373-
display: grid;
1374-
grid-template-rows: 1fr auto;
1375-
max-height: 100%;
1376-
}
1377-
}
1378-
1379-
/* If the image is meant to be aligned block-level with the text, use this selector... */
1380-
figure{
1381-
margin: 1em 40px;
1382-
text-align: center;
13831332
}
13841333
13851334
/* In all cases, also include the below styles */
13861335
figure{
13871336
break-inside: avoid;
1337+
margin: 1em 2.5em;
13881338
}
13891339
13901340
figure img{
13911341
display: block;
13921342
margin: auto;
1343+
max-height: 100vh;
13931344
max-width: 100%;
13941345
}
13951346
13961347
figcaption{
13971348
font-size: smaller;
13981349
font-style: italic;
13991350
margin: 1em;
1351+
text-align: center;
14001352
}
14011353
14021354
figcaption p + p{

0 commit comments

Comments
 (0)