我有一个图像,即使它的父级设置为overflow: hidden
,它仍然溢出并在页面上创建水平滚动。此处显示
以下是相关代码:
.section2img {
overflow-x: hidden !important;
height: min-content;
position: relative;
width: 50vw;
right: -60%;
top: 0;
}
.section2 img {
position: relative;
overflow-x: hidden !important;
}
GitRepo(如果需要(所以你可以做的是设置img的宽度,使其与网站匹配,然后将object-fit: cover;
添加到img中,它所做的就是剪切溢出的部分。