I wanna set the button width depending on its child element (which is tag).
But, the button only consider the child's pure content width, and ignore the padding of the child.
I tried to set width of the button to fit-content, max-content, auto and so on, and didn't work.
How can I fix this?
CSS
*,
*::before,
*::after {
box-sizing: border-box;
}
button {
display: inline-block;
padding: 0;
margin: 0;
& > a {
display: inline-block;
padding: calc(13px / 1.618) calc(100% / 1.618 / 1.618);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
}
button {
display: inline-block;
padding: 0;
margin: 0;
}
button > a {
display: inline-block;
padding: calc(13px / 1.618) calc(100% / 1.618 / 1.618);
}
<button><a>click</a></button>