最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Bootstrap image zoom - Stack Overflow

programmeradmin1浏览0评论

I am doing an e-merce site. I am use Bootstrap. What should I use when doing the product detail page? I want it to be as follows.

I want the picture to grow when it es to the picture.

I am doing an e-merce site. I am use Bootstrap. What should I use when doing the product detail page? I want it to be as follows.

I want the picture to grow when it es to the picture.

Share Improve this question edited Jun 25, 2017 at 16:45 Cœur 38.8k26 gold badges205 silver badges277 bronze badges asked Nov 10, 2016 at 11:12 sunay yildizsunay yildiz 792 gold badges2 silver badges13 bronze badges 2
  • The image should be in 2 format. i mean, 1 small size for thumb nail. and another one for large one. On click of the small image i.e thumbnail of the image, you need to show the large image. – Samir Commented Nov 10, 2016 at 11:15
  • To acheive this, you need Jquery and CSS as well. Please search, is there any of the Jquery plugin to do this. – Samir Commented Nov 10, 2016 at 11:16
Add a ment  | 

2 Answers 2

Reset to default 1

Here i have some code this may help you, grow your image with pure CSS.

CSS

* {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.HoverDiv {
  position: relative;
  overflow: hidden;
  border:1px solid black;
  width:360px;
  margin: 10px;
}

.HoverDiv img {
  max-width: 100%;
  text-align:center;
  -moz-transition: all 0.3s;
  -webkit-transition: all 0.3s;
  transition: all 0.3s;
}

.HoverDiv:hover img {
  -moz-transform: scale(1.1);
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}

img {
    display: inline-block;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    transition: 0.3s;
  position:relative;
  z-index:1;
}

img:hover {
    box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
   -webkit-transform: skewX(-20deg);
  -ms-transform: skewX(-20deg);
  transform: skewX(-20deg);
  -webkit-transform-origin:0 0;
  -ms-transform-origin:0 0;
  transform-origin:0 0;
}

HTML

<div class="HoverDiv">
<img src="http://pngimg./upload/tiger_PNG546.png" alt="Smiley face">
</div>

DEMO

Grow image on hover

Here is a working example

here is the html

<p>Background image:</p>

<div class="zoom-bg"></div>

<p>Using nested image and <code>object-fit</code>:</p>

<div class="zoom-img">
  <img src="https://placeimg./300/200/arch">
</div>

here is the css

.zoom-bg {
  width: 300px;
  height: 200px;
  overflow: hidden;
}

.zoom-bg:before {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: url(https://placeimg./300/200/nature) no-repeat center;
  background-size: cover;
  transition: all .3s ease-in-out;
}

.zoom-bg:hover:before {
  transform: scale(1.2);
}

.zoom-img {
  width: 300px;
  height: 200px;
  overflow: hidden;
}

.zoom-img > img {  
  object-fit: cover;
    width: 100%;
    height: 100%;
  transition: all .3s ease-in-out;
}

.zoom-img:hover > img {
  transform: scale(1.2);
}

check the working example here in codepen

发布评论

评论列表(0)

  1. 暂无评论