HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

CSS Edit, have to use !important a lot

Greetings

I'm changing the Keystone theme some with CSS (Vanilla 3.3) I'm using the CSS Editor, but for a lot of elements especially when it comes to changing fonts and size I have to use !important.

I also tried making a copy of the Keystone theme and change the custom_default.css (I'm using default) and some other css files, but no changes had effect (I cleared the chache). Adding my own custom.css didn't had any effect either.

Not sure if i'm doing anything wrong? Or will I have to live with adding a lot of !important to the CSS?

Thanks in advance.

Comments

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    The css has a very high specificity. You can either duplicate that or use !important line you already do

  • Options
    ElleElle New
    edited April 2020

    Thanks. I'm unsure what you mean by duplicate it in this case sorry. This is what I did:

    As an example, here's the TitleWrap class as it looks by default

    So I wrote for example

    .TitleWrap, .Item {

    font-size: 20px;

    }

    Nothing will happen without !important, but it doesn't looks like I should need !important there? It's like something is already overriding what I see in the inspector tool. Also can't change the css file directly, nothing happens there either without !important so definitely feels like something is overriding it. I don't know if it gets minified, but can't find anything.

    Sorry for being stubborn 😅

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    By "duplicating" I meant that if you find ".Item.Read .Title", you should be able to override it with simply also (duplicating) ".Item.Read .Title".

    If that doesn't work, your css file is for some reasons processed before the official css is applied. Check your html source code and see in which order your css files appear. Your custom.css should certainly be the last file loaded. If not, please name the files that are loaded.

  • Options

    Thank you, that could be it. Where would I need to look to see this and specify the order? The closest thing to html source code I can see is 'default.master.tpl'. There's no css links there though like you had in those traditional .html files back in time. Same using the inspector tool, who I believe is using the 'default.master.tpl'. Perhaps I need to specify the the css links and order myself in this file?

  • Options

    Edit: i tried to add the css links to 'default.master.tpl'. I added the link to custom.css first and then custom_default.css (and other way around as well). I still have to use !important. Same with just adding a link to custom_default.css, that file also need !important too for changes to take effect.

    I'm really lost on which css file are overriding the other two.

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    You have to check the source code of the html page you are looking at in your browser.

    For this forum you would see it like that:

    <link rel="stylesheet" href="/static-asset/cl30011/applications/dashboard/design/style.css?v=3.0.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/applications/dashboard/design/style-compat.css?v=3.0.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/plugins/IndexPhotos/design/indexphotos.css?v=1.2.2.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/plugins/Warnings2/design/warnings.css?v=2.5.1.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/resources/design/vanillicon.css?v=4.0-2020.008.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/plugins/editor/design/editor.css?v=1.8.1.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/plugins/Reactions/design/reactions.css?v=1.4.6.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/plugins/AdvancedSearch/design/advanced-search.css?v=2.0.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/plugins/Signatures/design/signature.css?v=1.7.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/plugins/Polls/design/polls.css?v=1.2.4.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/applications/vanilla/design/tag.css?v=3.0.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/themes/open-vf-com/design/custom.css?v=1.0.0.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/plugins/Online/design/online.css?v=1.7.1.5ea97c64" media="all" static="1" />
    <link rel="stylesheet" href="/static-asset/cl30011/applications/vanilla/design/spoilers.css?v=3.0.5ea97c64" media="all" static="1" />
    <link rel="shortcut icon" href="https://us.v-cdn.net/5018160/uploads/favicon_94bbda47a17138f9.ico" type="image/x-icon" />
    <link rel="apple-touch-icon-precomposed" href="https://us.v-cdn.net/5018160/uploads/favicon-152-e7e8f794ea7f8ca15e3af1b6642ab048.png" />
    <link rel="canonical" href="https://open.vanillaforums.com/discussion/38135/css-edit-have-to-use-important-a-lot" />
    


    Based on your approach to customize the css, the order might not work as intended.

  • Options

    Oh thanks. It would help if I found my brain before doing anything further 😆

    It seems another stylesheet is in use indeed

    I'm not sure how to change this unless I should add them in a desired order in 'default.master.tpl?

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    I guess you have based your theme on keystone. In the addon.json file, keystone has the following lines:

       "options": {
           "Styles": {
               "Default": "%s_default",
               "Classic": "%s_classic",
               "Dark": "%s_dark",
               "Cerulean": "%s_cerulean",
               "Coral": "%s_coral",
               "Dusk": "%s_dusk"
           }
       },
    

    That way, the keystones css file is loaded first and after that the variation of the keystone css.


    Since you most probably do not want to have options at all, you should delete that options section in the addon.json file. But the info in that file is cached in /cache/theme/paranoid.php and so you have to delete that file after you have changed the addon.json file.

  • Options
    ElleElle New
    edited April 2020

    I did the things above, but the css is still being overrided and need !important to work.

    I also looked into style.css, but doesn't seem to be the one doing it.

    Not sure if this means anything:

    That folder is empty though. I'm not sure it only happens with typography related css yet. I've not added much css, mainly background colour which didn't needed !important. It was when I started to try to change font family, size and colours of fonts that I suddenly needed !important on all of those. I can't find anyone else having this issue when searching. I'm pretty sure I set up themes the way described on here, but when it comes to typography both the themes own css file and any custom css file is overrided.

    I also tried the boilerplate theme because I think it's meant to write your own css with it? It comes with a custom.css only. That one too is overrided.

  • Options

    I've solved it and it was rather embarassing 😅

    In the Inspector it looked like for example .TitleWrap, .Item was controlling the fonts family and size for a certain element which they do, but need !important. But different elements are needed and need all at once to not require !important: .DataList .Item.Read .Title, .DataList .Item .Title. I only tried with one or two at a time and it wouldn't work without !important then. With all listed the custom css overrides the other stylesheets.

Sign In or Register to comment.