我有默认类 .sub-menu
的子菜单,固定宽度为 270px。我有一个具有自定义类.sub-menu-custom
。但它仍然使用 270px
的旧类,即使我不放它。
即使在检查元素上,也没有 270px
这是我的代码。
#custom-menu-news-and-events .sub-menu-custom {
position: absolute;
left: initial;
right: 0;
max-width: 100%;
width: 100%;
overflow: hidden;
}
您可以在这里查看我的网站: https://gcm.edu.ph/
最佳答案
它按预期工作并将宽度设置为父元素 (li) 的 100%。 更改您的 .sub-menu-custom 以像其他人一样阅读:
#custom-menu-news-and-events .sub-menu-custom {
position: absolute;
left: initial;
right: 0;
max-width: none;
width: 100%;
overflow: hidden;
position: fixed;
}
关于css - 为什么我的 div 宽度 100% 不起作用,即使我使用新类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68370353/