Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to create an upgrade box in html and css

I’m creating a game.
I need upgrades-button for that game so this is what I tried:

#upgbtn {
  padding: 4px 16px;
  background: yellowgreen;
  border: 4px solid black;
  border-radius: 10px;
}

#upgrade1 {
  padding: 9px 10px;
  background: yellow;
  border: 4px solid black;
  border-radius: 10px;
}
<div id="upgrade1">
  LV <span id="lvs">1</span>
  <div>
    <button id="upgbtn">Upgrade</button>
  </div>
</div>

That is way too long. But that one I want is the one when it is a box but not a long rectangle.

I tried using inline elements like <a>, <span> and more. This is the result:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

#upgbtn {
  padding: 4px 16px;
  background: yellowgreen;
  border: 4px solid black;
  border-radius: 10px;
}

#upgrade1 {
  padding: 9px 10px;
  background: yellow;
  border: 4px solid black;
  border-radius: 10px;
}
<span id="upgrade1">
LV <span id="lvs">1</span>
<div>
  <button id="upgbtn">Upgrade</button>
</div>
</span>

And that is the last thing I tried.

>Solution :

There multiple ways to solve it. as @TemaniAfif already stated in the comments upgrade1 { display: inline-block } is one way to solve it.

Another option would be to set the width to min-content: upgrade1 { width: min-content }

#upgbtn {
  padding: 4px 16px;
  background: yellowgreen;
  border: 4px solid black;
  border-radius: 10px;
}

#upgrade1 {
  padding: 9px 10px;
  background: yellow;
  border: 4px solid black;
  border-radius: 10px;
  width: min-content;
}
<div id="upgrade1">
  LV <span id="lvs">1</span>
  <div>
    <button id="upgbtn">Upgrade</button>
  </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading