user3044030 user3044030 - 2 years ago 58
HTML Question

HTML-How can I make a button stay in a fixed position after one beside it is removed?

I have two buttons

<button class="upgradebutton1" id="upupgrade1" onclick="browse_aww()">Browse /r/aww</button> <pr id="priceuno"> 5 </pr> <img id="upvotepicture" width=13px src=",width=178,height=178/Upvote-style-arrow.png"></img>

<button class="upgradebutton1" id="downupgrade1" onclick="grow_a_neckbeard()">Grow a neckbeard</button> <pr2 id="price2"> 5 </pr2> <img id="downvotepicture" width=13px src=""> </img>

Whenever I click the browse_aww button, the grow_a_neckbeard button slides over where the first button used to be. This is a problem with all of my upgrade buttons on the page. I've tried using css to set the position to Absolute, but that does nothing and glitches the entire thing.

Any and all help is appreciated

jsfiddle link:

Answer Source

If you set position to absolute you remove the box from the normal flow, so the other elements arranges like it never existed. You should create an identical box to replace the old one, but I think it's easier to simply disable the button, or at least set its visibility to hidden (which doesn't affect the normal flow).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download