Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Responsive/dynamic layered images

I'm using Twine 2.0.11 and SugarCube 1.0.34.

I'm trying to layer images so they rest on top of each other to create a composite. What I would like is for the images to reside in the passage element, so when the story bar is open, the images slide to the right along with the rest of the text and when the story bar is closed, the images slide to the left with the text. Out of the box, only the text (or a single image) does that.

If I use position:absolute in the CSS, then the images layer properly in the top left corner of the window, right where I specify. However, they don't react with the rest of the passage text. They remain static regardless of whether the story bar is open or not. Position:fixed does the same thing.

If I create a new div with a relative position in the passage via HTML, then place the images with an absolute or fixed position inside the div, they're still pegged to the left. I tried both of these along with supporting CSS but neither worked:

<div class="relative"><div class="absolute">[img[picture1.png]]</div><div class="absolute">[img[picture2.png]]</div></div>

<div class="relative"><img class="absolute" src="picture1.png"/><img class="absolute" src="picture2.png"/></div>

I tried to create a new div via a JS append, but for some reason I could only get it to display text. Images didn't show up at all.

Does anyone have any suggestions on how to do this? I can't be the only one to run into this issue. And since Twine uses both HTML and CSS, there's got to be a way to do it.

Thanks,

Comments

  • I got it to work, though it's not quite as dynamic as I'd like. All of my images are 300x300, which is why this works:

    HTML:
    <div id="imagebox">
    <div id="image" style="z-index: 1;">[img[images/image1.png]]</div>
    <div id="image" style="z-index: 2;">[img[images/image2.png]]</div>
    <div id="image" style="z-index: 3;">[img[images/image3.png]]</div>
    </div>
    <div id="text">
    Normal passage text goes here...
    </div>

    CSS:

    #imagebox
    {
    position:relative;
    height:300px;
    width:300px;
    }

    #image
    {
    position: absolute;
    left: 0px;
    top: 0px;
    height:300px;
    width:300px;
    }

    #text
    {
    position:relative;
    top:0px;
    }

Sign In or Register to comment.