skip to Main Content

Column Alignment

columnDefs: [
    { targets: [1, 2], className: "cssMyRightAlign" },
],

CSS

.cssMyRightAlign{
    text-align: right;
}

But its not aligning column 1 & 2 in right.

Codepen Link
https://codepen.io/Sixthsense6/pen/KKeRPXJ

2

Answers


  1. Chosen as BEST ANSWER

    Finally traced the root cause of the issue.

    I stored the JavaScript in separate file and linked it in my Web Page. If I keep the JS in webpage itself then it's working fine.

    Storing the Js in separate file and linking the same in webpage header or body is not working as expected.


  2. Looks like .cssMyRightAlign is overwritten by a selector with higher precedence. Try adding the !important keyword to it like so:

    .cssMyRightAlign{
        text-align: right !important;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search