【问题标题】:How to scale out.pop up image when i hover?悬停时如何扩展。弹出图像?
【发布时间】:2022-02-04 15:41:18
【问题描述】:

我有一个图像,当它悬停时我想扩大它。

代码是用 react 和 css 编写的。我做错了什么?

这是我的gist,其中包括样式表和 js 代码

反应/js 代码

    import React from 'react';
import OwlCarousel from 'react-owl-carousel';
import 'owl.carousel/dist/assets/owl.carousel.css';
import 'owl.carousel/dist/assets/owl.theme.default.css';

import ScreenHeading from '../../utilities/ScreenHeading/ScreenHeading';
import ScrollService from '../../utilities/ScrollService';
import Animations from '../../utilities/Animations';
import './Certificates.css';
import clf from '../../img/Certs/clf.png';
import shape from '../../img/Certs/shape-bg.png';

export default function Certificate(props) {
  let fadeInScreenHandler = (screen) => {
    if (screen.fadeInScreen !== props.id) return;
    Animations.animations.fadeInScreen(props.id);
  };

  const fadeInSubscription =
    ScrollService.currentScreenFadeIn.subscribe(fadeInScreenHandler);

  const options = {
    loop: true,
    margin: 0,
    nav: true,
    animateIn: 'bounceInRight',
    animateOut: 'bounceOutRight',
    dots: true,
    autoplay: true,
    smartSpeed: 1000,
    responsive: {
      0: {
        items: 1,
      },
      768: {
        items: 1,
      },
      1000: {
        items: 3,
      },
    },
  };

  return (
    <div>
      <ScreenHeading
        title={'Certifications'}
        subHeading={'I love validating my skills'}
      />
      <section className="testimonial-section fade-in" id={props.id || ''}>
        <div className="container">
          <div className="row">
            <OwlCarousel
              className="owl-carousel"
              id="testimonial-carousel"
              {...options}
            >
              <div className="col-lg-12">
                <div className="testi-item">
                  <div className="testi-comment">
                    <p>
                      <i className="fa fa-quote-left" />
                      Learning about core aws services, shared responsibility
                      model and billing and pricing concepts was an eyeopener
                      for me as a cloud engineer.
                      <i className="fa fa-quote-right" />
                    </p>
                  </div>
                  <div className="client-info">
                    <img src={clf} alt="no internet connection"></img>
                    <h5>AWS CLF-01</h5>
                    <p></p>
                  </div>
                </div>
              </div>

              <div className="col-lg-12">
                <div className="testi-item">
                  <div className="testi-comment">
                    <p>
                      <i className="fa fa-quote-left" />
                      Coming Soon ????
                      <i className="fa fa-quote-right" />
                    </p>
                  </div>
                  <div className="client-info">
                    {/* <img src={mike} alt="no internet connection"></img> */}
                    <h5>AWS SAA</h5>
                  </div>
                </div>
              </div>
              <div className="col-lg-12">
                <div className="testi-item">
                  <div className="testi-comment">
                    <p>
                      <i className="fa fa-quote-left" />
                      Coming Soon ????
                      <i className="fa fa-quote-right" />
                    </p>
                  </div>
                  <div className="client-info">
                    {/* <img src={clf} alt="no internet connection"></img> */}
                    <h5>AWS DVA</h5>
                  </div>
                </div>
              </div>
            </OwlCarousel>
          </div>
        </div>
      </section>
      <div className="footer-image">
        <img src={shape} alt="Phot0 not responding" />
      </div>
    </div>
  );
}

css

   .testimonial-section {
  padding: 80px 0 80px;
  background-image: url('../../../src/assets/Certificates/bg-1.jpg');
  background-position: center;
  background-attachment: fixed;
  position: relative;
  z-index: -1;
}
.testimonial-section::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.85;
  background-color: #1f2235;
}
.footer-image {
  width: 100%;
  height: 100%;
  max-width: 1920px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  margin-top: -110px;
}
.footer-image img {
  max-width: 100%;
  height: 130px;
}

.testimonial-section .testi-item {
  background-color: white;
  padding: 30px;
  border-radius: 50px 50px 50px 0px;
}

.testimonial-section .testi-item p {
  font-size: 16px;
  line-height: 26px;
  font-weight: 500;
  margin: 0 0 10px;
  font-style: italic;
}
.testimonial-section .testi-item p .fa-quote-left {
  margin-right: 5px;
  color: tomato;
}
.testimonial-section .testi-item p .fa-quote-right {
  margin-left: 5px;
  color: tomato;
}

.testimonial-section .client-info {
  position: relative;
  padding-left: 80px;
  padding-top: 5px;
  min-height: 60px;
}
.testimonial-section .client-info img {
  height: 70px;
  width: 70px;
  border: 2px solid transparent;
  border-color: black;
  left: 30px;
  top: -4px;
  border-radius: 50%;
  position: relative;
}
.testimonial-section:hover .client-info img {
  transform: scale3D(1.5, 1.5, 1.5);
}
.testimonial-section .client-info h5 {
  font-size: 20px;
  font-weight: 600;
  line-height: 26px;
  margin: 0 0 2px 10px;
  position: absolute;
}

【问题讨论】:

标签: javascript html css reactjs


【解决方案1】:

试试这样写

.testimonial-section:hover .client-info img {
  transform: scale3D(1.5,1.5,1.5);
}

.testimonial-section .client-info img:hover {
  transform: scale3D(1.5,1.5,1.5);
}

【讨论】:

  • 我都试过了,没用
  • 我添加了公共要点以便更好地理解
  • 能不能给img标签加个display:inline-block或者block
  • 如果你能提供一个例子就好了
【解决方案2】:

在这种情况下,transform: scale(1.5); 应该可以工作。这是一个工作示例(不是您的代码)

.image-box {
  width: 100px;
  height: 100px;
  text-align: center;
  border: 1px solid gray;
  overflow: hidden; 
}

.image-box img {
  width: 100px;
  height: 100px;
  transition: 300ms;
}

.image-box img:hover {
  transform: scale(1.5);
}
  <div class="image-box">
    <img src="https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/1.0" alt="">
  </div>

使用您的 HTML/CSS

.client-info img {
  height: 70px;
  width: 70px;
  border: 2px solid transparent;
  border-color: black;
  left: 30px;
  top: -4px;
  border-radius: 50%;
  position: relative;
}

.client-info h5 {
  font-size: 20px;
  font-weight: 600;
  line-height: 26px;
  margin: 0 0 2px 10px;
  position: absolute;
}

.client-info:hover img {
  transform: scale3D(1.5, 1.5, 1.5);
}
  
<div class="client-info">
    <img src="https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/1.0" alt="no internet connection"></img>
    <h5>AWS CLF-01</h5>
    <p></p>
  </div>

【讨论】:

  • 试过了,没用
  • 你能用你现有的代码创建一个小提琴吗?
  • 我需要用 css 转换成纯 html js。这有点困难
  • 我刚刚检查了您属于 client-info 部分的相关 html/css 代码,它似乎正在工作。
  • 我尝试了编辑后的版本,它在我的 CSS 中也不起作用,.testimonial-section 下存在 client info
猜你喜欢
  • 1970-01-01
  • 2011-05-30
  • 1970-01-01
  • 1970-01-01
  • 2017-01-11
  • 2011-10-10
  • 1970-01-01
  • 1970-01-01
  • 2016-07-12
相关资源
最近更新 更多