Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to display a Picturefill image without any bars and span residuals with the intrinsic ratio mixin? #59

Closed
rpkoller opened this issue Mar 1, 2014 · 1 comment

Comments

@rpkoller
Copy link

rpkoller commented Mar 1, 2014

I've tried around quite a bit but somehow it is kind of tricky to apply the intrinsic ratio mixin to a picturefill markup. If I try a single image everything lays out fine.

<div class="ir">
    <img src="/img/fp-580x270.jpg" alt="fp">
</div>
.ir {
    @include intrinsic-ratio(2.14814815, 100%);
}
*, *:before, *:after {
outline: 1px solid red;
}
body,
html {
    height:100%;
    line-height:1.4;
    padding:0;
    margin:0;
    background:lightyellow;
}

.container {
     max-width:750px;
     margin: 2em auto 0 auto;
}
img {
    width:100%;
    max-width:100%;
    height: auto;
}

bildschirmfoto 2014-03-01 um 05 30 25

a clean display - a wrapping div the ratio mixin is applied to - all fine. But the problem is on the picturefill side you dont have a single wrapping element but subelements as well. I tried to bypass by adding the class name to the inner spans and ended up with an empty box

<span data-picture data-alt="fp">
    <span class="intrinsic" data-src="/img/fp-338x157.jpg"></span>
    <span class="intrinsic" data-src="/img/fp-507x236.jpg" data-media="(min-device-pixel-ratio: 1.5)"></span>
    <span class="intrinsic" data-src="/img/fp-676x315.jpg" data-media="(min-device-pixel-ratio: 2.0)"></span>
    <noscript>
        <img src="/img/fp-loesungen-1160x540.jpg" alt="fp">
    </noscript>
</span>

bildschirmfoto 2014-03-01 um 05 42 34

If I added the selector to the outer span and removed the intrinsic class from the inner, using an attribute selector .intrinsic[attr^=data-alt] for the mixin I ended up with an image displayed:

bildschirmfoto 2014-03-01 um 05 45 27

On the downside there is still an empty bar beneath the image in contrast to the "regular" image from the beginning as well as the outline for an empty span. Is there a way to display an Picturefill image in the same clean manner like the first image? Best regards Ralf

@rpkoller
Copy link
Author

rpkoller commented Mar 2, 2014

Ok i got things working finally. i had to add display:block to the parent element for a picturefill image:

<span class="intrinsic-picturefill" data-picture data-alt="fp">
    <span data-src="/img/fp-338x157.jpg"></span>
    <span data-src="/img/fp-507x236.jpg" data-media="(min-device-pixel-ratio: 1.5)"></span>
    <span data-src="/img/fp-676x315.jpg" data-media="(min-device-pixel-ratio: 2.0)"></span>
    <noscript>
        <img src="/img/fp-loesungen-1160x540.jpg" alt="fp">
    </noscript>
</span>
.intrinsic-picturefill {
    @include intrinsic-ratio(2.14814815, 100%);
    display:block;
}

then the border and the empty box were gone. here is an example: first is a regular intrinsic img second is an intrinsic picturefill one - both have the identical extends now.

bildschirmfoto 2014-03-02 um 13 35 06

@rpkoller rpkoller closed this as completed Mar 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant