在按钮改变高度后使标题保持不变
Making title stay put after buttons change height
我有一个页面正在尝试制作动画。现在发生的情况是,当页面加载时,页眉会淡入并向上移动。之后,每次用户将鼠标悬停在按钮上时,按钮的颜色和高度都会发生变化。问题是,每当按钮改变高度时,其上方的文本(标题)也会向上移动。如何防止这种情况发生?
除了给出解决方案外,任何关于删除多余代码的提示或其他风格提示都将不胜感激。
.nav-button {
width: auto;
font-size: 0.6em;
padding: 1%;
font-family: 'Raleway', sans-serif;
border: 0.1em solid;
border-color: transparent;
border-radius: 3%;
cursor: pointer;
opacity: 0.8;
height: 1.7em;
}
#apply-button {
background-color: #28A55C;
transition: background-color 0.3s ease-in-out;
transition-delay: 0.2s;
transition: height 0.3s ease-in-out;
}
#apply-button:hover {
background-color: #DF1C40;
height: 2.4em;
}
#about-button {
background-color: #97BBDD;
transition: background-color 0.3s ease;
transition-delay: 0.2s;
transition: height 0.3s ease-in-out;
}
#about-button:hover {
background-color: #DF1C40;
height: 2.4em;
}
#sponsor-button {
background-color: #FF9D28;
transition: background-color 0.3s ease;
transition-delay: 0.2s;
transition: height 0.3s ease-in-out;
}
#sponsor-button:hover {
background-color: #DF1C40;
height: 2.4em;
}
<!-- intro page -->
<div id="splash" tabindex='1'>
<div id="header">
<div id="title">
<strong>DubsTech</strong>
<br>
Students teaching Students
<br>
</div>
<button class="nav-button" id="apply-button">Apply!</button>
<button class="nav-button" id="about-button">About</button>
<button class="nav-button" id="sponsor-button">Sponsor</button>
</div>
</div>
这是因为这三个按钮都是"title"元素的兄弟元素。任何布局更改都会更改其公共父元素"#header"。一种解决方案是使用另一个包装器"div"来包装所有这些按钮,并将该包装器设置为"height:2.4em",这样按钮的高度转换就不会影响"title"。
相关文章:
- 使用JavaScript将标题文本替换为按钮文本
- 如何在jQuery对话框标题栏中添加额外的按钮
- 在按钮改变高度后使标题保持不变
- 如何在标题上创建弹出框,当点击关闭按钮时,不使用jquery或php在网站中显示
- 您可以更改javascript确认上的按钮标题吗
- 类似facebook的按钮没有显示在fancybox标题中
- mvc4-jscript基于行数据多个值更改按钮标题
- Chocolat.JS-将标题转换为下载按钮-将span类内容移动到href中
- 更改单选按钮状态时更改标题
- 通过响应按钮单击更改表标题,其中行使用 JSTL for 循环更新
- 页面更改时动态更改标题按钮图标,jQuery mobile 1.4.5
- 使用带有哈希标签的链接处理类似Facebook的按钮信息(标题和图像)
- 如何使用javascript移除/隐藏、更改输入按钮的标题
- 使用 Jquery 自定义按钮和滑块(大小、位置、标题大小)
- 如何将我们自己的按钮添加到浏览器的标题栏中
- 单击后,如何在javascript函数中获取单击按钮的标题
- 钛应用器打开新窗口和上一个标题的动态后退按钮
- 如果我知道按钮的 id,如何使用 javascript 设置 DOM 按钮的标题
- 使用标题按钮更改jquery移动页面
- 标题按钮's文本/字体-重量无意中改变