为什么溢出:隐藏与 material 图标一起使用?
Why doesn't overflow: hidden work with material icons?
在下面的示例中,为什么 overflow: hidden;
对图块对象不起作用?
#tileContainer {
background-color: gray;
padding: 10px;
}
.tile {
display: inline-block;
padding: 10px;
margin: 10px;
width: 120px;
height: 120px;
background-color: white;
overflow: hidden;
}
.tile i {
opacity: .25;
position: absolute;
font-size: 150px;
left: -10px;
top: 25px;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div id="tileContainer">
<div class="tile">
<i class="material-icons">account_balance</i>
<div id="tileContent">
Stuff goes here.
</div>
</div>
<div class="tile">
<div id="tileContent">
Stuff goes here.
</div>
</div>
</div>
想要的结果更像这样:
将 position: relative
添加到 .tile
时有效。我猜这是因为 position: absolute
将元素从磁贴流中拉出。
因为position: absolute;
。
看到这个答案:CSS overflow hidden with absolute position.
在下面的示例中,为什么 overflow: hidden;
对图块对象不起作用?
#tileContainer {
background-color: gray;
padding: 10px;
}
.tile {
display: inline-block;
padding: 10px;
margin: 10px;
width: 120px;
height: 120px;
background-color: white;
overflow: hidden;
}
.tile i {
opacity: .25;
position: absolute;
font-size: 150px;
left: -10px;
top: 25px;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div id="tileContainer">
<div class="tile">
<i class="material-icons">account_balance</i>
<div id="tileContent">
Stuff goes here.
</div>
</div>
<div class="tile">
<div id="tileContent">
Stuff goes here.
</div>
</div>
</div>
想要的结果更像这样:
将 position: relative
添加到 .tile
时有效。我猜这是因为 position: absolute
将元素从磁贴流中拉出。
因为position: absolute;
。
看到这个答案:CSS overflow hidden with absolute position.