搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

Learn More

I tried using a button tag with overflow: hidden and an inner img tag with position: relative and left: -34px. The image is not positioned correctly by 4px.

more options

styling:

#user-menu button,
#user-menu .sheet17x17 {
    background-color: transparent;
    cursor: pointer;
}
#user-menu .sheet17x17 {
    margin: 2px;
    width: 17px;
    height: 17px;
    overflow: hidden;
    white-space: nowrap;
    display: inline-block;
}
#user-menu .sheet17x17.sheet-effects>img {
    position: relative;
}
#user-menu .sheet17x17.sheet-effects:hover>img {
    right: 17px;
}
#user-menu #user-menu-profile:hover>img {
    outline: solid azure 1px;
}
#user-menu #user-menu-social>img {
    margin-left: -68px;
    margin-top: -143px;
}

html:

                <div id="user-menu">
                    <span id="welcome-msg" class="lang-content">Welcome, </span><span id="goto-profile">Guest!</span> &nbsp;
                    <button id="user-menu-profile"><img src="profiles/erich.seac/avatars/avatar-28x28.png" /></button>
                    <button id="user-menu-comm" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></button >
                    <button id="user-menu-social" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></button >
                    <button id="user-menu-aux" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></button >
                </div>

----- however this works -----

                <div id="user-menu">
                    <span id="welcome-msg" class="lang-content">Welcome, </span><span id="goto-profile">Guest!</span> &nbsp;
                    <button id="user-menu-profile"><img src="profiles/erich.seac/avatars/avatar-28x28.png" /></button>
                    <div id="user-menu-comm" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></div>
                    <div id="user-menu-social" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></div>
                    <div id="user-menu-aux" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></div>
                </div>
styling: <pre><nowiki>#user-menu button, #user-menu .sheet17x17 { background-color: transparent; cursor: pointer; } #user-menu .sheet17x17 { margin: 2px; width: 17px; height: 17px; overflow: hidden; white-space: nowrap; display: inline-block; } #user-menu .sheet17x17.sheet-effects>img { position: relative; } #user-menu .sheet17x17.sheet-effects:hover>img { right: 17px; } #user-menu #user-menu-profile:hover>img { outline: solid azure 1px; } #user-menu #user-menu-social>img { margin-left: -68px; margin-top: -143px; } </nowiki></pre> html: <pre><nowiki> <div id="user-menu"> <span id="welcome-msg" class="lang-content">Welcome, </span><span id="goto-profile">Guest!</span> &nbsp; <button id="user-menu-profile"><img src="profiles/erich.seac/avatars/avatar-28x28.png" /></button> <button id="user-menu-comm" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></button > <button id="user-menu-social" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></button > <button id="user-menu-aux" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></button > </div> </nowiki></pre> <nowiki>----- however this works -----</nowiki> <pre><nowiki> <div id="user-menu"> <span id="welcome-msg" class="lang-content">Welcome, </span><span id="goto-profile">Guest!</span> &nbsp; <button id="user-menu-profile"><img src="profiles/erich.seac/avatars/avatar-28x28.png" /></button> <div id="user-menu-comm" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></div> <div id="user-menu-social" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></div> <div id="user-menu-aux" class="sheet17x17 sheet-effects"><img src="css/kacang.png" /></div> </div></nowiki></pre>

由cor-el于修改

被采纳的解决方案

You can post a more complete test case using this site if you don't have other hosting: jsFiddle

定位到答案原位置 👍 0

所有回复 (9)

more options

Sorry, the forum's wiki-based markup is not friendly to hash symbols. If you can edit your post and place a space before each # symbol, it will not be turned into a number.

more options

I've edited the text to show the CSS and HTML code properly.

more options

Which DOCTYPE are you using (if any) to avoid Firefox from using quirks mode?

more options

By default:

button {padding: 0 6px;}
div {padding: 0;}

That might explain the discrepancy.

more options

Thanks for the reply and I see that my code sample is by far not complete.

Based on what I posted that would be a fair conclusion, however that is not the case. I do in fact set the padding to 0px for buttons inside the div in the actualy case.

Thank you for taking the time to answer by question and sorry for not providing enough information.

more options

thanks for the tip.

more options

选择的解决方案

You can post a more complete test case using this site if you don't have other hosting: jsFiddle