html - Buttons not dependent on content, all same size -


i have struggle getting button same size when there placed different content inside button. looking tips , trick can me understand better. here picture of situasjon: enter image description here

here css code have used button part:

  .but { background-color: white; color: black; border: 2px solid #c8c8c8; height: 1.5em; text-decoration: none; display: inline-block; font-size: 1.2em; cursor: pointer; margin: -2px; }  .symbox { width: 20em; height: 5.2em; overflow-y: auto; overflow-x: hidden; border: 1px solid black; margin: 1px 0px; } 

.but buttons , .symbox border around buttons

you can use flexbox, this:

.container {    width: 4em;        display:flex;    flex-wrap:wrap;  }  .but {    border: 2px solid #ccc;    padding: 2px;    text-align: center;        flex-grow: 1;  }
<div class="container">    <div class="but">a</div>    <div class="but">b</div>    <div class="but">c</div>    <div class="but">de</div>    <div class="but">f</div>    <div class="but">ghi</div>    <div class="but">j</div>    <div class="but">k</div>    <div class="but">l</div>    <div class="but">m</div>    </div>

here's nice guide on how use flexbox effectively: https://css-tricks.com/snippets/css/a-guide-to-flexbox/


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -