Skip to content

[NODEBB] Help for my custom CSS

Solved Customisation
237 5 79.9k 3
  • @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 ?

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

    @phenomlab

    .categories > li, .category > ul > li {
        border: 1px solid silver;
        border-radius: 4px;
        margin-top: 5px;
        background: black;
        opacity: 0.9;
    }
    
  • @phenomlab

    .categories > li, .category > ul > li {
        border: 1px solid silver;
        border-radius: 4px;
        margin-top: 5px;
        background: black;
        opacity: 0.9;
    }
    

    @DownPW change the silver for a hex value.

  • @DownPW change the silver for a hex value.

    @phenomlab Doesn’t work


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
  • Page control arrows for PWA

    Solved Customisation nodebb
    27
    25 Votes
    27 Posts
    8k Views
    @crazycells it is, yes - I think I’ll leave it as there is no specific PWA CSS classes I know of. Well, you could use something like the below, but this means multiple CSS files for different operating systems. /** * Determine the mobile operating system. * This function returns one of 'iOS', 'Android', 'Windows Phone', or 'unknown'. * * @returns {String} */ function getMobileOperatingSystem() { var userAgent = navigator.userAgent || navigator.vendor || window.opera; // Windows Phone must come first because its UA also contains "Android" if (/windows phone/i.test(userAgent)) { return "Windows Phone"; } if (/android/i.test(userAgent)) { return "Android"; } if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { return "iOS"; } return "unknown"; // return “Android” - one should either handle the unknown or fallback to a specific platform, let’s say Android } Once you’re in that rabbit hole, it’s impossible to get out of it.
  • The best css to customize our logo?

    Solved Customisation css
    2
    1 Votes
    2 Posts
    1k Views
    @Sala This should look better .sidenav .navbar-brand { padding-top: 0.5rem; padding-bottom: 0.5rem; } [image: 1669026666905-e5cec20e-be36-4ee8-9129-fd11ad4656ac-image.png] You can increase the top and bottom padding by increasing the values above.
  • Post Style View

    Solved Customisation post style sudonix nodebb
    67
    2
    18 Votes
    67 Posts
    16k Views
    @cagatay Just add margin-left on the element like @phenomlab said to you : topic [component="post/parent"] { margin-left: 10px; } [image: 1669191112290-aa08c62b-4223-4cba-8c0f-c73d50474c0d-image.png] Maybe @phenomlab have a better way
  • Blinking text Effect

    Customisation nodebb text effect css
    3
    5 Votes
    3 Posts
    953 Views
    @phenomlab I love it too @phenomlab said in Blinking text Effect: Has that “broken neon light” look that you see in films. It’s exactly that, kind of old neon signs of bar or pubs a bit cyberpunk too
  • [NODEBB] Stats

    Unsolved Customisation plugin stats script
    20
    1
    2 Votes
    20 Posts
    4k Views
    @phenomlab said in [NODEBB] Stats: @jac or I land up fixing it I wouldn’t put it past you
  • [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
  • NodeBB Design help

    Solved Customisation
    8
    3
    2 Votes
    8 Posts
    2k Views
    @riekmedia I’ve applied some new CSS to your site. Can you reload the page and try again ? For the record, this is what I added #footer { background: #2d343e; border-top: 4px solid #2d343e; font-size: 0.9em; margin-top: 70px; padding: 80px 0 0; position: relative; clear: both; bottom: 0; left: 0; right: 0; z-index: 1000; margin-left: -15px; margin-right: -338px; } The /categories page seems a bit messed up, so looking at that currently EDIT - issued some override CSS in the CATEGORIES widget <!--- CSS fix for overspill on /categories page - DO NOT DELETE --> <style> #footer { margin-right: -45px; } </style> That should resolve the /categories issue.
  • NodeBB customisation

    Locked Customisation
    332
    27 Votes
    332 Posts
    134k Views
    @jac Given your departure away from your previous project, I’m going to close this thread…