在溢出文本之前隐藏图标
在我的网站上,我有一些瓷砖可以显示一些内容。根据屏幕截图,每行瓷砖的数量正在改变。每个瓷砖都有一个带有图标和文本的按钮。
我的问题是,在某些屏幕上,该按钮变为小,因此文本显示在新行中。
当按钮较小以在一行中显示两个时,我想做的是将图标隐藏在文本的前面。有什么方法可以实现吗?
示例代码:
.container {
display: flex;
flex-wrap: wrap;
}
.tile {
width: 50%;
}
@media screen and (min-width: 350px) {
.tile {
width: 33.3333%;
}
}
@media screen and (min-width: 500px) {
.tile {
width: 25%;
}
}
.tile_content {
margin: 10px;
background: grey;
}
button {
width: 100%;
}
<div class="container">
<div class="tile">
<div class="tile_content">
<div>
some content...
</div>
<div>
<button>
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="30px" height="30px">
<path d="M15,3C8.373,3,3,8.373,3,15c0,6.627,5.373,12,12,12s12-5.373,12-12C27,8.373,21.627,3,15,3z M16,21h-2v-7h2V21z M15,11.5 c-0.828,0-1.5-0.672-1.5-1.5s0.672-1.5,1.5-1.5s1.5,0.672,1.5,1.5S15.828,11.5,15,11.5z" /></svg>
<span>Informations</span>
</button>
</div>
</div>
</div>
<div class="tile">
<div class="tile_content">
<div>
some content...
</div>
<div>
<button>
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="30px" height="30px">
<path d="M15,3C8.373,3,3,8.373,3,15c0,6.627,5.373,12,12,12s12-5.373,12-12C27,8.373,21.627,3,15,3z M16,21h-2v-7h2V21z M15,11.5 c-0.828,0-1.5-0.672-1.5-1.5s0.672-1.5,1.5-1.5s1.5,0.672,1.5,1.5S15.828,11.5,15,11.5z" /></svg>
<span>Informations</span>
</button>
</div>
</div>
</div>
<div class="tile">
<div class="tile_content">
<div>
some content...
</div>
<div>
<button>
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="30px" height="30px">
<path d="M15,3C8.373,3,3,8.373,3,15c0,6.627,5.373,12,12,12s12-5.373,12-12C27,8.373,21.627,3,15,3z M16,21h-2v-7h2V21z M15,11.5 c-0.828,0-1.5-0.672-1.5-1.5s0.672-1.5,1.5-1.5s1.5,0.672,1.5,1.5S15.828,11.5,15,11.5z" /></svg>
<span>Informations</span>
</button>
</div>
</div>
</div>
<div class="tile">
<div class="tile_content">
<div>
some content...
</div>
<div>
<button>
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="30px" height="30px">
<path d="M15,3C8.373,3,3,8.373,3,15c0,6.627,5.373,12,12,12s12-5.373,12-12C27,8.373,21.627,3,15,3z M16,21h-2v-7h2V21z M15,11.5 c-0.828,0-1.5-0.672-1.5-1.5s0.672-1.5,1.5-1.5s1.5,0.672,1.5,1.5S15.828,11.5,15,11.5z" /></svg>
<span>Informations</span>
</button>
</div>
</div>
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了这篇文章解释了如何做:
https://jsfiddle.net/0uehno5l/
I found this article explaining how to do it:
https://www.freecodecamp.org/news/the-fab-four-technique-to-create-responsive-emails-without-media-queries-baf11fdfa848/
https://jsfiddle.net/0uehno5L/