Make button width fit to the text

后端 未结 8 662
一生所求
一生所求 2020-12-29 20:29

While I was fiddling with this \'Fancy 3D Button\' example, I found that the width seemed to be hard-coded to fit the text\'s width.

Here is the HTML /

8条回答
  •  情深已故
    2020-12-29 21:28

    I like Roger Cruz's answer of:

    width: fit-content;
    

    and I just want to add that you can use

    padding: 0px 10px;
    

    to add a nice 10px padding on the right and left side of the text in the button. Otherwise the text would be right up along the edge of the button and that wouldn't look good.

提交回复
热议问题