חיפוש בתמיכה

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

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

Read this answer in context 👍 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