Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

responsive design flaw

Hello I have designed my very first website from scratch so I was expecting many problems. My first problem is the responsive design department. For some reason it works on the preview but now that I have uploaded it onto my domain it has messed it all up and is not using my media queries at all. It also replaces the font on my SVG icons which is weird since they are images. But only on mobile, on PC the website is 100% how I thought it would be. SO I am assuming I have completely stuffed up my media queries. Do not be surprised if you see some really creative and ridiculous coding. Please help me if possible! Thank you

Website: www.pixel9design.co.za

HTML:

<!doctype html>

<html>

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.5, maximum-scale=0.5, minimal-ui">

<link href="css/normalize.css" rel="stylesheet">

<link href="css/style.css" rel="stylesheet">

<link href="https://fonts.googleapis.com/css?family=Qwigley" rel="stylesheet" type="text/css">

<title>Pixel 9 Design | Graphic, Art & Website Design</title>

</head>

<body>

<header class="head section">

<nav>

<ul>

<h1 class="logomobile"> <img src="img/p9logo.svg" alt="logo"> </h1>


    <h1 class="logo"> Pixel 9 Design </h1>

        <li> <a href="index.html"> Home </a> </li>

        <li> <a href="contact.html"> Contact </a> </li>

        <li> <a href="gallery.html"> Gallery </a></li>

</ul>


</nav>

</header>

<h1 class="firsthead"> How can we assist you today? </h1>

<div class="wrapper">

<div>

<a href ="artpage.html">

<img src="img/paintbrush.svg"  class="hvr-pulse-shrink" alt="design">

</a>

</div>

<div>

<a href ="design.html">

<img src="img/computericon.svg"  class="hvr-pulse-shrink" alt="online">

</a>

</div>

<div>

<a href ="gallery.html">

<img src="img/othericon.svg"   class="hvr-pulse-shrink" alt="other">

</a>

</div>

</div>

<footer>

<p> &copy Pixel 9 Design </p>

</footer>

</body>

</html>

Media queries:

@media (max-width:960px) {

.logo {

width: 40%;

    font-size: 2.95em;

margin-top: 25px;

}

nav li {

list-style:none;

display: inline-block;

float: right;

margin-right: 5px;

margin-top: 20px;

color: white;

border: solid 1px white;

padding: 20px 0;

font-weight: 100;

}

.contact {

padding: 30px 0 30px 80px;

}

.firsthead {

font-size: 1.25em;

}

}

@media (max-width:600px) {

.logo {

    display:none;

}


.logomobile {

    width: 100px;

    height: 100px;  

    display:inline-flex;    

    margin-left: -230px;

    margin-top: 0;


}


.wrapper {

display: block;

}

.wrapper > div {

justify-content: center;

align-items: centre;

width: 100%; }

.wrapper img {

width: 90%;

margin-top: 0;

margin: -20px 0px;

}

footer{

position:fixed;

}

.designpar{

font-size: 0.825em;

}

.contact {

padding: 10%;

text-align:justify;

font-size: 0.825em;

}

.firsthead {

padding: 10px 10px;

}

}

@media (max-width:400px) {

.logomobile {


    margin-left: -280px;

    margin-top: 10px;

    width: 80px;

    height: 80px;


}


nav li {

list-style:none;

display: inline-block;

float: right;

margin-right: 5px;

margin-top: 20px;

color: white;

border: none;

padding: 20px 0;

font-weight: 100;

max-width: 80px;

}

.designpar {

font-size: 0.625em;

text-align: justify;

}

.designpar::first-letter {

float:left;

font-size:30px;

line-height: 1;

font-weight: 100;

margin-right: 2px;

}

.firsthead {

font-size: 1em;

}

footer {

position:fixed;

}

.inkart img{

max-width: 100%;

}

}

1 Answer

Hi Kathleen, which mobile phone you're using for testing? Internet Explorer 10 in Windows 8 or Windows Phone 8? These systems require extra code.

Beginning of your css

@-webkit-viewport   { width: device-width; }
@-moz-viewport      { width: device-width; }
@-ms-viewport       { width: device-width; }
@-o-viewport        { width: device-width; }
@viewport           { width: device-width; }

Just before closing body tag on all pages

<script>
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
  var msViewportStyle = document.createElement('style')
  msViewportStyle.appendChild(
    document.createTextNode(
      '@-ms-viewport{width:auto!important}'
    )
  )
  document.querySelector('head').appendChild(msViewportStyle)
}
</script>

I am using my iPhone - safari. Unfortunately the code you have given me to add in hasn't made a difference

Well if your code works on desktop, it sure should work on IOS as well if you're browsing exactly the same url. Those codes are not needed by IOS at all, mostly for Windows Phones.

Yes exactly so not sure why it is not working like it did when I tested the preview on dreamweaver but not when on the actual website url

Found the reason for this. Change your viewport meta tag to

<meta name="viewport" content="width=device-width, initial-scale=1">

Yes! thank you!