首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有缩略图和缩放功能的仅CSS图片库

具有缩略图和缩放功能的仅CSS图片库
EN

Stack Overflow用户
提问于 2016-06-14 16:40:51
回答 3查看 2.3K关注 0票数 0

有没有可能有一个带有缩略图和带有缩放功能的大预览的图片库?像cloudzoom,但是没有任何JS,jQuery,脚本等等,因为所有形式的“脚本和动作”都是被禁止的,不会起作用。

我们只能使用HTML5和CSS3,不能使用脚本

谢谢

EN

回答 3

Stack Overflow用户

发布于 2016-06-14 17:56:18

看看这个。希望能对你有所帮助。

代码语言:javascript
复制
#images-box {
    /* The total width of the image-box, mainly for centering */
    width: 850px;
    margin: 0px auto;
    position: relative;
    top: 70px;
}
 
.image-lightbox img {
    /* Inherit the width and height from the parent element */
    width: inherit;
    height: inherit;
}
 
.holder {
    /* The width and height, you can change these */
    width: 250px;
    height: 166px;
    /* Float left, so everything aligns right */
    float: left;
    margin: 0 20px 0 0;
}
 
.image-lightbox {
    /* Inherit width and height from the .holder */
    width: inherit;
    height: inherit;
    padding: 10px;
    /* Box shadow */
    box-shadow: 0px 0px 10px rgba(0,0,0,0.1);
    background: #fff;
    border-radius: 5px;
    /* Position absolutely so we can zoom it out later */
    position: absolute;
    top: 0;
    font-family: Arial, sans-serif;
    /* Transitions to provide some eye candy */
    -webkit-transition: all ease-in 0.5s;
    -moz-transition: all ease-in 0.5s;
    -ms-transition: all ease-in 0.5s;
    -o-transition: all ease-in 0.5s;
}
 
.image-lightbox span {
    display: none;
}
 
.image-lightbox .expand {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}
 
.image-lightbox .close {
    position: absolute;
    width: 20px; height: 20px;
    right: 20px; top: 20px;
}
 
.image-lightbox .close a {
    height: auto; width: auto;
    padding: 5px 10px;
    color: #fff;
    text-decoration: none;
    background: #22272c;
    box-shadow: inset 0px 24px 20px -15px rgba(255, 255, 255, 0.1), inset 0px 0px 10px rgba(0,0,0,0.4), 0px 0px 30px rgba(255,255,255,0.4);
    border-radius: 5px;
    font-weight: bold;
    float: right;
}
 
.close a:hover {
    box-shadow: inset 0px -24px 20px -15px rgba(255, 255, 255, 0.01), inset 0px 0px 10px rgba(0,0,0,0.4), 0px 0px 20px rgba(255,255,255,0.4);
}
 
div[id^=image]:target {
    width: 450px;
    height: 300px;
    z-index: 5000;
    top: 50px;
    left: 200px;
}
div[id^=image]:target .close {
    display: block;
}
 
div[id^=image]:target .expand {
    display: none;
}
 
div#image-1:target, div#image-2:target, div#image-3:target { left: 200px; }
 
div#image-1 { left: 0; }
div#image-2 { left: 290px; }
div#image-3 { left: 580px; }
代码语言:javascript
复制
<div id="images-box">
    <div class="holder">
        <div id="image-1" class="image-lightbox">
            <span class="close"><a href="#">X</a></span>
            <img src="http://www.techinsights.com/uploadedImages/Public_Website/Content_-_Primary/Teardowncom/Sample_Reports/sample-icon.png" alt="earth!">
            <a class="expand" href="#image-1"></a>
        </div>
    </div>
    <div class="holder">
        <div id="image-2" class="image-lightbox">
            <span class="close"><a href="#">X</a></span>
            <img src="http://www.techinsights.com/uploadedImages/Public_Website/Content_-_Primary/Teardowncom/Sample_Reports/sample-icon.png" alt="earth!">
            <a class="expand" href="#image-2"></a>
        </div>
    </div>
    <div class="holder">
        <div id="image-3" class="image-lightbox">
            <span class="close"><a href="#">X</a></span>
            <img src="http://www.techinsights.com/uploadedImages/Public_Website/Content_-_Primary/Teardowncom/Sample_Reports/sample-icon.png" alt="earth!">
            <a class="expand" href="#image-3"></a>
        </div>
    </div>
</div>

票数 1
EN

Stack Overflow用户

发布于 2016-06-14 17:07:59

您可以使用css hover来实现图像缩放。使用hover属性,你可以创建一个你想要的图像缩放图库。这是它的一个示例。

https://codepen.io/Remedy/pen/ZYJrpp

代码语言:javascript
复制
<style>
* {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.item {
  position: relative;

  border: 1px solid #333;
  margin: 2%;
  overflow: hidden;
  width: 540px;
}
.item img {
  max-width: 100%;

  -moz-transition: all 0.3s;
  -webkit-transition: all 0.3s;
  transition: all 0.3s;
}
.item:hover img {
  -moz-transform: scale(1.1);
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}
</style>
<div class="item"> 
  <img src="https://upload.wikimedia.org/wikipedia/en/thumb/5/58/Pepsi_logo.svg/1280px-Pepsi_logo.svg.png" alt="pepsi" width="540" height="548">

  <div class="item-overlay top"></div>
</div>

您还可以查看下面的链接以了解完整的实现。

https://codepen.io/elad2412/pen/yfEGp

https://codepen.io/samuelmaggs/pen/ZWpjPN

票数 0
EN

Stack Overflow用户

发布于 2016-06-14 16:54:28

没有javascript或JQuery是不可能缩放图像的,我们需要使用Javascript或JQuery函数onmouseover

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37807000

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档