The outcome you are seeing is due to a number of technical issues:
1: Due to how Harloweâs Passage Transition Effect is implemented any block based standard HTML element (like <div>
and <img>
) you include within a Passage will be displayed using a different âdelayâ than the story formatâs own custom HTML elements. To overcome this visual effect issue you need change the standard HTML element to be displayed as inline-block instead.
The following CSS demonstrates how to do this for the <div>
elementâŚ
div {
display: inline-block;
width: 100%;
}
âŚand to do the same for any other block based element (like <p>
) you want to use simply append that elementâs type to the above CSS selector using a coma as a separatorâŚ
div, p {
display: inline-block;
width: 100%;
}
2: Each line-break you add to the contents of a Passage automatically gets converted to a HTML line-break (<br>
) element, and unfortunately line-breaks can effect the positioning of visual elements like <img>
. To overcome this issue you can use Harloweâs Collapsing White-space markup to suppress the automatically generated <br>
within the âimageâ section of content.
{
<div id="mapDiv">
... content of the div element...
</div>
}
3: The CSS position:absolute;
property is relies on the parent-child nature of the pageâs HTML structure to work, and unfortunately the custom HTML elements Harlowe is injecting into the output is effecting the CSS of the <img>
elements you are conditionally displaying including in the output.
Your static <img>
with that has inline position:absolute;
works because that element is a direct child of the <div>
element, as shown by the following HTML structure which I obtained by used my web-browserâs Web Developer Tools to Inspect the page.
<tw-collapsed>
<div id="mapDiv" data-raw="">
<img src="http://placekitten.com/300/300" data-raw="">
<img src="http://placekitten.com/30/30" style="left: 87%; top: 12%; position:absolute;" data-raw="">
...
</div>
</tw-collapsed>
âŚhowever if I Inspect the HTML elements being generate when the condition <img>
with a inline position:absolute;
is display you will notice that that <img>
element is not a direct child of the <div>
elementâŚ
<tw-collapsed>
<div id="mapDiv" data-raw="">
...
<tw-hook>
<img src="http://placekitten.com/30/30" style="left: 33%; top: 33%; position:absolute;" data-raw="">
</tw-hook>
</div>
</tw-collapsed>
âŚthere is a custom <tw-hook>
element (that is associated with the (if:)
macro call) in-between the <div>
and the <img>
elements, and this causing the position:absolute;
of the <img>
to be relative to the <tw-hook>
element instead of the <div>
. And due to its nature this issue is harder to overcome than the previous two.
The following solution replaces the <div>
with a Named Hook, and uses the related (append:) macro to conditionally inject the other <img>
elements as needed into the defined area.
- [[Number 1]]
(if: $progress >= 2)[- [[Number 2]]]
(if: $progress >= 3)[- [[Number 3]]]
{
|map>[
<img src="http://placekitten.com/300/300">
<img src="http://placekitten.com/30/30" style="left: 87%; top: 12%; position:absolute;">
<img src="http://placekitten.com/30/30" id="pos1">
]
(if: $progress >= 2)[(append: ?map)[<img src="http://placekitten.com/30/30">]]
(if: $progress >= 3)[(append: ?map)[<img src="http://placekitten.com/30/30" style="left: 33%; top: 33%; position:absolute;">]]
(if: $progress >= 4)[(append: ?map)[<img src="http://placekitten.com/30/30" id="pos2">]]
}
âŚthe above requires CSS like that describe in point 1, except its selector needs to target the Named Hook insteadâŚ
tw-hook[name="map"] {
display: inline-block;
width: 100%;
}
Using the above Named Hook technique results in a HTML structure like the followingâŚ
<tw-collapsed>
<tw-hook name="map">
<img src="http://placekitten.com/300/300" data-raw="">
<img src="http://placekitten.com/30/30" style="left: 87%; top: 12%; position:absolute;" data-raw="">
...
<img src="http://placekitten.com/30/30" style="left: 33%; top: 33%; position:absolute;" data-raw="">
...
</tw-hook>
</tw-collapsed>
âŚwhere both the static and the conditionally added <img>
elements are all direct children of the Name Hookâs <tw-hook>
element.