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

Centering slide images vertically #66

Open
william-vw opened this issue Sep 18, 2020 · 2 comments
Open

Centering slide images vertically #66

william-vw opened this issue Sep 18, 2020 · 2 comments

Comments

@william-vw
Copy link

I need to set a fixed width for the slide show, which also means max-width and max-height for the images. This means that some images will be less high than the slideshow container, and they are positioned at the top.

I was wondering how one can center slide images vertically. Since the images are positioned absolutely by slidr.js, it's not as simple as adding a vertical-align directive. Adding a top: xx directive will apply to all images, not only the small ones.

@bchanx
Copy link
Owner

bchanx commented Sep 18, 2020

Hi @william-vw, you can try using css flex-box to align things vertically and horizontally. For example:

  • without display: flex:
    without-flex-box
  • with display: flex, using align-items: center and justify-content: center:
    with-flex-box

@william-vw
Copy link
Author

Thanks a lot for this! Yes, using flex-box works. Seems like I stopped following CSS about ten years ago .. I had actually outfitted the slidr code with a dynamic re-positioning (setting top, left) based on the naturalHeight and naturalWidth of the images once they were loaded. Talk about overkill .. Lol.

FYI, I was wondering why the pause effect was not working when using the auto mode - it looks like mouse tracking is only enabled when keyboard is found in the settings:

if (_.settings['keyboard']) nav.mouse.track(_.slidr);

Which seems a bit strange, but maybe there's a reason?

Anyway, thanks for the awesome library :-)

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

2 participants