html - 我的悬停按钮的 CSS 过渡将容器向下推

标签 html css css-transitions css-transforms

我在一个 HTML h3 标签上有一个转换,我已经把它变成了一个按钮。在 :hover 上,我让它沿 y 轴向下平移 10px 并按比例放大 1.10。当转换发生时,它会像我将在屏幕截图中显示的那样轻微地将容器向下推:

enter image description here

enter image description here

我知道这很难看清,但它会向下推大约 2-5 个像素。我一直无法弄清楚为什么会这样。我在这里重新创建了这个问题:http://codepen.io/marlee/pen/VaLZPW?editors=1100

这是 html:

<article class="about-page-cta">
      <h3>Want to get to know us better?</h3>
        <a href="contact.html"><h4 class="contact-us-button">CONTACT US</h4>     </a>
    </article>

和 CSS:

.about-page-cta{
 background-color: #30c0d8;
 display: flex;
 flex-direction: column;
 align-items: center;
 padding: 2rem 0 2rem 0
 }

.about-page-cta h3{
margin-top: 0;
padding-top: 2rem;
color: white;
}

.about-page-cta a {
text-decoration: none;
}

.contact-us-button{
color: white;
background: #FF6952;
border-radius: 10%;
border: none;
padding: .75rem;
margin: 1rem;
transition: transform, background, .5s ease;
transform: scale(1);
}

.contact-us-button:hover{
background: #ff5339;
box-shadow: 0 0 6px white;
transform: scale(1.05);
}

感谢任何帮助!!

最佳答案

你的问题是 border-bottomanchor taghover 上..

a:hover{
  text-decoration: none; 
  color: #FF6952;
  border-bottom: 2px solid #30C0D8;
}

删除 border-bottom 属性或更具体地说明要应用边框的位置。或者

.about-page-cta a:hover {
border:0;
}

我想这应该可以解决问题......

*你的codepen的第86行

关于html - 我的悬停按钮的 CSS 过渡将容器向下推,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35738669/

相关文章:

html - 悬停时模糊叠加展开

javascript - 在 div 中只拖放一个按钮

html - 如何获取不包括孙子元素的所有子元素

javascript - 使用 fullpage.js 将类添加到粘性菜单

javascript - Jquery 提交与 javascript 提交

javascript - 当消息出现时动态应用 CSS JSF + JavaScript

css - 在网站上嵌入 Helvetica 字体?

javascript - 无法在位置固定的父元素中使用模态

html - 我怎样才能在一个 div 上为这两个东西设置动画?

css - 如何附加而不是替换转换值?