Skip to content

[NODEBB] Help for my custom CSS

Solved Customisation
237 5 79.9k 3
  • @cagatay said in [NODEBB] Help for my custom CSS:

    how can i add these new year icons to my home page as well?

    image.png

    JS:

    $(window).on('action:ajaxify.end', function(ev, data) {
        const snowMan = $('#snow-man');
        if (!snowMan.length && !ajaxify.data.template.chats) {
            $(`<img 
                src="https://www.freeiconspng.com/thumbs/snowman-png/snowman-png-29.png" 
                id="snow-man" 
                class="d-none d-lg-block position-fixed" style="z-index: 1054; bottom: -50px; right: -100px;"/>
            `).appendTo('body');
        } else {
            if (ajaxify.data.template.chats) {
                snowMan.remove();
            }
        }
    });
    

    CSS:

    // ------------------------------------------
    // Christmas styling 
    // ------------------------------------------
    /* Guirlande header */
    
    
    
    body {
      background-image: url("https://community.nodebb.org/assets/uploads/files/xmas-lights.png");
      background-repeat: repeat-x;
      background-position: top -22px left;
    }
    
    .container.px-md-4.brand-container {
        margin-top: 10px;
    }
    
    
    /*
    .skin-noskin #content {
        background: rgba(255, 255, 255, 0.9);
        margin-top: 1rem;
        border-radius: 5px;
    }*/
    
    /* end christmas styling */
    
    img#snow-man {
        width: 280px;
    }
    
    @media all and (max-width: 768px) {
    #snow-man {
        display: none;
      }
      .container.px-md-4.brand-container {
        margin-top: 15px !important;
        }
    }   
    
    div#console-nav-tab {
        z-index: 1000;
    }
    
  • thank you @DownPW

  • Hello @phenomlab

    I’d like to increase the size of the avatar image in the right sidebar without widening it, and center all the icons.

    I can’t find the right code.

    Any ideas?
    image.png

    .sidebar #user_dropdown .avatar {
        margin: 2px 0;
        width: 30px;
        height: 30px;
    }
    

    2f8847fb-7d2b-4794-834f-af459093d543-image.png

  • Hello @phenomlab

    I’d like to increase the size of the avatar image in the right sidebar without widening it, and center all the icons.

    I can’t find the right code.

    Any ideas?
    image.png

    .sidebar #user_dropdown .avatar {
        margin: 2px 0;
        width: 30px;
        height: 30px;
    }
    

    2f8847fb-7d2b-4794-834f-af459093d543-image.png

    @DownPW There isn’t any easy way to achieve this without using position: absolute on the img itself. Even then, you’d need to manually alter the position of the child icons in the same div (the sidebar). Whilst I do see the appeal, it’s not something I’d recommend doing to be honest.

  • @DownPW There isn’t any easy way to achieve this without using position: absolute on the img itself. Even then, you’d need to manually alter the position of the child icons in the same div (the sidebar). Whilst I do see the appeal, it’s not something I’d recommend doing to be honest.

    @phenomlab

    I succeeded in the following way by playing with the margins.

    .sidebar #user_dropdown .avatar {
        margin: 2px -7px;
        width: 35px;
        height: 35px;
    }
    

    Result is good :

  • I’d like to do the same thing with the website logo.

    For example, at Christmas time, I’d like to change my logo to something like a Santa hat, but it’s always cut off.

    I’ve tried adjusting the size and margins, and even modifying the logo’s pixels directly, but it doesn’t seem to work. It’s always cut off in the same way.

  • I’d like to do the same thing with the website logo.

    For example, at Christmas time, I’d like to change my logo to something like a Santa hat, but it’s always cut off.

    I’ve tried adjusting the size and margins, and even modifying the logo’s pixels directly, but it doesn’t seem to work. It’s always cut off in the same way.

    said in [NODEBB] Help for my custom CSS:

    I’d like to do the same thing with the website logo.

    For example, at Christmas time, I’d like to change my logo to something like a Santa hat, but it’s always cut off.

    I’ve tried adjusting the size and margins, and even modifying the logo’s pixels directly, but it doesn’t seem to work. It’s always cut off in the same way.

    @phenomlab ?

  • This post is deleted!
  • I just upgraded to the latest version to see if I could replicate this, which I can’t. Do you perhaps have overriding CSS?

  • resolve with :

    li[component=post] a[href*=“/groups/administrators”] {
    position: absolute !important;
    left: 2px;
    z-index: 2;
    margin-top: 1px;
    border-radius: 999px !important;
    line-height: 14px;
    display: block;
    margin-left: 6px !important;
    background: var(–bs-user-level-bg) !important;
    color: var(–bs-body-color-primary) !important;
    width: auto;
    }

  • resolve with :

    li[component=post] a[href*=“/groups/administrators”] {
    position: absolute !important;
    left: 2px;
    z-index: 2;
    margin-top: 1px;
    border-radius: 999px !important;
    line-height: 14px;
    display: block;
    margin-left: 6px !important;
    background: var(–bs-user-level-bg) !important;
    color: var(–bs-body-color-primary) !important;
    width: auto;
    }

    @DownPW great, but use position: absolute; carefully and sparingly

  • Hi,

    I’d like to enlarge the div so that the logo is fully displayed. Right now, for example, it’s cut off on the right at the glasses.

    8d7fea95-a138-42be-9ffd-12448b0b6fcd-image.jpeg

    an idea ?

  • if I set :

    • {
      overflow: visible !important;
      }
      it’s OK.

    I have not overflow: hidden in my custom css on acp…

    Maybe because Fancybox add an <a> no ?

    9780086b-1ca2-4b61-bf56-b4eb9e1c8871-image.jpeg

  • if I set :

    • {
      overflow: visible !important;
      }
      it’s OK.

    I have not overflow: hidden in my custom css on acp…

    Maybe because Fancybox add an <a> no ?

    9780086b-1ca2-4b61-bf56-b4eb9e1c8871-image.jpeg

    @DownPW strange. Fancybox doesn’t actually alter the image as far as I recall.

    Does it make a difference if you change the class name (in developer mode) from fancybox to say, fancybox1?

    If it works, then the class may have that defined already.

  • @baris said:

    You should change your selectors so it doesn’t look at the entire document. You probably only want to apply fancybox to stuff inside the #content element which is what changes when the user navigates around the page. So use $('#content a').... for your selectors then the forum logo in the header won’t be selected.

    I modified the JS Fancybox code now and this code and it seem better 🙂

    // ---------------------------------------------
    // Fancybox Media Reader (Without Website Logo)
    // ---------------------------------------------
    
    if (top.location.pathname !== '/login') {
        $(window).on('action:posts.loaded', function(data) {
            console.log("Polling DOM for lazyLoaded images to apply Fancybox");
            $(document).ready(function() {
                $('#content a').not('.forum-logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() {
                    $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate");
                });
            });
        });
    }
    
    if (top.location.pathname !== '/login') {
        $(document).ready(function() {
            $(window).on('action:ajaxify.end', function(data) {
                $('#content a').not('.logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() {
                    $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate");
                    data.preventDefault()
                    // Strip out the images contained inside blockquotes as this looks nasty :)
                    $('#content blockquote img').remove();
                });
                Fancybox.bind(
                    '#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]',
                    {
                        groupAll: true,
                    }
                );
            });
        });
    }
    
    // Chat fancybox - fires when chat module loaded and AJAX calls new chat
    $(document).ready(function() {
        $(window).on('action:chat.loaded', function(data) {
            // >>> Se limiter au contenu principal uniquement <<<
            $('#content img').not('.forum-logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() {
                var newHref = $(this).attr("src");
                $(this).wrap("<a class='fancybox' href='" + newHref + "'/>");
                $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate");
                data.preventDefault();
                // Strip out the images contained inside blockquotes as this looks nasty :)
                $('#content blockquote img').remove();
            });
            Fancybox.bind(
                '#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]',
                {
                    groupAll: true,
                }
            );
        });
    });
    

    For the logo, I must use overflow: visible !important; on [component="brand/logo"]

    /* --- Logo --- */
    [component="brand/logo"] {
      max-height: 50px;
      width: auto;
      height: auto;
      max-width: 100%;     
      display: block;
      object-fit: contain;  
      object-position: left center;
      overflow: visible !important;
    }
    

    Better result !!


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
  • Bug Report

    Solved Bugs nodebb bugs
    47
    1
    26 Votes
    47 Posts
    9k Views
    @crazycells Good points, thanks. I completely forgot that classes are added - makes life much simpler! EDIT - seems this is pretty straightforward, and only needs the below CSS .upvoted i { color: var(--bs-user-level) !important; } This then yields [image: 1718028529465-3f072f8a-ebfa-4910-8723-73c493b8e4eb-image.png] However, the caveat here is that the .upvoted class will only show for your upvotes, and nobody else’s. However, this does satisfy the original request however I would love to see my upvoted posts more clearly, because currently, when I upvote, nothing on the post tool is changing, it would be nicer if there is an indication that I have upvoted (like a filled or colored triangle?)
  • 15 Votes
    51 Posts
    11k Views
    Oh yes, that’s what’s super cool, I learn something every day. Afterwards I start from so low in JS
  • Custom html in nodebb to prevent cache

    Unsolved Configure nodebb
    18
    2 Votes
    18 Posts
    3k Views
    @Panda You’ll need to do that with js. With some quick CSS changes, it looks like this [image: 1690796279348-d619844f-fbfe-4cf1-a283-6b7364f6bf18-image.png] The colour choice is still really hard on the eye, but at least you can now read the text
  • 1 Votes
    1 Posts
    725 Views
    No one has replied
  • Title on homepage of nodebb forum

    Solved Customisation nodebb
    2
    1 Votes
    2 Posts
    1k Views
    @eveh Welcome board The code you are referring to is custom written as no such functionality exists under NodeBB. However, adding the functionality is relatively trivial. Below are the required steps Navigate to /admin/appearance/customise#custom-header Add the below code to your header, and save once completed <ol id="mainbanner" class="breadcrumb"><li id="addtext">Your Title Goes Here</li></ol> Navigate to /admin/appearance/customise#custom-js and add the below code, then save $(document).ready(function() { $(window).on('action:ajaxify.end', function(data) { // Initialise mainbanner ID, but hide it from view $('#mainbanner').hide(); var pathname = window.location.pathname; if (pathname === "/") { $("#addtext").text("Your Title"); $('#mainbanner').show(); } else {} // If we want to add a title to a sub page, uncomment the below and adjust accordingly //if (pathname === "/yourpath") { //$("#addtext").text("Your Title"); //$('#mainbanner').show(); //} }); }); Navigate to /admin/appearance/customise#custom-css and add the below CSS block .breadcrumb { right: 0; margin-right: auto; text-align: center; background: #0086c4; color: #ffffff; width: 100vw; position: relative; margin-left: -50vw; left: 50%; top: 50px; position: fixed; z-index: 1020; } Note, that you will need to adjust your CSS code to suit your own site / requirements.
  • [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 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.
  • Customising NodeBB

    Locked Customisation nodebb
    3
    0 Votes
    3 Posts
    2k Views
    Closing this thread as a duplicate of https://sudonix.com/topic/12/nodebb-customisation