<div class="g-wrap">
<div class="g-container">
<p>1122334455</p>
</div>
<div class="g-container overflow">
<p>1122334455</p>
</div>
<div class="g-container clip">
<p>1122334455</p>
</div>
<div class="g-container contain">
<p>1122334455</p>
</div>
</div>
<div class="g-tips">
<div><span>正常布局</span></div>
<div><span>overflow: hidden</span></div>
<div><span>clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%)</span></div>
<div><span>contain: paint</span></div>
</div>
body, html {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
padding: 10px;
overflow: hidden;
}
.g-container {
width: 150px;
height: 100px;
padding: 10px;
background: #fc0;
p {
width: 100%;
border: 1px solid #333;
margin-left: -60px;
font-size: 18px;
}
}
.overflow {
overflow: hidden;
}
.clip {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
.contain {
contain: paint;
}
/** useless code **/
.g-wrap {
width: 100%;
display: flex;
justify-content: space-around;
}
.g-tips {
margin-top: 24px;
display: flex;
justify-content: space-around;
font-size: 14px;
font-weight: bold;
div {
width: 250px;
text-align: center;
}
span {
color: deeppink;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.