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 can I make button auto width to its parent div

I can’t make a button auto its width to the parent div it is a child of. How do I make that?

See the problem in action.

Here is the code (html structure) if you need it:

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

<div class="drp">
  <button class="drp-btn" id="i-drp-btn">m/s</button>
  <div id="i-speed-drp" class="drp-content">
    <button class="drp-btn-elem" value="m/s">m/s</button>
    <button class="drp-btn-elem" value="km/h">km/h</button>
  </div>
</div>

>Solution :

Did you try width: 100% on your button style?
It should take the size of the parent, except if you have margin defined on your parent or padding defined on your button.

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