Display in mobile device is not affected by changes to css but works fine in larger (laptop sized) viewport

I have a paste of the code as it is at this time: https://pastebin.com/DpaHEqb0
URL of the site is: www.nwavpros.com

I’m pretty new to all this and I realize I’m not using a perfect way of doing this; but, since its just the splash page for while the site is being built I wasn’t too concerned with how it is implemented as long as I get the basic right result. I can’t change where the line breaks are or the formatting really because its part of my client’s expectation to have it look like that. Only that it needs to be device friendly (ie: responsive) to fit any device size.

When I make changes to the code that targets my cell phone viewport size there is no effect. In fact, there is no effect no matter where I make changes to the css - no change on that device. I got the phone’s screen size from a website “what is my viewport size” and it reported 360px wide. This seems reasonable because it looks to be about that width when I look at the phone.

When I make changes to the media query that targets my laptop viewport size the changes take effect. But nothing I do can change the way it displays on the phone. What could be causing this?

I think you have a typo - I suspect for the smaller screen sizes you meant

font-size: 2.5em;

not 25em ! Your text was enormous and one had to scroll right down to see it.

1 Like

Welcome to the forums, @onlineventures1. smile

I don’t see a problem with the link you posted. The font size reduces at smaller screen widths, as per your media queries. (This is not necessarily a good idea, as small font sizes are harder to read on small screens, but it is what you wanted.)

I suggest that before you go much further, you educate your client that websites are not the same as print pages, and it is not possible or desirable to try to control layout rigidly. What if your visitor has poor eyesight and has set their default font several sizes larger than you have allowed for?

It is much more important that a page should be usable at any screen size than that the layout should look identical at any screen size. Most visitors will only use a single device anyway, and will neither know nor care what it looks like at other screen resolutions.

2 Likes

Another thought - your browser may be caching the CSS so not reflecting changes. Ctrl-F5 forces an external stylesheet to reload.

1 Like

Neither do I :slight_smile: The code seems different to that in the pastebin so seems a bit odd unless its been fixed by now.

You really want to start as you mean to go on and even though this is a splash page you don’t want to alienate search engines or people with accessibility issues at this early stage. You may find a page with multiple h1s being dropped in rankings by search engines and may be hard to claw back once the real site is active.

A screen reader (or bot) will read each h1 and try to make sense of it and a screen reader will pause at the end of each fragment and indeed will make little sense. They won’t join all the dots together and work out its one or two phrases.

I’d suggest you make the image an h1 as that contains the alt attribute text of the name of the site and is the most important thing on that page. The rest of the text is just a couple of paragraphs in p tags.

You can still break the words where you want (although this can be bad practice as @TechnoBear said above because the lines won’t always wrap at those points if a user has increase font-size). If you use spans to break the phrase into lines (rather than breaks or block level tags) then the meaning of the phrase is not diminished and screen readers won’t pause at every line break. Search engines will also get the correct phrase in one go rather than disparate fragments of text.

The beauty of using semantic html is that you get all this behaviour baked in for free :slight_smile:

I would suggest html roughly like this:

<div class="wrap">
  <h1 class="image-container">
    <img class="image" src="http://www.nwavpros.com//images/nwav_splash.png" title="NorthWest AV Professionals" alt="NorthWest AV Professionals splash page. Under construction.">
  </h1>
  <div class="text-container">
    <p class="text">
      <span>Thanks for stopping by. Our website is </span>
      <span> currently under construction.</span>
    </p>
    <p class="text">
      <span>For information, please send us </span>
      <span>an email to: </span>
      <span>NWAVPROS@gmail.com </span>
      <span>or call: </span>
      <span>Bob Jacobs - (509)768-6882 </span>
      <span>Bobby Pruitt - (509)570-4069 </span>
    </p>
  </div>
</div>

Then you can lose all your media queries and do something like this:

/* All devices */
html {
  box-sizing: border-box;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}
body {
  font-family: courier, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}
.wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 10px;
}
.image-container {
  margin: 0;
}
.image {
  display: block;
  width: 100%;
  height: auto;
}
.text-container {
  padding: 0 0 3rem;
  margin: auto 0;
  color: #666666;
}
.text {
  text-align: center;
  font-weight: bold;
  margin: 0;
  line-height: 1.4;
  color: #666;
  font-size: clamp(1rem, 2.2vw, 2rem);
}
.text span {
  display: block;
}

Or if you want telephone numbers aligned nicely then something like this:

If a job is worth doing it is always worth doing well. :slight_smile:

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.