html - 根据部分 url 为 div 加载新的 css 样式

标签 html css url

我有 wwww.my-site.com - 当用户按下德国国旗时,它将到达 www.my-site.com/de/。现在,当显示该 URL 时,我只想更改菜单的字体大小。路径是 #topnav li a

我试过以下方法:

<script>
  if (window.location.pathname('/de') === 0)
    document.write('<style>#topnav li a{font-size: 15px!important;}</style>');
</script>

没有成功。非常欢迎任何帮助!

最佳答案

我想你的意思是:

if (window.location.pathname.indexOf('/de') === 0)

路径名 本身不是函数。

关于html - 根据部分 url 为 div 加载新的 css 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31756425/

相关文章:

html - 修复大小标签 "li"并减少粗体字号

asp.net - 如何调用 Web 服务并使用 URL 传递参数

flutter - Google map 无法在 Flutter 中使用 URL 启动器打开

javascript 只允许重定向同一域内的 url

javascript - 每个部分的不同菜单颜色/

html - 子菜单不会显示为 block

html - 左侧元素的固定边距

css - 如何在 react-native-router-flux 中设置 Scene 组件的标题

css - 如何给带尖三 Angular 形的下拉菜单添加阴影?

html - 将单个图像缩放为网格正方形?