Responsive Text Size Code

Options
Hi all,


I'm in the process of making my advocacy forms responsive and I just have one more hurdle! My header text is not scaling down in size when I shrink the window, so the text just gets cut off and too large/difficult to read once it gets down to a mobile format. Does anyone know a CSS trick I can use to correct this? Should I put a media query somewhere? What does that look like?


Thanks fo the help!


- Sydney
Tagged:

Comments

  • Generally, the CSS3 media query could look like the following (replace the XXX with your breakpoint screen width and feel free to modify the content within accordingly) -- that basically tells the browser that when the screen dimension is of that max-width pixel wise, then do whatever contains within.

    @media (max-width: XXXpx){
    h1,h2,h3,h4{

    font-size: 14pt

    }

    }


    If you are using Bootstrap, you can tap into their helper classes, i.e.


    <span style="color:rgb(0,102,153);">@media</span> <span>(</span><span>max-width</span><span style="color:rgb(85,85,85);">:</span> <span style="color:rgb(85,85,85);">@</span><span>screen-xs-max</span><span>)</span> <span>{</span> <span style="color:rgb(0,170,136);">...</span> <span>}<br/><br/>more on that -- </span>
    http://getbootstrap.com/css/

    Sydney Moyer:

    Hi all,


    I'm in the process of making my advocacy forms responsive and I just have one more hurdle! My header text is not scaling down in size when I shrink the window, so the text just gets cut off and too large/difficult to read once it gets down to a mobile format. Does anyone know a CSS trick I can use to correct this? Should I put a media query somewhere? What does that look like?


    Thanks fo the help!


    - Sydney

  • Erik Leaver
    Erik Leaver Blackbaud Employee
    Ancient Membership 250 Likes 100 Comments Photogenic

    Sydney Moyer:

    Hi all,


    I'm in the process of making my advocacy forms responsive and I just have one more hurdle! My header text is not scaling down in size when I shrink the window, so the text just gets cut off and too large/difficult to read once it gets down to a mobile format. Does anyone know a CSS trick I can use to correct this? Should I put a media query somewhere? What does that look like?


    Thanks fo the help!


    - Sydney

    Hi Sydney,


    Are you using the Lumiante Advocacy Responsive Wrapper Kit? It has a lot of the styles & media queries you'll need: https://community.blackbaud.com/reviews/item/36/1323


    Cheers,

    Erik
  • Thanks Daniel!
    Forgive my lack of awareness on media queries, but do you know
    where I ought to put them? Should they just go under the class of
    the block of text I’m styling in the stylesheet? Or do they have
    their own special place in the code?

    Appreciate your
    help!

    -
    Sydney

  • Yes I actually
    did use the kit to set this up! I’m looking for a deeper level of
    customization though. Basically I added a background image to the
    header, and instead of using the logo as the visual in the header,
    I swapped it out for headline text (you can see it in a sample
    alert here:
    https://secure2.convio.net/clf/site/Advocacy?cmd=display&page=UserAction&id=519).
    The headline text is breaking at about 675px wide, however, because
    the font size won’t scale down. I’ve tried putting the media
    queries mentioned above in the stylesheet but they don’t seem to be
    working. Not sure what I’m doing wrong!

    -
    Sydney

  • Erik Leaver
    Erik Leaver Blackbaud Employee
    Ancient Membership 250 Likes 100 Comments Photogenic

    Sydney Moyer:

    Yes I actually did use the kit to set this up! I’m looking for a deeper level of customization though. Basically I added a background image to the header, and instead of using the logo as the visual in the header, I swapped it out for headline text (you can see it in a sample alert here: https://secure2.convio.net/clf/site/Advocacy?cmd=display&page=UserAction&id=519). The headline text is breaking at about 675px wide, however, because the font size won’t scale down. I’ve tried putting the media queries mentioned above in the stylesheet but they don’t seem to be working. Not sure what I’m doing wrong!

    - Sydney

    Hmm. The columns in the alert (the input fields & message) are supposed to move to a single column format (stacked) when the window gets resized smaller so there's something broken -- they aren't collapsing. You should test without your modifications & then start taking steps forward.


    All of the media queries are in the advocacy_responsive_css file. That's the place you should add in declarations for your title sizes.
  • Looks like you have your <style> embedded within the PageWrapper "Additional HTML tags for HEAD Element", and I did see some of media queries reference been made on the header, although they might be made incorrectly (i.e. line 385, the way you wrap the media queries inside of targetted class element .navbar-brand I think that's not correct (you have it the other way around, refer to below for correct one)

    view-source:https://secure2.convio.net/clf/site/Advocacy?cmd=display&page=UserAction&id=519


    you may want to paste this into the existing <style> tag

    @media (max-width: 699px){
    h1.navbar-brand {

    font-size: 5em;

    }

    }
    @media (max-width: 499px){
    h1.navbar-brand {

    font-size: 2.7em;

    }

    }



    The coloring is just to show how to wrap the CSS inside of the media queries

    You might want to make sure that there is no duplicate on the breakpoint, or better put this at the end of your style tag before the closing </style>


    regards,

    Daniel

    Sydney Moyer:

    Thanks Daniel! Forgive my lack of awareness on media queries, but do you know where I ought to put them? Should they just go under the class of the block of text I’m styling in the stylesheet? Or do they have their own special place in the code?

    Appreciate your help!

    - Sydney

    P.s.

    @Erik -- I don't think she' using the responsive stlye css, the file isn't included in hers, but either way, if it's just to resolve the header font-size, she could make do with just the barebones :)


    @Sydney --

    You would want to differentiate the class assignment of your h1.navbar-brand and that image link on the footer which uses the same class while they are actually differents element in nature, (one is an h1 and the other is <a> tag -- assign different class name for either of them, don't use the same, or else the CSS ruleset is going to conflict one another inadvertently)


    you need to clean up that invalid @media queries line within your .navbar-brand selector on your <style>

    like for example - line 186 (remove the highlighted red -- that's not valid CSS)

    .navbar-brand{

    float:none;

    margin:0 auto;

    height:auto;

    max-width:80%;

    font-size: 7em;

    font-weight: 900;

    color: #ffffff;

    font-family: Roboto, Arial, sans-serif;

    line-height: .8;

    text-transform: uppercase;

    text-align: center;

    align: center;


    /*REMOVE THIS*/
    @media (max-width: 675px){

    h1,h2,h3,h4{

    font-size: 14pt;

    font-weight: 50;

    }

    /*REMOVE THIS*/


    }


    Line 385

    /*REMOVE THIS*/

    .navbar-brand {

    @media (max-width: 767px){

    h1,h2,h3,h4{

    font-size: 14pt

    }

    }

    }

    /*REMOVE THIS*/


  • Daniel,


    Thank you so much, this worked!! The header text is now responsive. I'm so close to this being finished! My only issue now is that the responsive code is broken in the alert contact fields and messge. I'm not sure what's causing the problem – I uploaded using the kit again and encountered the same issue. Do you know what might be causing this problem?

    https://secure2.convio.net/clf/site/Advocacy?cmd=display&page=UserAction&id=519


    Again, thank you so much for your help, you are a lifesaver!!


    Best,

    Sydney

    Daniel Hartanto:

    Looks like you have your <style> embedded within the PageWrapper "Additional HTML tags for HEAD Element", and I did see some of media queries reference been made on the header, although they might be made incorrectly (i.e. line 385, the way you wrap the media queries inside of targetted class element .navbar-brand I think that's not correct (you have it the other way around, refer to below for correct one)

    view-source:https://secure2.convio.net/clf/site/Advocacy?cmd=display&page=UserAction&id=519


    you may want to paste this into the existing <style> tag

    @media (max-width: 699px){
    h1.navbar-brand {

    font-size: 5em;

    }

    }
    @media (max-width: 499px){
    h1.navbar-brand {

    font-size: 2.7em;

    }

    }



    The coloring is just to show how to wrap the CSS inside of the media queries

    You might want to make sure that there is no duplicate on the breakpoint, or better put this at the end of your style tag before the closing </style>


    regards,

    Daniel

    Sydney Moyer:

    Thanks Daniel! Forgive my lack of awareness on media queries, but do you know where I ought to put them? Should they just go under the class of the block of text I’m styling in the stylesheet? Or do they have their own special place in the code?

    Appreciate your help!

    - Sydney

    P.s.

    @Erik -- I don't think she' using the responsive stlye css, the file isn't included in hers, but either way, if it's just to resolve the header font-size, she could make do with just the barebones :)


    @Sydney --

    You would want to differentiate the class assignment of your h1.navbar-brand and that image link on the footer which uses the same class while they are actually differents element in nature, (one is an h1 and the other is <a> tag -- assign different class name for either of them, don't use the same, or else the CSS ruleset is going to conflict one another inadvertently)


    you need to clean up that invalid @media queries line within your .navbar-brand selector on your <style>

    like for example - line 186 (remove the highlighted red -- that's not valid CSS)

    .navbar-brand{

    float:none;

    margin:0 auto;

    height:auto;

    max-width:80%;

    font-size: 7em;

    font-weight: 900;

    color: #ffffff;

    font-family: Roboto, Arial, sans-serif;

    line-height: .8;

    text-transform: uppercase;

    text-align: center;

    align: center;


    /*REMOVE THIS*/
    @media (max-width: 675px){

    h1,h2,h3,h4{

    font-size: 14pt;

    font-weight: 50;

    }

    /*REMOVE THIS*/


    }


    Line 385

    /*REMOVE THIS*/

    .navbar-brand {

    @media (max-width: 767px){

    h1,h2,h3,h4{

    font-size: 14pt

    }

    }

    }

    /*REMOVE THIS*/


  • Hi Sydney,


    You are always welcome, and always glad to help.


    I might need further clarification / direction from you regarding that "broken alert contact fields and message", what do you mean by that? any screengrab, further description of the issue would probably be helpful in this case. Let us know.


    regards,

    Daniel

    Sydney Moyer:

    Daniel,


    Thank you so much, this worked!! The header text is now responsive. I'm so close to this being finished! My only issue now is that the responsive code is broken in the alert contact fields and messge. I'm not sure what's causing the problem – I uploaded using the kit again and encountered the same issue. Do you know what might be causing this problem?

    https://secure2.convio.net/clf/site/Advocacy?cmd=display&page=UserAction&id=519


    Again, thank you so much for your help, you are a lifesaver!!


    Best,

    Sydney

  • Thanks so much Daniel! A screenshot is below. Basically, the page is responsive, but the "Contact" Column with input fields should be stacking in a single-column format on top of the "Message" section, but they're instead stacking side-by-side, which makes the content hard to read on mobile. The original kit setup had these two elements stacking correctly, so I'm not sure what I've done in modifying the header and background that broke the responsiveness for these two sections below it. Thanks for any insight you may have!


    - Sydney


    be18badabb3e09555b2d8647eb11d9bc-huge-sc


  • Hi Sydney,


    No your modifying the header CSS shouldn't have anything to do with the mobile stacking. That mobile stacking of the 2 column is what Erik was referring to as it might seems that you have not really include all the CSS files that the kit might have come with (i.e. that advocacy_responsive_css.css file that seems to be missing/not included) from your wrapper last time I viewed whether that could be intentional since you want to write your own custom CSS or inadvertent.


    But regardless, you might not need that CSS file if what you intend to do is just to have them stack, you could just paste this following CSS that basically tells at 699px max screen width and below, remove the float and make sure those DIV fill out the width of the entire screen / parent wrapper -- you could paste this at the same inline style you already have just put them at bottom

    @media (max-width:699px){


    #action-alert #column1{

    float:none;

    clear:both;

    width:100% !important;

    }


    #action-alert #column2{

    float:none;

    clear:both;

    width:100% !important;

    }


    }



    With that, you now see the possibility of creating your own CSS overwrite (if coding is what you might have been thinking of doing in future) -- and this could be a good primer on the CSS portion of what we have been talking/discussing here

    https://www.w3schools.com/css/css_rwd_mediaqueries.asp


    regards,

    Daniel

    Sydney Moyer:

    Thanks so much Daniel! A screenshot is below. Basically, the page is responsive, but the "Contact" Column with input fields should be stacking in a single-column format on top of the "Message" section, but they're instead stacking side-by-side, which makes the content hard to read on mobile. The original kit setup had these two elements stacking correctly, so I'm not sure what I've done in modifying the header and background that broke the responsiveness for these two sections below it. Thanks for any insight you may have!


    - Sydney


    be18badabb3e09555b2d8647eb11d9bc-huge-sc


  • Daniel,


    That worked! Thank you so much for all your help in getting this up and running, it looks fantastic! And I'm learning a bit about media queries and responsive CSS. Appreciate all your help with this!


    Best,

    Sydney
  • Sidney, one thing that you need to correct on your CSS


    do not put that inside of another media queries


    (line 287 from view-source:https://secure2.convio.net/clf/site/Advocacy?cmd=display&page=UserAction&id=519)


    You are currently putting the entire @media (max-width:699px){...} inside of another @media (max-width:499px){..} that's wrong -- each of media queries should be on their own thus it's always important to check the closing of the @media curly bracket.


    Important -- You need to fix that otherwise, it might not behave correctly in some / most browsers.


    regards,

    Daniel


    EDIT:


    those should be

    @media (max-width: 499px){

    h1.navbar-brand {

    font-size: 2.7em;

    }
    }

    @media (max-width:699px){


    #action-alert #column1{

    float:none;

    clear:both;

    width:100% !important;

    }


    #action-alert #column2{

    float:none;

    clear:both;

    width:100% !important;

    }

    }

    OR if you want the entire thing to be stacking not at 699px width but at 499px width, then you don't need to include the @media (max-width:699px){ } rather, just copy paste the "content" of that originally 699px media queries to 499px media queries, so it looks like this:

    @media (max-width: 499px){
    h1.navbar-brand {
    font-size: 2.7em;
    }

    #action-alert #column1{

    float:none;
    clear:both;
    width:100% !important;
    }

    #action-alert #column2{
    float:none;
    clear:both;
    width:100% !important;
    }
    }

    Sydney Moyer:

    Daniel,


    That worked! Thank you so much for all your help in getting this up and running, it looks fantastic! And I'm learning a bit about media queries and responsive CSS. Appreciate all your help with this!


    Best,

    Sydney

  • Oh thank you! I'll fix that now. Thanks for your help!


    Daniel Hartanto:

    Sidney, one thing that you need to correct on your CSS


    do not put that inside of another media queries


    (line 287 from view-source:https://secure2.convio.net/clf/site/Advocacy?cmd=display&page=UserAction&id=519)


    You are currently putting the entire @media (max-width:699px){...} inside of another @media (max-width:499px){..} that's wrong -- each of media queries should be on their own thus it's always important to check the closing of the @media curly bracket.


    Important -- You need to fix that otherwise, it might not behave correctly in some / most browsers.


    regards,

    Daniel


    EDIT:


    those should be

    @media (max-width: 499px){

    h1.navbar-brand {

    font-size: 2.7em;

    }
    }

    @media (max-width:699px){


    #action-alert #column1{

    float:none;

    clear:both;

    width:100% !important;

    }


    #action-alert #column2{

    float:none;

    clear:both;

    width:100% !important;

    }

    }

    OR if you want the entire thing to be stacking not at 699px width but at 499px width, then you don't need to include the @media (max-width:699px){ } rather, just copy paste the "content" of that originally 699px media queries to 499px media queries, so it looks like this:

    @media (max-width: 499px){
    h1.navbar-brand {
    font-size: 2.7em;
    }

    #action-alert #column1{

    float:none;
    clear:both;
    width:100% !important;
    }

    #action-alert #column2{
    float:none;
    clear:both;
    width:100% !important;
    }
    }

    Sydney Moyer:

    Daniel,


    That worked! Thank you so much for all your help in getting this up and running, it looks fantastic! And I'm learning a bit about media queries and responsive CSS. Appreciate all your help with this!


    Best,

    Sydney

  • You are always welcome there ;) all looks good now

    Sydney Moyer:

    Oh thank you! I'll fix that now. Thanks for your help!

Categories