【发布时间】:2019-11-07 03:28:32
【问题描述】:
我需要使特定类的按钮和链接看起来和定位相同。我试过这个(简化):
<html>
<head>
<title>My site</title>
<style>
.my-class {
display: inline-block;
background-color: #cccccc;
width: 18px;
height: 18px;
cursor:pointer;
box-sizing: border-box;
border: 1px solid #888888;
}
</style>
</head>
<body>
<a href="#" class="my-class" title="My link"></a>
<button class="my-class" type="submit" title="My button"></button>
</body>
</html>
但是链接的位置比按钮高一点:
是否有跨浏览器的纯 css 解决方案(无 javascript)允许将它们定位在同一级别上?
【问题讨论】:
-
你加了
float:left; -
谢谢迪佩什。是的,它解决了问题。
-
看看有时我们只需要 cmets 来解决问题
标签: html css button cross-browser positioning