css - 为什么我的 div 宽度 100% 不起作用,即使我使用新类

标签 css wordpress

我有默认类 .sub-menu 的子菜单,固定宽度为 270px。我有一个具有自定义类.sub-menu-custom。但它仍然使用 270px 的旧类,即使我不放它。

enter image description here

即使在检查元素上,也没有 270px

enter image description here

这是我的代码。

#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/

相关文章:

php - WordPress:获取数据并排序

php - 返回站点名称的 Wordpress 插件

php - WordPress $wpdb->选项

php - 验证码在 localhost 上工作正常,但不能在线工作

html - 在这种情况下,当我增加 border-right 时会发生什么?

html - 在每张幻灯片上插入文本

html - 使用css定位img元素

iphone - Wordpress二十二子主题响应式布局问题

设置div高度的CSS表达式

javascript - materializeCSS - 带有选项卡的扩展导航栏作为页面链接