overflow-x 和 overflow-y

这两个属性的工作方式与 overflow 属性类似,并且接受相同的值。overflow-x 参数仅适用于 x 或左右轴。overflow-y 在 y 轴或从上到下轴上工作。

HTML

<div id="div-x">
    If this div is too small to display its contents, 
    the content to the left and right will be clipped.
</div>

<div id="div-y">
    If this div is too small to display its contents, 
    the content to the top and bottom will be clipped.
</div>

CSS

div {
    width: 200px;
    height: 200px;
}

#div-x {
    overflow-x: hidden;
}

#div-y {
    overflow-y: hidden;
}