I am attempting to put a div around the buttons in my app. The divs should have a 5px padding around the button. However, the div keeps spanning the entire width of the page unless i set the width with a number. Obviously it would be much easier to have an 'auto' width for every div instead of specifying width for each individua开发者_运维知识库l button. Is there any way to do this?
stylesheet:
.button_div {width: auto; height: auto; border-radius: 10px; padding: 5px;}
view:
<div class="button_div">
Thanks!
The 'auto' width for a div is for the div to take up the full width. Div's are block-level by default.
To get a div to collapse down to the size of its contents, you need to either float it, or set the display to inline-block.
why dont you use
<button class="someClass"/>
.someClass {padding: 5px;}
精彩评论