【问题标题】:When i hover my icon for make it bigger, my page moving当我将图标悬停以使其更大时,我的页面正在移动
【发布时间】:2021-09-10 06:54:36
【问题描述】:

当我将光标放在我的图标上时,我的图标字体大小会变大,因此 div 会变大一点,它会使页面移动一点,看起来并不酷。我怎样才能在不使我的 div 更大的情况下做到这一点?我的代码:

<div className="bg-gray-100 ratingWidth tomiddle p-6 rounded-lg text-center">
      Aradığınız yanıtı bulabildiniz mi ?
      <div className="mt-3  space-x-5 h-full "> //My icon Div
        <span className="ti-thumb-up ratingEase "></span> //My icons
        <span className="ti-thumb-down ratingEase"></span>
        <br />
      </div>
    </div>

CSS:

.ratingWidth {
  width: 96%;
  height: 100%;
}
.ratingEase {
  transition: 0.2s;
  font-size: 50px;
}
.ratingEase:hover {
  transition: 0.2s;
  transition-timing-function: ease;
  font-size: 54px;
}

【问题讨论】:

    标签: html css reactjs react-native sass


    【解决方案1】:

    您可以使用绝对定位元素。 此属性使您的图标不会改变 DOM 中的任何其他项目。 即使你移动、变换或对这个元素做任何事情,其他元素也不会移动。

    .ratingEase {
        transition: 0.2s;
        font-size: 50px;
        position: absolute;
    }
    

    【讨论】:

    • 你应该尝试学习所有关于 CSS 中位置的知识,这是它最重要的方面之一。至少,位置绝对,位置相对,位置固定和位置粘性。祝你好运:)
    猜你喜欢
    • 2013-04-02
    • 2016-06-08
    • 2014-01-31
    • 1970-01-01
    • 2014-11-18
    • 1970-01-01
    • 1970-01-01
    • 2015-07-05
    • 2020-02-08
    相关资源
    最近更新 更多