Skip to content

Commit d20b953

Browse files
authored
docs: document image/figure float and alignment (#510)
* docs: document image/figure float and alignment options Add documentation for the new CSS float and alignment support for images and figures introduced in render-guides 0.37.0. Split the monolithic Images.rst into three focused pages: - Images.rst: basics, parameters, Examples 1-2 - ImageZoom.rst: zoom modes, options, accessibility, Examples 3-7 - ImageAlignment.rst: float/align, clearing, responsive, Examples 8-10 Depends on: TYPO3-Documentation/render-guides#1174 * fix: correct heading underline characters for TYPO3 convention When ImageZoom.rst and ImageAlignment.rst were extracted from Images.rst into their own pages, heading underline characters were not promoted to match the new document hierarchy. Sections that were h3/h4 in the parent document need to become h2/h3 as standalone pages. TYPO3 heading convention: - h1: = above and below (page title) - h2: = below only (sections) - h3: - below only (subsections) - h4: ~ below only (sub-subsections) Signed-off-by: Sebastian Mendel <info@sebastianmendel.de> --------- Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
1 parent 7079182 commit d20b953

File tree

4 files changed

+449
-204
lines changed

4 files changed

+449
-204
lines changed
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
:navigation-title: Float and alignment
2+
3+
.. include:: /Includes.rst.txt
4+
.. _image-float-alignment:
5+
6+
==========================================
7+
Image and figure floating and alignment
8+
==========================================
9+
10+
.. versionadded:: 0.37.0
11+
Float and alignment support for images and figures was introduced in
12+
render-guides version 0.37.0.
13+
14+
Images and figures can be floated to the left or right so that surrounding
15+
text wraps around them. This is useful for inline illustrations, icons,
16+
or any image that should be embedded within a text flow rather than
17+
displayed as a standalone block.
18+
19+
There are two ways to apply floating:
20+
21+
1. **CSS classes** ``:class: float-left`` or ``:class: float-right`` — works on
22+
both ``.. image::`` and ``.. figure::`` directives.
23+
2. The ``:align:`` **option** — ``:align: left``, ``:align: right``, or ``:align: center``
24+
— works on ``.. figure::`` directives (internally mapped to the same CSS
25+
classes).
26+
27+
Both approaches produce the same visual result. Use whichever fits your
28+
preference.
29+
30+
.. _image-float-css-classes:
31+
32+
Float with CSS classes
33+
======================
34+
35+
Add ``float-left`` or ``float-right`` to the ``:class:`` option. You can combine
36+
these with other classes such as ``with-shadow`` or ``with-border``:
37+
38+
.. code-block:: rst
39+
40+
.. figure:: /Images/MyImage.png
41+
:alt: Description of the image
42+
:class: float-left with-shadow
43+
44+
Caption text here
45+
46+
Surrounding text will wrap to the right of the image.
47+
48+
.. _image-float-align-option:
49+
50+
Align option
51+
============
52+
53+
The ``:align:`` option on ``.. figure::`` directives supports ``left``, ``right``,
54+
and ``center``. Values ``left`` and ``right`` produce the same floating behavior
55+
as the CSS classes:
56+
57+
.. code-block:: rst
58+
59+
.. figure:: /Images/MyImage.png
60+
:alt: Description of the image
61+
:align: right
62+
63+
Caption text here
64+
65+
Surrounding text will wrap to the left of the image.
66+
67+
Using ``:align: center`` centers the figure without any text wrapping.
68+
69+
.. _image-float-clearing:
70+
71+
Clearing floats
72+
===============
73+
74+
After a floated image, you may want subsequent content to appear below the
75+
image rather than wrapping around it. Use the ``clear-both`` class to clear
76+
floats:
77+
78+
.. code-block:: rst
79+
80+
.. figure:: /Images/MyImage.png
81+
:alt: Description of the image
82+
:class: float-left
83+
84+
Caption
85+
86+
This text wraps around the image.
87+
88+
.. rst-class:: clear-both
89+
90+
This text appears below the image.
91+
92+
The ``.. rst-class:: clear-both`` directive applies the CSS ``clear: both``
93+
property to the next element, forcing it below any floated content.
94+
95+
.. _image-float-responsive:
96+
97+
Responsive behavior
98+
===================
99+
100+
Floated images automatically switch to full-width block display on small
101+
screens (below 576px). This ensures readable text on mobile devices
102+
without horizontal scrolling.
103+
104+
.. _image-float-example-8:
105+
106+
Example 8: Figure floated left
107+
------------------------------
108+
109+
.. figure:: /_Images/a4.jpg
110+
:alt: Example figure floated left
111+
:class: float-left with-shadow
112+
:width: 150px
113+
114+
A figure floated to the left
115+
116+
Typesetting is the composition of text by means of arranging physical types
117+
or the digital equivalents. Stored letters and other symbols are retrieved
118+
and ordered according to a language's orthography for visual display.
119+
Typesetting requires one or more fonts.
120+
121+
.. rst-class:: clear-both
122+
123+
.. code-block:: rst
124+
125+
.. figure:: /_Images/a4.jpg
126+
:alt: Example figure floated left
127+
:class: float-left with-shadow
128+
:width: 150px
129+
130+
A figure floated to the left
131+
132+
Typesetting is the composition of text by means of arranging
133+
physical types or the digital equivalents. ...
134+
135+
.. rst-class:: clear-both
136+
137+
.. _image-float-example-9:
138+
139+
Example 9: Figure aligned right
140+
--------------------------------
141+
142+
.. figure:: /_Images/a4.jpg
143+
:alt: Example figure aligned right
144+
:align: right
145+
:width: 150px
146+
147+
A figure aligned right via ``:align:``
148+
149+
Typesetting is the composition of text by means of arranging physical types
150+
or the digital equivalents. Stored letters and other symbols are retrieved
151+
and ordered according to a language's orthography for visual display.
152+
Typesetting requires one or more fonts.
153+
154+
.. rst-class:: clear-both
155+
156+
.. code-block:: rst
157+
158+
.. figure:: /_Images/a4.jpg
159+
:alt: Example figure aligned right
160+
:align: right
161+
:width: 150px
162+
163+
A figure aligned right via :align:
164+
165+
Typesetting is the composition of text by means of arranging
166+
physical types or the digital equivalents. ...
167+
168+
.. rst-class:: clear-both
169+
170+
.. _image-float-example-10:
171+
172+
Example 10: Image floated left with shadow
173+
-------------------------------------------
174+
175+
.. image:: /_Images/a4.jpg
176+
:alt: Example image floated left
177+
:class: float-left with-shadow
178+
:width: 150px
179+
180+
Typesetting is the composition of text by means of arranging physical types
181+
or the digital equivalents. Stored letters and other symbols are retrieved
182+
and ordered according to a language's orthography for visual display.
183+
Typesetting requires one or more fonts.
184+
185+
.. rst-class:: clear-both
186+
187+
.. code-block:: rst
188+
189+
.. image:: /_Images/a4.jpg
190+
:alt: Example image floated left
191+
:class: float-left with-shadow
192+
:width: 150px
193+
194+
Typesetting is the composition of text by means of arranging
195+
physical types or the digital equivalents. ...
196+
197+
.. rst-class:: clear-both
198+
199+
.. _image-float-best-practices:
200+
201+
Best practices for floating
202+
============================
203+
204+
* Always use ``.. rst-class:: clear-both`` after floated content to prevent
205+
layout issues with subsequent sections
206+
* Set an explicit ``:width:`` on floated images to control how much space
207+
text has to wrap around
208+
* Floated figures are limited to 50% of the page width to ensure readability
209+
* Prefer ``:align:`` on figures for cleaner RST syntax; use ``:class:`` when you
210+
need to combine float with other classes like ``with-shadow``
211+
* Test on narrow viewports to verify the responsive behavior

0 commit comments

Comments
 (0)