【问题标题】:Stabelize rest of page, when button hover当按钮悬停时稳定页面的其余部分
【发布时间】:2018-09-16 03:04:59
【问题描述】:

当我将鼠标悬停在按钮上时,大小会发生变化,这正是我想要的。

但是,下面的所有内容都会因旧按钮大小和新按钮大小之间的差异而提升。

<div id="container">

    <!-- Main Content -->

    <div id="upper_logo" ><img src="gallery/logo_small.png"/></div>

    <div id="slogan" ><p style="color: #ffffff; font-size: 50px; text-align: center">BLA BLUB BLA LEL BUL BLUE LOUB</p></div>

    <div id="play_button"><a target="_blank" href="https://SITE/google_advice/"><img src="gallery/google_play_button_small.png"></a></div>

    <div style="display: table; margin: auto;">
        <div class="button_box"><a id="buttons" target="_blank" href="LINK" ><img src="gallery/youtube_icon_smal.png"></a></div>

        <div class="button_box"><a id="buttons" target="_blank" href="LINK"><img src="gallery/different_twitter_icon_small.png"></a></div>

        <div class="button_box"><a id="buttons" target="_blank" href="LINK" ><img src="gallery/discord_icon_small.png"></a></div>

    </div>

    <!-- Description margin: auto 500px auto; -->

    <div style="text-align: left; margin: auto; width: 500px">
        <h1 style="font-size: 48px;">BLA LA BLA</h1>

        <h2 style="font-size: 24px">TEXT BLA BLA TEXT TEXT BLA BLA TEXT 2</h2>


        <h3 style="font-size: 22px">TEXT BLA BLA TEXT TEXT BLA BLA TEXT 2</h3>

        <p style="font-size: 22px">TEXT BLA BLA TEXT TEXT BLA BLA TEXT 3</p>

        <p> </p>

        <h3 style="font-size: 22px">END TEXT</h3>
    </div>

</div> 

非常感谢!

【问题讨论】:

  • 谢谢,但它仍然会影响其他元素

标签: javascript html css hover


【解决方案1】:

一种选择是在 CSS 中制作按钮 position: absolute。这样,它不会改变任何其他元素的位置。唯一的缺点是您必须为其下方的任何元素设置自定义位置。

.hover_button{
  background-color: yellow;
  padding: 15px;
  position: absolute;
}
.hover_button:hover{
  padding: 25px;
}
.below_button{
  margin-top: 90px;
}
<h1> hello this is a h1 </h1>
<button class="hover_button">When you hover on me, I will grow!</button>
<h2 class="below_button"> hello this is a h2 </h2>

【讨论】:

  • 谢谢,我可以解决它。带有 display: inline-block, position: absolute 和其他一些微小的变化:)
  • 没问题!由于此答案有效,您介意将其标记为正确吗?谢谢:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-13
  • 1970-01-01
  • 2015-10-31
  • 2014-07-03
  • 1970-01-01
相关资源
最近更新 更多