admin管理员组文章数量:1026989
My impress.js slides have images that I would like to fill the screen and center, here's the code:
<div id="impress">
<div class="step" data-x="-10000" data-y="100" data-z="0" data-scale="1">
Introduction
</div>
<div class="step" data-x="-10000" data-y="-1100" data-z="1000" data-scale="1">
<img src="images/Wallpaper-Abstract-Fractal-Flowers-Lilies.jpg" >
</div>
</div>
Right now it looks like below, but I'd like the image in the second slide to fill up the screen (maintaining aspect ratio).
Is there some way to zoom in by changing the data-scale or the camera angle? Or will some css tricks suffice? I started with the default example template.
My impress.js slides have images that I would like to fill the screen and center, here's the code:
<div id="impress">
<div class="step" data-x="-10000" data-y="100" data-z="0" data-scale="1">
Introduction
</div>
<div class="step" data-x="-10000" data-y="-1100" data-z="1000" data-scale="1">
<img src="images/Wallpaper-Abstract-Fractal-Flowers-Lilies.jpg" >
</div>
</div>
Right now it looks like below, but I'd like the image in the second slide to fill up the screen (maintaining aspect ratio).
Is there some way to zoom in by changing the data-scale or the camera angle? Or will some css tricks suffice? I started with the default example template.
Share Improve this question asked Jun 1, 2016 at 6:03 M.R.M.R. 1,0732 gold badges16 silver badges31 bronze badges4 Answers
Reset to default 2Add this to the css (X is the number of the step in question):
#step-X html,body{
margin:0;
height:100%;
overflow:hidden;
}
#step-X img{
min-height:100%;
min-width:100%;
height:auto;
width:auto;
position:absolute;
top:-100%; bottom:-100%;
left:-100%; right:-100%;
margin:auto;
}
and this to the html:
<div class="step" data-rel-x="2000" data-rel-y="0">
<img src="path/to/image.png" alt="">
</div>
You can use this CSS for image, I will work definitely.
/* Set rules to fill background */
min-height: 100%;
min-width: 1024px;
/* Set up proportionate scaling */
width: 100%;
height: auto;
/* Set up positioning */
position: fixed;
top: 0;
left: 0;
bottom:0;
right:0;
margin:auto;
I'm personnaly using the great object-fit: cover/contain;
properties, and I set the size of the picture to the size of the viewport, and it's enough. Note that it also works with videos if you want.
.fitImage {
width: 100vw;
height: 100vh;
margin: 0;
padding:0;
background: black;
}
.fitImage img {
width: 100%;
height: 100%;
object-fit: contain;
}
<div class="step fitImage" data-x="0" data-y="0" data-scale="2">
<img src="picture.png" />
</div>
This answer is pretty late. But it may help some googlers (all of us) later :)
The trick is to bine the attribute data-scale=2 (or a bigger number than 2) on the slide, thus we have <div class="step" data-scale=2></div>
Then we fill this slide with an image and increase the height and width attributes of the image. Finally we have something like this :
<div class="step" data-scale=2>
<img src="src/of/image.jpeg" style="position: absolute; left: 0px; top: 0px; z-index: -1; width: 9000px; height: 1000px">
</div>
We can bine data-scale and dimensions (height,width) of the image until we are satisfied with the quality of the image.
Please refer to this link for more details : Hinco (impress.js contributor) Blog
My impress.js slides have images that I would like to fill the screen and center, here's the code:
<div id="impress">
<div class="step" data-x="-10000" data-y="100" data-z="0" data-scale="1">
Introduction
</div>
<div class="step" data-x="-10000" data-y="-1100" data-z="1000" data-scale="1">
<img src="images/Wallpaper-Abstract-Fractal-Flowers-Lilies.jpg" >
</div>
</div>
Right now it looks like below, but I'd like the image in the second slide to fill up the screen (maintaining aspect ratio).
Is there some way to zoom in by changing the data-scale or the camera angle? Or will some css tricks suffice? I started with the default example template.
My impress.js slides have images that I would like to fill the screen and center, here's the code:
<div id="impress">
<div class="step" data-x="-10000" data-y="100" data-z="0" data-scale="1">
Introduction
</div>
<div class="step" data-x="-10000" data-y="-1100" data-z="1000" data-scale="1">
<img src="images/Wallpaper-Abstract-Fractal-Flowers-Lilies.jpg" >
</div>
</div>
Right now it looks like below, but I'd like the image in the second slide to fill up the screen (maintaining aspect ratio).
Is there some way to zoom in by changing the data-scale or the camera angle? Or will some css tricks suffice? I started with the default example template.
Share Improve this question asked Jun 1, 2016 at 6:03 M.R.M.R. 1,0732 gold badges16 silver badges31 bronze badges4 Answers
Reset to default 2Add this to the css (X is the number of the step in question):
#step-X html,body{
margin:0;
height:100%;
overflow:hidden;
}
#step-X img{
min-height:100%;
min-width:100%;
height:auto;
width:auto;
position:absolute;
top:-100%; bottom:-100%;
left:-100%; right:-100%;
margin:auto;
}
and this to the html:
<div class="step" data-rel-x="2000" data-rel-y="0">
<img src="path/to/image.png" alt="">
</div>
You can use this CSS for image, I will work definitely.
/* Set rules to fill background */
min-height: 100%;
min-width: 1024px;
/* Set up proportionate scaling */
width: 100%;
height: auto;
/* Set up positioning */
position: fixed;
top: 0;
left: 0;
bottom:0;
right:0;
margin:auto;
I'm personnaly using the great object-fit: cover/contain;
properties, and I set the size of the picture to the size of the viewport, and it's enough. Note that it also works with videos if you want.
.fitImage {
width: 100vw;
height: 100vh;
margin: 0;
padding:0;
background: black;
}
.fitImage img {
width: 100%;
height: 100%;
object-fit: contain;
}
<div class="step fitImage" data-x="0" data-y="0" data-scale="2">
<img src="picture.png" />
</div>
This answer is pretty late. But it may help some googlers (all of us) later :)
The trick is to bine the attribute data-scale=2 (or a bigger number than 2) on the slide, thus we have <div class="step" data-scale=2></div>
Then we fill this slide with an image and increase the height and width attributes of the image. Finally we have something like this :
<div class="step" data-scale=2>
<img src="src/of/image.jpeg" style="position: absolute; left: 0px; top: 0px; z-index: -1; width: 9000px; height: 1000px">
</div>
We can bine data-scale and dimensions (height,width) of the image until we are satisfied with the quality of the image.
Please refer to this link for more details : Hinco (impress.js contributor) Blog
本文标签: javascriptHow to fill the screen with image in impressjsStack Overflow
版权声明:本文标题:javascript - How to fill the screen with image in impress.js? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745630301a2160120.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论