Translating HTML Exported From Figma Plugins (Anima, Locofy): Fixing Broken Absolute Positioning
Replace position: absolute with in-flow Flexbox layout wherever translated text needs to push neighboring elements out of the way. This applies to HTML exported from Figma through Anima or Locofy: keep absolute positioning for deliberate overlays, and check the exported CSS rather than assuming that a layer’s position in Figma tells you how it will behave in the browser.
A translated heading can wrap onto another line without moving a description pinned with top. The translation hasn’t broken the CSS; it has exposed a layout that depended on the source copy’s height. Fix that dependency in Figma if the component will be exported again, or repair the exported CSS if the HTML is what you maintain.
Trace the overlap before changing the CSS
- Open the translated page at a width where the problem occurs. Identify the two elements that collide, such as a heading and the description immediately below it.
- Inspect both elements. Look for
position: absoluteon the text, its wrapper, or the neighboring element. A heading can be in flow inside a wrapper that is itself out of flow. - Find the containing block for each absolutely positioned element. Start with the closest ancestor whose
positionis notstatic, but check intervening ancestors for properties such astransformorcontainthat can also establish a containing block. - Temporarily switch the suspect element to
position: static. Check whether the next element now moves when the text wraps. If the collision moves to the next card or section instead, inspect the enclosing wrapper for another out-of-flow element or a height that still assumes the original copy.
.card {
position: relative;
}
.card-title {
position: absolute;
top: 16px;
left: 16px;
}
.card-copy {
position: absolute;
top: 48px;
left: 16px;
}
This is the pattern to look for: the description starts at 48px regardless of where the heading ends. Both children are out of flow, so neither reserves space in the card. The example selectors stand in for the matching rules in your export; verify the same relationship on the affected elements before editing.
Never fix a translated heading collision by moving the description farther down with
top. That fits one translation at one width without fixing the relationship between the two elements.
Put translated content back into flow
.card {
display: flex;
flex-direction: column;
gap: 12px;
padding: 16px;
}
.card-title,
.card-copy {
position: static;
}
Replace the earlier rules rather than keeping two competing versions of the component. Remove the old offsets from the text rules: spacing now comes from the card’s padding and the gap between its flex items. Verify that the title and description are direct children of the flex container, or apply the layout to the wrapper that actually contains both.
.card-list {
display: flex;
flex-direction: column;
gap: 24px;
}
.card {
position: static;
display: flex;
flex-direction: column;
gap: 12px;
padding: 16px;
}
Repair the next level too if the exported cards themselves are absolutely positioned. A title can correctly push its description down inside the card while the card remains unable to push the next card down. After replacing the old card offsets, check that a taller first card moves the second card without a manual adjustment.
Choose positioning by what needs to move
| Layout job | CSS to inspect or apply | What to verify after translation |
|---|---|---|
| Stack a heading and description | display: flex with flex-direction: column | A new line in the heading moves the description down. |
| Keep a card in flow while anchoring an overlay | position: relative on the card | The card still takes up space in the list, and the overlay follows the card. |
| Place a decorative element in a corner | position: absolute with top and right | The longest translated copy does not enter the overlay’s area. |
| Diagnose a drifting percentage offset | top: 10% or left: 10% | The vertical offset depends on the containing block’s height; the horizontal offset depends on its width. |
Switching a text element to position: relative puts it back in flow, but that alone isn’t a clean reset. If you leave a top or left offset on it, the element can move visually while its original space stays reserved. Remove the offsets if the element is meant to align with its neighbors.
Keep intentional overlays anchored to the component
.card {
display: flex;
flex-direction: column;
gap: 12px;
padding: 16px;
}
.card-mark {
position: absolute;
top: 16px;
right: 16px;
}
This version keeps the copy in flow but does not make the card the mark’s containing block. If no property on the card establishes one, the mark can be positioned against another ancestor or the initial containing block. Inspect that relationship if the mark lands in a section corner instead of the card corner.
.card {
position: relative;
display: flex;
flex-direction: column;
gap: 12px;
padding: 16px;
padding-right: 56px;
}
.card-mark {
position: absolute;
top: 16px;
right: 16px;
}
With the mark directly inside the card, the card’s padding box now provides the positioning reference. The extra right padding reserves room for a small decoration; adjust it to the mark’s actual size and check the result at a narrow width. If the mark is a translated label that can grow, place it in flow instead of relying on a fixed strip of space.
Keep absolute positioning only where the element does not need to reserve space for itself. If translated content must make room for it, give it a place in the layout.
Fix repeat exports in Figma
For Anima, the Figma setup documentation says that the HTML output is standalone and that auto-layout properties translate to CSS Flexbox. That makes the design file the better repair point when another export would replace your CSS edits. For a Locofy export, use the same browser-side diagnosis, but confirm the generated layout in the HTML and CSS rather than assuming Anima’s mapping applies.
- Start with the smallest affected component. Put the heading and description in the same auto-layout frame and use its direction, spacing, and padding to define their relationship.
- Check each text layer for
Ignore auto layout, formerly calledabsolute positionin Figma Design. Turn it off for text that should move its siblings. For a decoration that intentionally stays outside the flow, use constraints to control its position as the frame resizes. - Apply auto-layout to the repeating cards and page sections too. Fixing the text stack inside a card won’t help if the card is still excluded from the list’s flow.
- Resize the frame horizontally and vertically before previewing or syncing. Re-export, then check that the rules that produced the collision no longer apply to the translated content.
Ignore auto layout describes whether a layer participates in its parent’s layout in Figma Design. Figma Sites describes relative, absolute, fixed, and sticky positioning separately. When debugging a browser export, use the actual CSS position value and the element’s containing block.
Validate the translated export at the widths that broke
- Open the source and translated versions at the same widths. Include both the width where the collision first appeared and a narrower width where the heading wraps again.
- Check the whole chain: the heading pushes the description, the description contributes to the card’s height, and the card pushes the following card or section. Verify this with the translated HTML, not just the original Figma frame.
- Inspect each remaining
position: absoluterule in the repaired component. Confirm that it serves an intentional overlay, that its containing block is the expected wrapper, and that the longest translated copy stays clear of it.
Use HTML Translate to prepare a translated copy of the export, then compare the repaired component against the source at matching viewport widths.
Common mistakes and troubleshooting
- The heading grows, but the description never moves. The description or its wrapper is still pinned with
position: absolute. Return it to flow in the same layout container as the heading. - The card looks fixed, but it overlaps the next card. Inspect the card wrapper for
position: absoluteor a fixedheightthat no longer fits the content. Let the list lay out each card at its resulting height. - The replacement Flexbox rule has no effect on the pair.
display: flexlays out the container’s direct children. Find the wrapper that contains both text blocks, or lay out their wrappers together. - An overlay jumps after the component is moved. Check which ancestor establishes its containing block. Add
position: relativeto the intended wrapper and verify that a closer ancestor with a property such astransformdoes not take over. - The text moves but leaves an unexplained gap. A
position: relativeelement with an offset still reserves its original space. Remove the offset and set the spacing on the parent. - The overlap comes back after export. The CSS patch fixed the generated file, not the Figma source. Review
Ignore auto layouton the text, card, and section layers before exporting again.
HTML File Translation Questions
Should every absolute position be removed?
No. Keep position: absolute for deliberate overlays that don’t need to reserve layout space. Change it where headings, descriptions, cards, or sections need to move their neighbors as copy grows.
Does setting the card to relative make its text flow?
No. position: relative can make the card a reference for its absolutely positioned descendants, but those descendants stay out of flow. Change the text or wrapper positioning separately.
Can percentage offsets fix a translated layout?
They can place an overlay relative to a containing block, but they don’t make one text block follow another. A percentage top follows the containing block’s height, not the bottom edge of the preceding heading.
Is it better to patch the export or edit Figma?
Patch the CSS if the exported HTML is the version you maintain. If the component will be exported repeatedly, correct its auto-layout structure in Figma and verify the resulting display: flex and positioning rules in the new export.
Does the same CSS repair apply to Locofy exports?
Yes, when the generated CSS shows the same problem. If a text block is out of flow because it uses position: absolute, restoring it to flow addresses that dependency regardless of which plugin exported the file.