Skip to content

[NODEBB] Help for my custom CSS

Solved Customisation
237 5 79.9k 3
  • How to add icon on categories span time ?

    I will test this code for add Paragraph FA icon for example :

    [component="topic/header"] span.timeago:before {
        content: "\f1dd";
        margin-right: 5px;
        margin-left: 5px;
    }
    

    Result 😞

    311ca192-524a-4c10-bcb6-02e0381b6900-image.png

  • How to add icon on categories span time ?

    I will test this code for add Paragraph FA icon for example :

    [component="topic/header"] span.timeago:before {
        content: "\f1dd";
        margin-right: 5px;
        margin-left: 5px;
    }
    

    Result 😞

    311ca192-524a-4c10-bcb6-02e0381b6900-image.png

    @DownPW that won’t work unless you add a font family to go with it - any Unicode characters typically require an associated font family. Try adding

    font-family: "font awesome 5 free"; to the CSS you already have.

  • @phenomlab

    I have test this :

    [component="topic/header"] span.timeago:before {
        content: "\f1c0";
        font-family: "font awesome 5 free";
        margin-right: 5px;
        margin-left: 5px;
        color: black;
    }
    

    But doesn’t work

    8ed44f06-ca16-4a7c-9a7b-e46a9b6fa339-image.png

  • @phenomlab

    I have test this :

    [component="topic/header"] span.timeago:before {
        content: "\f1c0";
        font-family: "font awesome 5 free";
        margin-right: 5px;
        margin-left: 5px;
        color: black;
    }
    

    But doesn’t work

    8ed44f06-ca16-4a7c-9a7b-e46a9b6fa339-image.png

    @DownPW does it work if you change it to
    Font Awesome 5 Free ? Might need to access your site directly to test this as it works for mine and should also work for you.

    One last thing you can try is adding the below into the CSS class - sometimes needed as the FA5 free icons are solid only, therefore may require

    font-weight: 900;

    Let me know how you get on

  • @DownPW does it work if you change it to
    Font Awesome 5 Free ? Might need to access your site directly to test this as it works for mine and should also work for you.

    One last thing you can try is adding the below into the CSS class - sometimes needed as the FA5 free icons are solid only, therefore may require

    font-weight: 900;

    Let me know how you get on

    @phenomlab

    That works with

    font-weight: 900;
    

    Thank you 🙂

    9a398d72-9ceb-48f7-b6c1-8e21509ced47-image.png

  • @DownPW After spending a lot of time on the theme switcher (see referenced post above), I re-wrote some of it as found that there were caching issues with CSS as it always calls the same version number. The new function below resolves that issue.

    I also removed the website prefix, as with relative paths, this is not required 🙂

    // ------------------------------------------
    // Theme Switcher
    // ------------------------------------------
    // On choisit une chaine de caractère aléatoire pour affecter un numéro de version au fichier CSS. 
    // The function below creates a random string which we use for CSS versioning to prevent cache conflicts
    function generateRandomString(length) {
        var text="";
        var possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        for (var i=0;
        i < length;
        i++) {
            text+=possible.charAt(Math.floor(Math.random() * possible.length));
        }
        return text;
    }
    
    $(document).ready(function () {
        var string=generateRandomString(10);
        $("#random_string").text(string);
        // This variable gets the theme ID 
        // Cette variable obtient l'ID du thème
        var whichTheme=localStorage.getItem("theme");
        // This variable gets the active theme's actual URL
        //Cette variable obtient l'URL réelle du thème actif
        var activeTheme=localStorage.getItem("activeTheme");
        // This variable appends the dropdown list to the existing panel
        // Cette variable ajoute la liste déroulante au panneau existant
        var panel=$('<li id="switcher" class="dropdown text-center"> \
    <label for="theme-control-list-check" class="dropdown-toggle" data-toggle="dropdown" id="theme_dropdown" title="" role="button" data-original-title="Theme" aria-expanded="false"> \
    <a class="btn-link" title="Theme Switcher" href="#"><i id="ticon" class="fa fa-fw fa-lightbulb-o"></i><span class="visible-xs-inline">Theme Switcher</span></a> \
    </label> \
    <ul id="theme" class="dropdown-menu"> \
    <li><a id="default" href="#" rel="/assets/client.css?v=e02phpkima0">Default</a></li> \
    <li><a id="default dark" href="#" rel="/assets/customcss/default_dark.css">Default Dark</a></li> \
    <li><a id="Light Flat" href="#" rel="/assets/customcss/testflat.css">Light Flat</a></li> \
    <li><a id="Dark Flat" href="#" rel="/assets/customcss/testflat.css">Dark Flat</a></li> \
    <li><a id="Dark Neon Aqua" href="#" rel="/assets/customcss/dark_neon_aqua.css">Dark Neon Aqua</a></li> \
    <li><a id="Dark Neon Blue" href="#" rel="assets/customcss/dark_neon_blue.css">Dark Neon Blue</a></li> \
    <li><a id="Dark Neon Green" href="#" rel="/assets/customcss/dark_neon_green.css">Dark Neon Green</a></li> \
    <li><a id="Dark Neon Solary" href="#" rel="/assets/customcss/dark_neon_solary.css">Dark Neon Solary</a></li> \
    <li><a id="Dark Neon White" href="#" rel="/assets/customcss/dark_neon_white.css"">Dark Neon White</a></li> \
    <li><a id="Eva 00" href="#" rel="/assets/customcss/eva_00.css">Eva.00</a></li> \
    <li><a id="Eva 01" href="#" rel="/assets/customcss/eva_01.css">Eva.01</a></li> \
    <li><a id="Eva 01 Purple Green"href="#" rel="/assets/customcss/eva_01_purple_green.css">Eva.01: Purple-Green</a></li> \
    <li><a id="Eva 02" href="#" rel="/assets/customcss/eva_02.css">Eva.02: Red-Orange</a></li> \
    </ul> \
    </div> ');
        // See if there is an active theme selected in localStorage. If none selected, use the default. If there is a theme in localStorage, use that and apply it
        // Regarde s'il y a un thème actif sélectionné dans "localStorage". Si aucun n'est sélectionné, utilise la valeur par défaut. 
        // S'il y a un thème dans localStorage, on l'utilise et on l'applique.
        if (whichTheme) {
            $("head").append("<link href='" + activeTheme + '?version=' + string + "' type=\"text/css\" rel=\'stylesheet\' />");
        }
        else {
            // No need to include anything here as there's no CSS to add.
            // Pas besoin d'inclure quoi que ce soit ici car il n'y a pas de CSS à ajouter.
        }
        $('ul#logged-in-menu').prepend(panel);
        $('ul#logged-out-menu').prepend(panel);
        if (utils.findBootstrapEnvironment()==='xs') {
            $('#menu').prepend(panel);
        }
        $(document).ready(function () {
            // Listen to the NAV dropdown for any changes
            // Écoute la liste déroulante NAV pour tout changement de thème
            $("#theme li a").on("click change", function () {
                // If we detect a change, append the selected CSS file into the DOM 
                // Si un changement est détecté, on ajoute le fichier CSS sélectionné dans le DOM (Document Object Model)
                var thishref=$(this).attr('rel');
                $("link[rel=stylesheet]").attr('href', thishref + "?version=" + string + "");
                //location.reload();
                //$("head").append("<link href='" + $(this).attr("rel") + $(this).attr("id") + " type=\'text/css\' rel=\'stylesheet\' />");
                location.reload();
                // This variable stores the selected theme ID
                // Cette variable stocke l'ID du thème sélectionné
                var selected=$(this).attr("id");
                // This variable stores the selected theme link 
                // Cette variable stocke le lien du thème sélectionné
                var theTheme=$(this).attr("rel");
                // This variable updates the selected theme ID
                // See if "default" has been selected. If it has, then...
                // Cette variable met à jour l'ID du thème sélectionné
                // Regarde si "default" a été sélectionné. Si c'est le cas, alors...
                if (selected==='default') {
                    localStorage.setItem("theme", "");
                    // This variable will strip the current appeneded theme ID
                    // Cette variable supprimera l'ID du thème actuellement ajouté
                    localStorage.setItem("activeTheme", "");
                    // This variable will strip the current appeneded theme URL (HREF)
                    // Finally, we have to reload the page to effect the changes
                    // Cette variable supprimera l'URL actuelle du thème ajouté (HREF)
                    // Enfin, on recharge la page pour effectuer les modifications
                    location.reload();
                }
                // If any other theme is selected, carry on as normnal, and update localStorage
                // Si un autre thème est sélectionné, continuez normalement et mettez à jour localStorage
                else {
                    localStorage.setItem("theme", selected);
                    // This variable updates the actual href of the CSS file
                    // Cette variable met à jour le href réel du fichier CSS
                    localStorage.setItem("activeTheme", theTheme);
                    //window.location.href = window.location.href
                }
                // We use return false to prevent the browser from reloading or following any HREF links
                // On utilise la fonction "return false" pour empêcher le navigateur de recharger ou de suivre les liens HREF
                //return false;
            }
            );
        }
        );
    }
    
    );
    // When hovering over the #switcher element, target the i class and add 'themeoff'
    // Lorsque du  survol de l'élément #switcher, on cible la classe CSS "i" et on ajoute le CSS "themeoff"
    $(document).on('mouseenter', '#switcher', function() {
        $('#switcher i').addClass("themeoff");
    }
    
    );
    // When leaving the however state, target the i class and remove 'themeoff'
    // Lorsque l'on quitte l'état, on cible la classe CSS "i" et on supprime le CSS "themeoff"
    $(document).on('mouseleave', '#switcher', function() {
        $('#switcher i').removeClass("themeoff");
    }
    
    );
    

    Hi friend, the code looks great.
    Can I post it on my site as well?
    And how can one know the path of subject assessments?
    I’m talking about this code: https://sudonix.com/post/1809

  • Hi friend, the code looks great.
    Can I post it on my site as well?
    And how can one know the path of subject assessments?
    I’m talking about this code: https://sudonix.com/post/1809

    @elhana-fine feel free. It’s posted here so that others can also make use of it.

  • @elhana-fine @phenomlab

    We have create this topic for reference.

    –> You will find all stuff to deploy it on your server.

    ENJOY

  • hi @phenomlab

    I use .category-item:first-of-type css properties for add a border-top on my principal pages like recent, unread etc…

    But this properties add a border too on topic header categories name.

    It’s possible to disable it just on topic (topic.header) ?

    83184b85-6629-4b93-8ef3-2bfb9b6d5631-image.png

  • hi @phenomlab

    I use .category-item:first-of-type css properties for add a border-top on my principal pages like recent, unread etc…

    But this properties add a border too on topic header categories name.

    It’s possible to disable it just on topic (topic.header) ?

    83184b85-6629-4b93-8ef3-2bfb9b6d5631-image.png

    @DownPW possibly with :not in the css class

    https://www.w3schools.com/cssref/sel_not.asp

  • @phenomlab

    I think I understand but I don’t find the good CSS class

    here the code for recent page for example :

    .category-item:first-of-type {
    	border-top: 1px solid #0a769978 !important;
        border-top-left-radius: 4px !important;
        border-top-right-radius: 4px !important;
    }
    

    and I will test this for disable border-top on topic page but don’t work:

    .category-item:first-of-type:not(.category-item .inline-block){
    	border-top: 0px solid #0a769978 !important;
    }
    

    here the html code :

    72ef18bb-21a0-4e8b-8890-9707cf1a51ca-image.png

  • @phenomlab

    I think I understand but I don’t find the good CSS class

    here the code for recent page for example :

    .category-item:first-of-type {
    	border-top: 1px solid #0a769978 !important;
        border-top-left-radius: 4px !important;
        border-top-right-radius: 4px !important;
    }
    

    and I will test this for disable border-top on topic page but don’t work:

    .category-item:first-of-type:not(.category-item .inline-block){
    	border-top: 0px solid #0a769978 !important;
    }
    

    here the html code :

    72ef18bb-21a0-4e8b-8890-9707cf1a51ca-image.png

    @DownPW sorry for late reply. Can you provide me with a url where this issue exists ? PM is fine of course if you don’t want to publish directly here.

  • @phenomlab

    I think I understand but I don’t find the good CSS class

    here the code for recent page for example :

    .category-item:first-of-type {
    	border-top: 1px solid #0a769978 !important;
        border-top-left-radius: 4px !important;
        border-top-right-radius: 4px !important;
    }
    

    and I will test this for disable border-top on topic page but don’t work:

    .category-item:first-of-type:not(.category-item .inline-block){
    	border-top: 0px solid #0a769978 !important;
    }
    

    here the html code :

    72ef18bb-21a0-4e8b-8890-9707cf1a51ca-image.png

    @DownPW A couple of things here. You are using the !important argument twice - one will override the other, meaning they can’t both be set like that - typically, the last marked so will be preferred. Would this not work better ?

    .category-item.inline-block {
        border-top: none !important;
    }
    
    .category-item:first-of-type {
        border-top: 1px solid #0a769978;
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;
    }
    
  • Thanks Mark

    I will test that tomorrow and I will tell you if is good or not !

    – Other bug i have to resolve my friend :

    • When I have plenty of tag on Post, have this :

    How to add a top space beetween the tag for a better lisibility ?

    Thanks in advance @phenomlab

  • Thanks Mark

    I will test that tomorrow and I will tell you if is good or not !

    – Other bug i have to resolve my friend :

    • When I have plenty of tag on Post, have this :

    How to add a top space beetween the tag for a better lisibility ?

    Thanks in advance @phenomlab

    @DownPW said in [NODEBB] Help for my custom CSS:

    – Other bug i have to resolve my friend :

    When I have plenty of tag on Post, have this :

    How to add a top space beetween the tag for a better lisibility ?
    Thanks in advance @phenomlab

    an idea for that @phenomlab ?

  • @DownPW said in [NODEBB] Help for my custom CSS:

    – Other bug i have to resolve my friend :

    When I have plenty of tag on Post, have this :

    How to add a top space beetween the tag for a better lisibility ?
    Thanks in advance @phenomlab

    an idea for that @phenomlab ?

    @DownPW I’ll check and get back to you.

  • @DownPW said in [NODEBB] Help for my custom CSS:

    – Other bug i have to resolve my friend :

    When I have plenty of tag on Post, have this :

    How to add a top space beetween the tag for a better lisibility ?
    Thanks in advance @phenomlab

    an idea for that @phenomlab ?

    @DownPW Try this

    .tag-list {
        display: inline-block;
        margin-top: 5px;
        line-height: 1.7;
    }
    

    Because you are using inline-block to float the elements on the same line, you cannot use margins to control the space. In this case, line-height will provide what you are looking for.

  • @phenomlab

    great

    line-height: 1.7;

    is very good 😉

  • Hello @phenomlab

    I have a odd littlebug only on Smartphone chrome based browsers (chrome, vivaldi, brave) only (it’s ok on firefox mobile)

    the right border of categories /topic is not visible

    Here a screenshot of the problem on chrome based browsers:

    11307bec-32cd-4855-be32-f7e98edcebc7-image.png

    And a good result on firefox mobile (it’s OK) :

    464d09c5-5531-458a-b6be-0444c66d44b0-image.png

    odd 😲

  • Hello @phenomlab

    I have a odd littlebug only on Smartphone chrome based browsers (chrome, vivaldi, brave) only (it’s ok on firefox mobile)

    the right border of categories /topic is not visible

    Here a screenshot of the problem on chrome based browsers:

    11307bec-32cd-4855-be32-f7e98edcebc7-image.png

    And a good result on firefox mobile (it’s OK) :

    464d09c5-5531-458a-b6be-0444c66d44b0-image.png

    odd 😲

    @DownPW odd indeed. Can you send me the CSS you are using for this ?


Did this solution help you?
Did you find the suggested solution useful? Support 💗 Sudonix with a coffee
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics
  • Custom Page - nodebb

    Solved Customisation custom-pages nodebb
    13
    2
    5 Votes
    13 Posts
    138 Views
    I’m happy to see this
  • Nodebb design

    Solved General nodebb
    2
    1 Votes
    2 Posts
    844 Views
    @Panda said in Nodebb design: One negative is not being so good for SEO as more Server side rendered forums, if web crawlers dont run the JS to read the forum. From recollection, Google and Bing have the capability to read and process JS, although it’s not in the same manner as a physical person will consume content on a page. It will be seen as plain text, but will be indexed. However, it’s important to note that Yandex and Baidu will not render JS, although seeing as Google has a 90% share of the content available on the web in terms of indexing, this isn’t something you’ll likely lose sleep over. @Panda said in Nodebb design: The “write api” is preferred for server-to-server interactions. This is mostly based around overall security - you won’t typically want a client machine changing database elements or altering data. This is why you have “client-side” which could be DOM manipulation etc, and “server-side” which performs more complex operations as it can communicate directly with the database whereas the client cannot (and if it can, then you have a serious security flaw). Reading from the API is perfectly acceptable on the client-side, but not being able to write. A paradigm here would be something like SNMP. This protocol exists as a UDP (UDP is very efficient, as it is “fire and forget” and does not wait for a response like TCP does) based service which reads performance data from a remote source, thus enabling an application to parse that data for use in a monitoring application. In all cases, SNMP access should be “RO” (Read Only) and not RW (Read Write). It is completely feasible to assume complete control over a firewall for example by having RW access to SNMP and then exposing it to the entire internet with a weak passphrase. You wouldn’t do it (at least, I hope you wouldn’t) and the same ethic applies to server-side rendering and the execution of commands.
  • How to downgrade plugin version on NodeBB

    Solved Customisation downgrade nodebb
    11
    3 Votes
    11 Posts
    2k Views
    @cagatay no problems
  • [NodeBB] Custom fields plugin

    Unsolved Customisation nodebb plugins javascript custom
    5
    0 Votes
    5 Posts
    2k Views
    @pwsincd hi. Just following up on this thread (I know it’s old) but was curious to understand if it’s still an issue or not ?
  • is "night mode" shifting the forum several pixels up?

    Solved Configure nodebb
    8
    4 Votes
    8 Posts
    1k Views
    @crazycells hmm. Good point. I actually use my own version of the dark mode plugin, so not entirely sure. However, I think the CSS is probably the same. I’m not at my PC currently but can check and advise later.
  • NodeBB 1.19.3

    Solved Performance nodebb 1.19.3 performance
    33
    4 Votes
    33 Posts
    9k Views
    @phenomlab I find the problem Mark The error message indicated this path : http://localhost:4567/assets/plugins/nodebb-plugin-emoji/emoji/styles.css?v=6983dobg16u I change the path url on config.json [image: 1645128773854-47bacc80-f141-41e4-a261-3f8d650cc6f6-image.png] And all it’s good Weird, I didn’t have to change that path before 1.19.3 But this does not prevent the problem from a clean install with Emoji Plugin EDIT: After test, that resolv the problem installation for 1.18.x but not for 1.19.x (I have other error message when I run ./nodebb Setup For resume: NodeJS 16_x with 1.18.x is ok
  • NodeBB Footer

    Solved Customisation footer nodebb
    10
    1 Votes
    10 Posts
    2k Views
    @phenomlab said in NodeBB Footer: @jac and you. Hope all is well and you recover quickly Thanks pal
  • [NODEBB] CSS Style Sheets SelectBox

    Locked Solved Customisation css
    112
    24 Votes
    112 Posts
    33k Views
    @DownPW as discussed in PM Seems to have been solved with the new JS code that you added allowing the version CSS file change!! Cache problem therefore with the JS of the Switcher theme Based on this, I will close this thread and reference https://sudonix.com/topic/207/nodebb-help-for-my-custom-css/27