php - 更改具有相同 ID joomla 的模块标题之一的 ID

标签 php html css joomla

我有这三个模块都具有相同的 id:

<?php if ($this->countModules('user2')) : ?>
    <div id="user2-wrap"><div id="user2" class="container row clr">
        <jdoc:include type="modules" name="user2" style="usergrid" grid="<?php echo $user2_width; ?>" />
    </div></div>
<?php endif; ?>

检查后我得到:

    <div id="user2-wrap"><div id="user2" class="container row clr">
                    <div class="module   span_4 col clr">
                <h3 class="module-title">Our Story</h3>
            <div class="module-body"> 
    <div class="custom">

<div id="user2-wrap"><div id="user2" class="container row clr">
                    <div class="module   span_4 col clr">
                <h3 class="module-title">Featured Training</h3>
            <div class="module-body"> 
    <div class="custom">


<div id="user2-wrap"><div id="user2" class="container row clr">
                    <div class="module   span_4 col clr">
                <h3 class="module-title">Chapters</h3>
            <div class="module-body"> 
    <div class="custom">

所有这些都有相同的类 module-title 我需要更改一个 module-title 的颜色。如何更改一个特定 module-title 的 ID?或者还有其他方法吗?

最佳答案

尝试在您的 module-title 类中使用第 nth-child 解决方案。

:nth-child(number_of_the_child_you_want_to_change) {
   your css declarations;
}

这是链接 CSS nth-child

编辑:如果您想要/可以使用 JavaScript,请使用此代码通过 class="module-title" 选择文档中的第二个元素。

<script>
document.querySelectorAll('.module-title')[1].style.color = "red";
</script>

我更改了文本颜色,当然您需要将您自己的更改插入到类元素中。

关于php - 更改具有相同 ID joomla 的模块标题之一的 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42801653/

相关文章:

php - jQuery 自动完成 JSON 引用外部 PHP 文件时出现错误 404

php - 如何将 SQL 框的值存储到 PHP 变量中

html - Icomoon 字体生成器 : Failed to decode downloaded font

javascript - 为什么样式对动态添加的内容没有任何影响

php - MySQL 数据透视表子字符串列名称

php - 描述计算文本相似度的 PHP 算法的论文 "Oliver [1993]"是什么?

javascript - $_POST 在 PHP 中不起作用。也尝试过 $_REQUEST

javascript - 来自环境变量的Angular 2 base href

html - WordPress 隐藏 IMG

javascript - 将 append 的相关元素保留在正文中