Search results
31 gru 2014 · Remove the width and display: block and then add display: inline-block to the button. To have it remain centered you can either add text-align: center; on the body or do the same on a newly created container.
To adjust a button's width to fit the text, set the width CSS property on the button to fit-content. The fit-content CSS property makes it so the button's width will be set based on the size of its content.
7 maj 2015 · You should try setting a min-width instead of a width, this will let the button expand if need be. Once you do this you should also set some horizontal padding so the text isnt butted up to the end like so: input[type="submit"] { min-width: 26%; padding: 5px 15px; } http://jsfiddle.net/jqjxd0xt/
@media screen and (min-width: 601px) { div.example { font-size: 80px; }} /* If the screen size is 600px wide or less, set the font-size of <div> to 30px */ @media screen and (max-width: 600px) { div.example { font-size: 30px; }}
5 lut 2017 · What is the best practice for a UI, to make all the similar buttons with a fixed-width, no matter how long is the text (with the condition to fit) or make the width proportional with the text and add the same padding?
text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; } .button1 {width: 250px;}
The button will scale to fit the text inside it, with a minimum width of 100px and a maximum width of 200px. You can adjust the padding , min-width , and max-width values in the CSS class to fit the text inside the button according to your requirements.