Buttons change font size to some non-specified












0














I have some buttons. Without CSS it saves font size of buttons when you click or hover the button. But if I apply CSS, it changes:



Without CSS



Without CSS



With CSS



With CSS



The font size changes (if I set not default size in FXML, the highest button has default font size) and it starts being smaller height (possible to see in 2nd gif)



CSS:



.button {
-fx-border-style: null;
-fx-background-radius: 0;

-fx-background-color: #560145;

-fx-font-family: "Open Sans", "Open Sans", "Open Sans", "Open Sans";
-fx-text-fill: white;
}

.button:hover {
-fx-background-color: #87016c;
-fx-text-fill: #e6e6e6;
}

.button:pressed {
-fx-background-color: #4d0036;
-fx-text-fill: #e6e6e6;
}


.button:disabled {
-fx-opacity: 0.4;
-fx-background-color: grey;
-fx-text-fill: black;
}


FXML



  <Button layoutX="342.0" layoutY="329.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="164.0" text="Button">
<font>
<Font size="6.0" />
</font>
</Button>


I don't do anything in java code with buttons! Only CSS and FXML font-size setting.



What's wrong? 😐










share|improve this question
























  • something wrong in the code you are not showing, maybe? Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
    – kleopatra
    Dec 26 at 13:26










  • you did read the referenced help page, didn't you ;) Then follow its suggestion!
    – kleopatra
    Dec 26 at 15:29










  • @kleopatra as I understand, it's fully right..
    – andrey 27
    Dec 26 at 16:00










  • but also include the code in your question itself. Not everyone can access external sites, and the links may break over time (from: stackoverflow.com/help/how-to-ask - concededly not from the other, thought it was there as well ;)
    – kleopatra
    Dec 26 at 16:25










  • @kleopatra Enough right now? That's all I do with the button.
    – andrey 27
    Dec 26 at 16:38
















0














I have some buttons. Without CSS it saves font size of buttons when you click or hover the button. But if I apply CSS, it changes:



Without CSS



Without CSS



With CSS



With CSS



The font size changes (if I set not default size in FXML, the highest button has default font size) and it starts being smaller height (possible to see in 2nd gif)



CSS:



.button {
-fx-border-style: null;
-fx-background-radius: 0;

-fx-background-color: #560145;

-fx-font-family: "Open Sans", "Open Sans", "Open Sans", "Open Sans";
-fx-text-fill: white;
}

.button:hover {
-fx-background-color: #87016c;
-fx-text-fill: #e6e6e6;
}

.button:pressed {
-fx-background-color: #4d0036;
-fx-text-fill: #e6e6e6;
}


.button:disabled {
-fx-opacity: 0.4;
-fx-background-color: grey;
-fx-text-fill: black;
}


FXML



  <Button layoutX="342.0" layoutY="329.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="164.0" text="Button">
<font>
<Font size="6.0" />
</font>
</Button>


I don't do anything in java code with buttons! Only CSS and FXML font-size setting.



What's wrong? 😐










share|improve this question
























  • something wrong in the code you are not showing, maybe? Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
    – kleopatra
    Dec 26 at 13:26










  • you did read the referenced help page, didn't you ;) Then follow its suggestion!
    – kleopatra
    Dec 26 at 15:29










  • @kleopatra as I understand, it's fully right..
    – andrey 27
    Dec 26 at 16:00










  • but also include the code in your question itself. Not everyone can access external sites, and the links may break over time (from: stackoverflow.com/help/how-to-ask - concededly not from the other, thought it was there as well ;)
    – kleopatra
    Dec 26 at 16:25










  • @kleopatra Enough right now? That's all I do with the button.
    – andrey 27
    Dec 26 at 16:38














0












0








0







I have some buttons. Without CSS it saves font size of buttons when you click or hover the button. But if I apply CSS, it changes:



Without CSS



Without CSS



With CSS



With CSS



The font size changes (if I set not default size in FXML, the highest button has default font size) and it starts being smaller height (possible to see in 2nd gif)



CSS:



.button {
-fx-border-style: null;
-fx-background-radius: 0;

-fx-background-color: #560145;

-fx-font-family: "Open Sans", "Open Sans", "Open Sans", "Open Sans";
-fx-text-fill: white;
}

.button:hover {
-fx-background-color: #87016c;
-fx-text-fill: #e6e6e6;
}

.button:pressed {
-fx-background-color: #4d0036;
-fx-text-fill: #e6e6e6;
}


.button:disabled {
-fx-opacity: 0.4;
-fx-background-color: grey;
-fx-text-fill: black;
}


FXML



  <Button layoutX="342.0" layoutY="329.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="164.0" text="Button">
<font>
<Font size="6.0" />
</font>
</Button>


I don't do anything in java code with buttons! Only CSS and FXML font-size setting.



What's wrong? 😐










share|improve this question















I have some buttons. Without CSS it saves font size of buttons when you click or hover the button. But if I apply CSS, it changes:



Without CSS



Without CSS



With CSS



With CSS



The font size changes (if I set not default size in FXML, the highest button has default font size) and it starts being smaller height (possible to see in 2nd gif)



CSS:



.button {
-fx-border-style: null;
-fx-background-radius: 0;

-fx-background-color: #560145;

-fx-font-family: "Open Sans", "Open Sans", "Open Sans", "Open Sans";
-fx-text-fill: white;
}

.button:hover {
-fx-background-color: #87016c;
-fx-text-fill: #e6e6e6;
}

.button:pressed {
-fx-background-color: #4d0036;
-fx-text-fill: #e6e6e6;
}


.button:disabled {
-fx-opacity: 0.4;
-fx-background-color: grey;
-fx-text-fill: black;
}


FXML



  <Button layoutX="342.0" layoutY="329.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="164.0" text="Button">
<font>
<Font size="6.0" />
</font>
</Button>


I don't do anything in java code with buttons! Only CSS and FXML font-size setting.



What's wrong? 😐







css javafx






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 26 at 17:48









fabian

50.4k115272




50.4k115272










asked Dec 26 at 12:41









andrey 27

85




85












  • something wrong in the code you are not showing, maybe? Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
    – kleopatra
    Dec 26 at 13:26










  • you did read the referenced help page, didn't you ;) Then follow its suggestion!
    – kleopatra
    Dec 26 at 15:29










  • @kleopatra as I understand, it's fully right..
    – andrey 27
    Dec 26 at 16:00










  • but also include the code in your question itself. Not everyone can access external sites, and the links may break over time (from: stackoverflow.com/help/how-to-ask - concededly not from the other, thought it was there as well ;)
    – kleopatra
    Dec 26 at 16:25










  • @kleopatra Enough right now? That's all I do with the button.
    – andrey 27
    Dec 26 at 16:38


















  • something wrong in the code you are not showing, maybe? Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
    – kleopatra
    Dec 26 at 13:26










  • you did read the referenced help page, didn't you ;) Then follow its suggestion!
    – kleopatra
    Dec 26 at 15:29










  • @kleopatra as I understand, it's fully right..
    – andrey 27
    Dec 26 at 16:00










  • but also include the code in your question itself. Not everyone can access external sites, and the links may break over time (from: stackoverflow.com/help/how-to-ask - concededly not from the other, thought it was there as well ;)
    – kleopatra
    Dec 26 at 16:25










  • @kleopatra Enough right now? That's all I do with the button.
    – andrey 27
    Dec 26 at 16:38
















something wrong in the code you are not showing, maybe? Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
– kleopatra
Dec 26 at 13:26




something wrong in the code you are not showing, maybe? Please provide a Minimal, Complete, and Verifiable example that demonstrates the problem.
– kleopatra
Dec 26 at 13:26












you did read the referenced help page, didn't you ;) Then follow its suggestion!
– kleopatra
Dec 26 at 15:29




you did read the referenced help page, didn't you ;) Then follow its suggestion!
– kleopatra
Dec 26 at 15:29












@kleopatra as I understand, it's fully right..
– andrey 27
Dec 26 at 16:00




@kleopatra as I understand, it's fully right..
– andrey 27
Dec 26 at 16:00












but also include the code in your question itself. Not everyone can access external sites, and the links may break over time (from: stackoverflow.com/help/how-to-ask - concededly not from the other, thought it was there as well ;)
– kleopatra
Dec 26 at 16:25




but also include the code in your question itself. Not everyone can access external sites, and the links may break over time (from: stackoverflow.com/help/how-to-ask - concededly not from the other, thought it was there as well ;)
– kleopatra
Dec 26 at 16:25












@kleopatra Enough right now? That's all I do with the button.
– andrey 27
Dec 26 at 16:38




@kleopatra Enough right now? That's all I do with the button.
– andrey 27
Dec 26 at 16:38












2 Answers
2






active

oldest

votes


















0














I'm not sure what exactly went wrong, but you shouldn't combine Button properties AND CSS to choose the font.



Defining both font family and font size in the CSS stylesheet should work fine. (-fx-font-family allows only for a single string though.)



.button {
-fx-border-style: null;
-fx-background-radius: 0.0;

-fx-background-color: #560145;
-fx-font-size: 6.0;
-fx-font-family: "Open Sans";
-fx-text-fill: white;
}

...


As an alternative use inline CSS to change the button's font size:



<Button layoutX="342.0" layoutY="329.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="164.0" text="Button" style="-fx-font-size: 6;"/>


and remove the -fx-font-size property from the CSS stylesheet.






share|improve this answer























  • Thanks. But it changes all the buttons to this font size, but I would like to set it using FXML for each button and let all buttons get other options (color, text-fill,...) from css, that's why I use css. Is it possible?
    – andrey 27
    Dec 26 at 17:58












  • And.. If I set font and font size in css, it still changes the height of the button... (like 2nd gif)
    – andrey 27
    Dec 26 at 18:04



















0














Changing height solver adding



-fx-background-insets: 0 0 0 0, 0, 1, 2;


in .button section.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53932263%2fbuttons-change-font-size-to-some-non-specified%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I'm not sure what exactly went wrong, but you shouldn't combine Button properties AND CSS to choose the font.



    Defining both font family and font size in the CSS stylesheet should work fine. (-fx-font-family allows only for a single string though.)



    .button {
    -fx-border-style: null;
    -fx-background-radius: 0.0;

    -fx-background-color: #560145;
    -fx-font-size: 6.0;
    -fx-font-family: "Open Sans";
    -fx-text-fill: white;
    }

    ...


    As an alternative use inline CSS to change the button's font size:



    <Button layoutX="342.0" layoutY="329.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="164.0" text="Button" style="-fx-font-size: 6;"/>


    and remove the -fx-font-size property from the CSS stylesheet.






    share|improve this answer























    • Thanks. But it changes all the buttons to this font size, but I would like to set it using FXML for each button and let all buttons get other options (color, text-fill,...) from css, that's why I use css. Is it possible?
      – andrey 27
      Dec 26 at 17:58












    • And.. If I set font and font size in css, it still changes the height of the button... (like 2nd gif)
      – andrey 27
      Dec 26 at 18:04
















    0














    I'm not sure what exactly went wrong, but you shouldn't combine Button properties AND CSS to choose the font.



    Defining both font family and font size in the CSS stylesheet should work fine. (-fx-font-family allows only for a single string though.)



    .button {
    -fx-border-style: null;
    -fx-background-radius: 0.0;

    -fx-background-color: #560145;
    -fx-font-size: 6.0;
    -fx-font-family: "Open Sans";
    -fx-text-fill: white;
    }

    ...


    As an alternative use inline CSS to change the button's font size:



    <Button layoutX="342.0" layoutY="329.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="164.0" text="Button" style="-fx-font-size: 6;"/>


    and remove the -fx-font-size property from the CSS stylesheet.






    share|improve this answer























    • Thanks. But it changes all the buttons to this font size, but I would like to set it using FXML for each button and let all buttons get other options (color, text-fill,...) from css, that's why I use css. Is it possible?
      – andrey 27
      Dec 26 at 17:58












    • And.. If I set font and font size in css, it still changes the height of the button... (like 2nd gif)
      – andrey 27
      Dec 26 at 18:04














    0












    0








    0






    I'm not sure what exactly went wrong, but you shouldn't combine Button properties AND CSS to choose the font.



    Defining both font family and font size in the CSS stylesheet should work fine. (-fx-font-family allows only for a single string though.)



    .button {
    -fx-border-style: null;
    -fx-background-radius: 0.0;

    -fx-background-color: #560145;
    -fx-font-size: 6.0;
    -fx-font-family: "Open Sans";
    -fx-text-fill: white;
    }

    ...


    As an alternative use inline CSS to change the button's font size:



    <Button layoutX="342.0" layoutY="329.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="164.0" text="Button" style="-fx-font-size: 6;"/>


    and remove the -fx-font-size property from the CSS stylesheet.






    share|improve this answer














    I'm not sure what exactly went wrong, but you shouldn't combine Button properties AND CSS to choose the font.



    Defining both font family and font size in the CSS stylesheet should work fine. (-fx-font-family allows only for a single string though.)



    .button {
    -fx-border-style: null;
    -fx-background-radius: 0.0;

    -fx-background-color: #560145;
    -fx-font-size: 6.0;
    -fx-font-family: "Open Sans";
    -fx-text-fill: white;
    }

    ...


    As an alternative use inline CSS to change the button's font size:



    <Button layoutX="342.0" layoutY="329.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="164.0" text="Button" style="-fx-font-size: 6;"/>


    and remove the -fx-font-size property from the CSS stylesheet.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 26 at 18:05

























    answered Dec 26 at 17:41









    fabian

    50.4k115272




    50.4k115272












    • Thanks. But it changes all the buttons to this font size, but I would like to set it using FXML for each button and let all buttons get other options (color, text-fill,...) from css, that's why I use css. Is it possible?
      – andrey 27
      Dec 26 at 17:58












    • And.. If I set font and font size in css, it still changes the height of the button... (like 2nd gif)
      – andrey 27
      Dec 26 at 18:04


















    • Thanks. But it changes all the buttons to this font size, but I would like to set it using FXML for each button and let all buttons get other options (color, text-fill,...) from css, that's why I use css. Is it possible?
      – andrey 27
      Dec 26 at 17:58












    • And.. If I set font and font size in css, it still changes the height of the button... (like 2nd gif)
      – andrey 27
      Dec 26 at 18:04
















    Thanks. But it changes all the buttons to this font size, but I would like to set it using FXML for each button and let all buttons get other options (color, text-fill,...) from css, that's why I use css. Is it possible?
    – andrey 27
    Dec 26 at 17:58






    Thanks. But it changes all the buttons to this font size, but I would like to set it using FXML for each button and let all buttons get other options (color, text-fill,...) from css, that's why I use css. Is it possible?
    – andrey 27
    Dec 26 at 17:58














    And.. If I set font and font size in css, it still changes the height of the button... (like 2nd gif)
    – andrey 27
    Dec 26 at 18:04




    And.. If I set font and font size in css, it still changes the height of the button... (like 2nd gif)
    – andrey 27
    Dec 26 at 18:04













    0














    Changing height solver adding



    -fx-background-insets: 0 0 0 0, 0, 1, 2;


    in .button section.






    share|improve this answer


























      0














      Changing height solver adding



      -fx-background-insets: 0 0 0 0, 0, 1, 2;


      in .button section.






      share|improve this answer
























        0












        0








        0






        Changing height solver adding



        -fx-background-insets: 0 0 0 0, 0, 1, 2;


        in .button section.






        share|improve this answer












        Changing height solver adding



        -fx-background-insets: 0 0 0 0, 0, 1, 2;


        in .button section.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        andrey 27

        85




        85






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53932263%2fbuttons-change-font-size-to-some-non-specified%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Mossoró

            Error while reading .h5 file using the rhdf5 package in R

            Pushsharp Apns notification error: 'InvalidToken'