• Resolved MRaines

    (@mraines)


    Hi again,
    I have tried my best to resolve a couple of issues relating to responsiveness.

    1.) I’ve customized my fonts on the Home Page Slider and the Page Headers. Can you help with how to maintain the responsiveness of these elements on tablet and mobile environments?

    2.) On the Services Box option on the home page, I would like to only have three boxes. I was able to do this and for mobile/tablet environments, I was able to make those three boxes responsive. However, doing that causes the elements (the three services boxes) to be off-center on a computer screen.

    On an unrelated item, is there a way to remove the navigation arrows on the Home Page Slider?

    Thank you advance for your help!
    M.

Viewing 15 replies - 1 through 15 (of 15 total)
  • When posting a question, please include a link to your site so it can be examined directly. Thanks.

    Thread Starter MRaines

    (@mraines)

    Okay…here you go:

    M.

    Can you help with how to maintain the responsiveness of these elements on tablet and mobile environments?

    The first thing you want to do is remove the inline style and add it to your child theme’s style.css file (or to the end of your custom CSS; I see you are using both). Inline styles are very difficult to modify using CSS, and to make the elements responsive, you’re going to want to use media queries in your CSS.

    For example, in the header image, you have this:

    <div class="slider-main">
       <div class="top-bar">
          <h2 style="font-size: 60px; color: #000000;"><strong>Silver Lining of Life</strong></h2>
          <h1 style="font-size: 30px;">Lubbock Counseling Services</h1>
          <h1 style="font-size: 30px;">Staci Rocha, M.A. LPC</h1>
       </div><!-- top-bar -->

    Remove the inline style that sets the font-size & color, then in your child theme’s style.css file, add this instead:

    .slider-main .top-bar h2 {
       font-size: 60px;
       color: #000000;
    }
    .slider-main .top-bar h1 {
       font-size: 30px;
    }

    Now we can add some media queries to change the font size at different view port widths:

    /* These rules are for tablets */
    @media only screen and (max-width: 768px) {
       .slider-main .top-bar h2 {
          font-size: 40px;
       }
       .slider-main .top-bar h1 {
          font-size: 25px;
       }
    } 
    
    /* These rules are for cell phones */
    @media only screen and (max-width:  350px) {
       .slider-main .top-bar h2 {
          font-size: 30px;
       }
       .slider-main .top-bar h1 {
          font-size: 20px;
       }
    }

    Note that the rules inside the media queries are the same as the original rules, except for the values of font-size (change the values as you prefer). The first media query kicks into affect once the width of the screen goes below 768px, the width of an iPad. You can see the media queries in action by adjusting the width of your desktop browser.

    For cell phones, I picked 350px. Some people use 320px, others use 480px. Cell phones, of course, come in many different widths, so pick a width that you are comfortable with. You can actually go pretty crazy & add queries depending upon whether the device is in landscape or portrait mode.

    The only thing you need to remember is that your media queries should go at the very end of your stylesheet, after the normal rules, so that the normal rules don’t override the media queries.

    However, doing that causes the elements (the three services boxes) to be off-center on a computer screen.

    For the service boxes, you should not assign them the same ID. Technically speaking, there should only be one unique ID per web page element. If you want to assign the same identifier to multiple elements, use a class, instead. So change services-box from an ID to a class, and then in your CSS rules, change #services-box to .services-box. I see that there are already rules for .services-box. Did you change the classes to IDs? Go ahead and change them back.

    In your CSS, you have a couple of problems:

    .services-box {
      max-width: 28%rem;
    }

    You can’t combine percent with rem. I assume you want percent, so remove the rem from this rule. Actually, remove this rule altogether, because we’re going to use a different one. Also, center is not a valid value for the float property.

    I see there are already a bunch of media queries which affect the service boxes. Let’s add some others to override some of those rules:

    .services .services-box {
       width: 32%;
       max-width: none;
       box-sizing: border-box;
    }
    .services .services-box img,
    .services .services-box h2
     {
      margin: 0 auto;
      display: table;
      font-size: 22px;
    }

    The first rule sets the width to be about a third of the container width, so they will automatically be “centered.” The second rule centers the images and headings within the service boxes. You’ll just need to add a media query so that the service boxes stack on top of one another at mobile screen widths so they don’t look squashed:

    @media only screen and (max-width:  768px) {
       .services .services-box {
          width: 100%;
       }
    }

    is there a way to remove the navigation arrows on the Home Page Slider?

    Add this CSS rule:

    .nivo-directionNav {
       display: none;
    }

    Thread Starter MRaines

    (@mraines)

    Thank you for the thorough information! I was able to resolve almost all of these issues. I am still having problems centering the Services boxes on the home page on a standard computer screen.

    When I change the code, it changes the boxes to a landscape kind of view and formats the content across the page. You can see that here:

    Can you tell me what I’ve done wrong.

    Thanks again!
    M.

    Read this paragraph from above:

    For the service boxes, you should not assign them the same ID. Technically speaking, there should only be one unique ID per web page element. If you want to assign the same identifier to multiple elements, use a class, instead. So change services-box from an ID to a class, and then in your CSS rules, change #services-box to .services-box. I see that there are already rules for .services-box. Did you change the classes to IDs? Go ahead and change them back.

    Thread Starter MRaines

    (@mraines)

    Okay, this is in territory that I’m not all together comfortable with…but I don’t believe I changed any classes to IDs. In the original functions.php file, I see under the section text and array that the content is specified as services-> class and id-> services-box. Is it as straightforward as changing the class here to services-box?

    Here’s the code I’m referencing:

    $section_text = array(
    		1 => array(
    			'section_title'		=> 'Our Services',
    			'menutitle'			=> 'services',
    			'bgcolor' 			=> '#ffffff',
    			'bgimage'			=> '',
    			'class'				=> 'services',
    			'content'			=> '<div id="services-box">
    				<img src="'.get_template_directory_uri().'/images/icon-web-design.png">

    That would be very strange if that is the code from the original functions.php. As I mentioned earlier, the coding standard is that there be only one element per web page which has the same ID. Anyway, try doing this: change the id in this line:

    'content'			=> '<div id="services-box">

    to a class:

    'content'			=> '<div class="services-box">

    Thread Starter MRaines

    (@mraines)

    My apologies the code I posted in my previous post was from the original index.php file. I changed the ‘content’ to a class in the child theme index file and made sure my style sheet was referencing the class. It still shows as before.

    Hmm, I’m still seeing an ID instead of a class when I inspect the page. So you changed the word id to class and not the word content.

    Thread Starter MRaines

    (@mraines)

    I did…
    Here’s the code from my index.php file in my child theme:

    $section_text = array(
    		1 => array(
    			'section_title'		=> 'Our Services',
    			'menutitle'			=> 'services',
    			'bgcolor' 			=> '#ffffff',
    			'bgimage'			=> '',
    			'class'				=> 'services',
    			'content'			=> '<div class="services-box">
    				<img src="'.get_template_directory_uri().'/images/icon-web-design.png">
    				<h2>Web <span>Design</span></h2>
    				<p>Lorem Ipsum is simply dummy text of they printing and typesetting industry. Lore Ipsum has been the industry standard in dummy text ever since the 1500s, when an unknown printer took a galley of type andin scrambled it to make a type book.</p>
    				<a href="#" class="read-more">Read More</a>
    				</div><div class="services-box">
    				<img src="'.get_template_directory_uri().'/images/icon-web-design.png">
    				<h2>Web <span>Development</span></h2>
    				<p>Lorem Ipsum is simply dummy text of they printing and typesetting industry. Lore Ipsum has been the industrys standard in dummy text ever since the 1500s, when an unknown printer took a galley of type andin scrambled it to make a type book.</p>
    				<a href="#" class="read-more">Read More</a>
    				</div><div class="services-box">
    				<img src="'.get_template_directory_uri().'/images/icon-web-design.png">
    				<h2>Mobile <span>Website</span></h2>
    				<p>Lorem Ipsum is simply dummy text of they printing and typesetting industry. Lore Ipsum has been the industrys standard in dummy text ever since the 1500s, when an unknown printer took a galley of type andin scrambled it to make a type book.</p>
    				<a href="#" class="read-more">Read More</a>
    				</div><div class="services-box">
    				<img src="'.get_template_directory_uri().'/images/icon-web-design.png">
    				<h2>WordPress <span>Themes</span></h2>
    				<p>Lorem Ipsum is simply dummy text of they printing and typesetting industry. Lore Ipsum has been the industrys standard in dummy text ever since the 1500s, when an unknown printer took a galley of type andin scrambled it to make a type book.</p>
    				<a href="#" class="read-more">Read More</a>
    				</div>',
    		),

    Rather than waste any more time on trying to make the site fit the “standard,” let’s just alter our CSS to use an ID instead of a class. In the CSS that I gave you, change .services-box to #services-box:

    .services #services-box {
       width: 32%;
       max-width: none;
       box-sizing: border-box;
    }
    .services #services-box img,
    .services #services-box h2
     {
      margin: 0 auto;
      display: table;
      font-size: 22px;
    }
    @media only screen and (max-width:  768px) {
       .services #services-box {
          width: 100%;
       }
    }

    Thread Starter MRaines

    (@mraines)

    It’s so close…this centered the boxes correctly on my home screen but now the boxes show up squished in a mobile environment. I even tried adding an additional media query with 350px set as the max-width.

    Remember this paragraph from above:

    The only thing you need to remember is that your media queries should go at the very end of your stylesheet, after the normal rules, so that the normal rules don’t override the media queries.

    I see that you placed your media queries at the end of your child theme’s style.css file, like I recommended above, but this rule is in your custom CSS:

    .services #services-box {
      width: 32%;
      max-width: none;
      box-sizing: border-box;
    }

    What’s happening is that the custom CSS rules are being read in after the child theme’s style.css file, so in essence, this rule is overriding the media query, which is why the width stays at 32%.

    So, you can either move the rules from the custom CSS into the style.css file, but above the media queries, or move the media queries from the end of the style.css file to the end of the custom CSS. Either way, the media queries will then end up after the normal rules.

    Thread Starter MRaines

    (@mraines)

    eeeeee—that worked! \o/

    Thank you so much for your time and help!

    Best,
    M.

    Thread Starter MRaines

    (@mraines)

    Marking this topic as resolved.

    Thanks again for the awesome support!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Issues with Responsiveness’ is closed to new replies.