-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
CSS for improving images in docs #1635
Comments
Thanks, glad to hear that! 😄Those are some pretty cool hacks! I've never seen this technique, but it makes pretty much sense to me. However, I don't whether all users of the theme want those hacks included by default. Do you have a public deployment where we can see them in action? |
Zoom - https://signalfx.github.io/app-dev-workshop/module6/hotrod/ - Step 5 hover over NavBar. Click and hold to zoom Shadow - https://signalfx.github.io/app-dev-workshop/module2/muting/ - modal dialogs These could potentially be included in default CSS as they are only activated when you append the image url e.g.
|
Why do it with odd source paths? There is already things like
Then instead of creating CSS that triggers off the path, you could go with a slightly more expected convention of triggering on a class. |
Awesome, thanks a lot ! |
I guess we could add some more convenience classes via the |
I'm closing this issue with a lookout what's already possible - let's continue the discussion in a new issue! [Button](#){ .md-button }
[:fontawesome-brands-github: GitHub](#){ .md-button .md-button--primary }
[:smile: Emojis](#){ .md-button }
!!! Buttons
[Button](#){ .md-button }
[:fontawesome-brands-github: GitHub](#){ .md-button .md-button--primary }
[:smile: Emojis](#){ .md-button } |
As a new mkdocs-material user I've just discovered the .zoom idea above. I think it is really neat and exactly what I was looking for. Perhaps it is worth mentioning in the Image Attribute list section? |
What would you like to document? The additional CSS for zooming? The problem with this approach is that it is more or less desktop-only. Scaling without a transform origin (or at least some context about the environment) will not work well on mobile. For this reason it’s more or less a hack, which is why it isn’t documented. |
True. I just tried it on my mobile and not pretty. Will try improve and if viable, document. |
I have a problem : when I zoom an image with your CSS. The sides of the images are hidden by the rest of the page. I tried to put "overflow: visible" but it doesn't work. Have you got an idea on how to put the image on the foreground when it is zoomed. |
Here is my latest code @maxcrn Javascript
CSS
Then in the markdown use
|
@rcastley Thanks, but I have the same issue with this code. Here is the problem when I click to zoom on it : It gets hidden on the sides. Thanks for your help ! |
@maxcrn Confirmed it was also broken in my environment after updating Material theme. Here is the fix: Javascript
CSS
|
I have update the CSS slightly, to make the content centered. In my case, I also have the theming on, so I add the bg-color variable to the background as well. .shadow {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.zoom {
transition: transform ease-in-out 0.5s;
cursor: zoom-in;
}
.image-zoom-large {
transform: scale(1.5);
cursor: zoom-out;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
z-index: 100;
position: absolute;
margin: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
height: auto;
width: auto;
border: 1px solid #ddd;
border-radius: 6px;
padding: 4px;
background-color: var(--md-default-bg-color);
} Might improve on the JS later (i.e. not pop the image out of the running text, and add an overlay behind the image which you can also click to minimize the image). |
You can replace By the way, thanks for the snippets! |
Thank you! I did not like the glightbox, but this minimal css was awesome. I removed .image-zoom-large {
transform: scale(1.5);
cursor: zoom-out;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
z-index: 100;
max-width: 100vw;
margin: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
height: auto;
width: auto;
border: 1px solid #ddd;
border-radius: 6px;
padding: 4px;
background-color: var(--md-default-bg-color);
} I also had to modify the js to make it work with // Hook for zoom in image
document$.subscribe(function() {
var images = document.querySelectorAll(".zoom")
images.forEach(item => {
item.addEventListener('click', function () {
this.classList.toggle('image-zoom-large');
})
})
})
|
Hi,
Just want to say absolutely love this theme and putting it to great use. Whilst we have been developing our docs we have come up with a few CSS tweaks to improve image handling in our docs and just wanted to share them for consideration in including them in a future release.
Support for:
To use e.g. the zoom features just add
#zoom
to the end of the image URLOnce again thank you :-)
The text was updated successfully, but these errors were encountered: