链接和按钮位置

问题描述 投票:0回答:4

我需要制作特定类的按钮和链接以相同的方式进行外观和定位。我尝试过这个(简体):

<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),可以将它们定位在同一级别上?

我需要制作特定类的按钮和链接以相同的方式进行外观和定位。我尝试过此操作(简化):

我的站点

...
html css button cross-browser positioning
4个回答
0
投票
将此添加到您的CSS:

0
投票
尝试此Fiddle

0
投票
<body> <div style="height:50px;line-height:50px"> <a href="#" class="my-class" title="My link"></a> <button class="my-class" type="submit" title="My button"></button> </div> </body>

0
投票
如果您要放置特定的链接该怎么办?请回答。
© www.soinside.com 2019 - 2024. All rights reserved.