简体   繁体   English

我怎样才能让父母<button>采取孩子的大小</button><svg>

[英]How can I make parent <button> take size of child <svg>

I use svg image with help of use from previously created sprite.我使用SVG图像以帮助use以前创建的精灵。 The problem is that when I have <svg> inside of button then div takes the whole space available when expected income is to be the same size as child.问题是,当我在button内有<svg>时,当预期收入与孩子的大小相同时,div 会占用整个可用空间。 Any help?有什么帮助吗?

My code:我的代码:

 <button class="presentation__video-controls-play-pause" id="play-pause"> <svg class="play-pause-icon" width="22" height="29" viewBox="0 0 22 29"> <use href="img/icons/sprite.svg#play"></use> </svg> </button>

you have to make padding and margin of parent 0你必须制作父 0 的填充和边距

 <button class="presentation__video-controls-play-pause" id="play-pause" style="padding:0px;margin:0px;"> <svg class="play-pause-icon" width="22" height="29" viewBox="0 0 22 29"> <use href="img/icons/sprite.svg#play"></use> </svg> </button>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM