我在标题 div 中有 4 个按钮。我已将它们全部放置在 css 中的顶部和左侧边距,因此它们都在一行中彼此相邻。没有什么花哨。
现在我正在尝试在按下按钮时执行一项操作,按钮文本会向下移动一点。
我在 CSS 中使用这段代码:
#btnhome:active{
line-height : 25px;
}
HTML:
<div id="header">
<button id="btnhome">Home</button>
<button id="btnabout">About</button>
<button id="btncontact">Contact</button>
<button id="btnsup">Help Us</button>
</div>
按钮 CSS 示例:
#btnhome {
margin-left: 121px;
margin-top: 1px;
width: 84px;
height: 45px;
background: transparent;
border: none;
color: white;
font-size:14px;
font-weight:700;
}
这些按钮也适用于标题背景,我确信它与这些设置有关:
#header {
background-image: url(images/navbar588.png);
height: 48px;
width: 588px;
margin: 2em auto;
}
它运作良好,但唯一的问题是所有其他按钮也将其文本向下移动?这是为什么?我不是清楚地澄清我只想使用#btnhome 吗?所有按钮都有完全不同的 ID。除边距外,所有按钮都具有相同的 CSS 设置。我需要编辑什么?
非常感谢你。