I’ve made the stylesheet below for my website, developing with desktop in mind, specifying a font-size for the body element and doing everything else relative to that (using em). Now I’d like to be able to set a larger font-size for when the website is viewed on a mobile phone, so I’ve added a simple media query. My flow to try testing is:
- delete browsing data in my browser (Chrome)
- start the local server, with homepage open in browser, with width > 600px
- confirm with inspect that body text uses font-size 16px, coming from style.css
- resize screen width to <600px, and reload the browser window (in case it’s needed)
Result: this body text still uses font-size 16px, coming from style.css, rather than 20px, as I have in my little media query.
Can anyone spot what I have wrong in my media query, my stylesheet, or my work flow? Thanks in advance for any ideas!
:root {
--link-color: #99CC66;
--header-color: #666869;
--header-hover: #131213;
}
.navbar li{
display: inline-block;
vertical-align: text-top;
margin-left: 15px;
margin-right: 15px;
list-style-type:none;
font-size: 1.25em;
}
.navbar a {
color: var(--header-color) !important;
}
.navbar a:hover {
color: var(--header-hover) !important;
text-decoration: none;
}
.navbar-brand {
font-size: 1em;
}
body {
font-size: 16px;
}
p { font-size: 1em;
text-indent: 1em}
.circled_section {
border-radius: 25px;
border: 5px solid var(--link-color);
padding: 15px;
margin-top: 10px;
margin-bottom: 10px;
}
.one_branch_display {
margin: 30px;
width: 35%;
}
.two_branch_display {
margin: 20px;
width: 35%;
}
.four_branch_display {
margin: 5px;
width: 23%;
}
.container {
margin-right: auto;
margin-left: auto;
padding-left: 15px;
padding-right: 15px;
max-width: 1320px !important;
}
.container:before,
.container:after {
content: " ";
display: table; }
.container:after {
clear: both; }
/* Increase the font size on mobile devices */
@media only screen and (max-width: 600px) {
body {
font-size: 20px;
}}
/* family generation display colors */
.g3 { font-size: 1em; text-decoration: underline; color: #8b8378; }
.g4 { font-size: 1em; text-decoration: underline; color: #FFCC66; }
.g5 { font-size: 1em; text-decoration: underline; color: #FF66CC; }
.g6 { font-size: 1em; text-decoration: underline; color: #99CC66; }
.g7 { font-size: 1em; text-decoration: underline; color: #000066; }
.g8 { font-size: 1em; text-decoration: underline; color: #663300; }
.g9 { font-size: 1em; text-decoration: underline; color: #8A5C8A; }
.g10 { font-size: 1em; text-decoration: underline; color: #75A3A3; }
.g11 { font-size: 1em; text-decoration: underline; color: #000000; }
.g12 { font-size: 1em; text-decoration: underline; color: #8A5C5C; }
.g13 { font-size: 1em; text-decoration: underline; color: #006699; }
.g14 { font-size: 1em; text-decoration: underline; color: #CC9933; }
.g15 { font-size: 1em; text-decoration: underline; color: #5C8A73; }
.g16 { font-size: 1em; text-decoration: underline; color: #CC99B3; }
/*Styles for image gallery hover text:*/
.image_container {
position: relative;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: var(--link-color);
}
.image_container:hover .overlay {
opacity: 1;
}
.text {
color: white;
font-size: 1em;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
3