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
Ana Camelo
Courses Plus Student 13,218 PointsMargin
Hi,
I'm finishing up a website and as I was writing down the media queries for smaller screens a margin appeared only in the nav. The only element before it is the logo image.
Does anyone know how can I clear the margins that I have not added to the nav. so it doesn't look horrible in smaller screens?
Thanks a lot!
4 Answers
Matt Campbell
9,767 PointsHi Ana Camelo
Check if there is a margin setting on the wider screen sizes. Remember that the CSS rules are kept unless overwritten in the media query. Get a link to the site up.
When posting code like that, what I suggest is grab the two areas that are relevant rather than all of it.
Richmond Lauman
28,793 PointsSeeing the style code you are using now would make it easier to help.
Ana Camelo
Courses Plus Student 13,218 Points/*Global*/
body {
font-family: 'Gudea', sans-serif;
color: #4b4b4b;
}
a {
color: #008baf;
text-decoration: none;
}
img, object {
max-width: 100%;
}
/*Typography*/
h1 {
color: #008baf;
font-size: 1.750em;
}
h2 {
color: #f6f6f6;
font-size: 1.25em;
font-weight: 400;
}
h3 {
color: #269db8;
font-size: 1.25em;
margin-top: 1.75em;
}
h4 {
color: #269db8;
font-size: 1em;
font-weight: 600;
line-height: 50%;
}
p {
line-height: 150%;
clear:both;
min-height: 25px;
}
.social {
color: #fff;
text-decoration: none;
}
.tinny {
color: #f2f2f2;
font-size: 1em;
line-height: 0.2em;
}
.thanks {
text-align: center;
font-size: 1.2em;
margin-top: 100px;
margin-bottom: 500px;
}
/*Navigation*/
.header .nav {
font-size: 1em;
margin: 1%;
list-style: none;
left: 15px;
}
.header .nav li {
display: inline-block;
margin: 0;
list-style: none;
}
.header .nav li a {
color: #f6f6f6;
text-decoration: none;
display: block;
line-height: 10px;
padding: 40px 0 0;
margin: 0 0 10px 10px;
}
.header .nav li a:hover, .header .nav li a:active {
color: #8dbbc6;
}
/*Forms*/
form {
margin-top: 5%;
}
table th {
padding-bottom: 2em;
padding-right: 1em;
}
table td {
width: 100%;
}
.btn-submit {
width: 100px;
float: left;
border: 0;
padding: 7px;
margin: 40px 0 20px 0;
color: #ffffff;
font-size: .75em;
background-color: #cacaca;
border-radius: 25px;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
}
label, input, textarea, span {
float: left;
}
label {
width: 100%%;
}
input[type=text], textarea {
width: 70%;
background-color: #e4e4e4;
border: 1px solid;
border-color: #bdbdbd;
color: #9d9d9d;
margin: 10px;
}
input, textarea {
padding: 1%;
border: 1 solid;
border-radius: 15px;
}
input:focus, textarea:focus {
outline: none;
border: 1px solid;
border-color: #8f8f8f;
}
textarea {
border-color: #bdbdbd;
height: 200px;
}
#form span {
margin-left: 30px;
color:#420600;
}
#form span.valid {
color: 199392;
}
#form span.error {
color: #e9282f;
}
#footer_form {
width: 200px;
padding: 5px 5px;
font-size: 1em;
color: #4b4b4b;
border-radius: 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
}
#email_2{
margin: 10px 0;
}
.btn-submit_2 {
width: 80px;
float: left;
margin: 1px 0;
border: 0;
padding: 7px 5px;
margin-top: 0px;
color: #ffffff;
font-size: .75em;
background-color: #b2b2b2;
border-radius: 25px;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
}
/*Slider*/
#slider {
width: 100%;
}
#slide_1 {
background-color: #fcb215;
max-width: 100%;
}
#slide_2 {
background-color: #f4801f;
max-width: 100%;
}
#slide_3 {
background-color: #f15b44;
max-width: 100%;
}
#slide_4 {
background-color: #f7931d;
max-width: 100%;
}
#slide_5 {
background-color: #199392;
max-width: 100%;
}
#slide_6 {
background-color: #4f3891;
max-width: 100%;
}
/*Images*/
#imgs_serv {
background-color:#ffffff;
text-align: center;
}
.gv, .ss, .gp {
background-color: #e6e7e8;
margin-bottom: 0;
max-width: 100%;
}
.gv img {
width: 90%;
vertical-align: middle;
padding: 18px 2px;
}
.gv img:hover {
content: url("../img/001_gestion_V02.png");
}
.gp img {
width: 90%;
vertical-align: middle;
padding: 18px 2px;
}
.gp img:hover {
content: url("../img/003_gestion_P02.png");
}
.ss img {
width: 90%;
vertical-align: middle;
padding: 18px 2px;
}
.ss img:hover {
content: url("../img/002_sistema_S02.png");
}
.gestion_procesos,
.sistema_scada,
.gestion_ventas {
margin-top: 20px;
margin-bottom: 40px;
max-width: 100%;
}
/*Header*/
.header:after {
content:"";
height:0;
display:block;
visibility:hidden;
clear:both;
}
.header {
background-color: #008baf;
}
.header .logo {
float: left;
margin: 15px 0;
font: 0/0 serif;
text-shadow: none;
color: transparent;
padding: 14px 0;
}
.header .logo a {
display: block;
max-width: 100%
}
.icon {
margin-right: 10px;
}
/*Footer*/
#foot {
background-color: #404041;
color: #dedede;
font-size: 0.75em;
margin-bottom: 0px;
margin-top: 0px;
}
#foot a {
color: #dedede;
}
#foot h1 {
color: #dedede;
font-size: 1.25em;
line-height: 10px;
}
#foot ul {
list-style: none;
margin: 10px 0 0 -20px;
}
#foot li {
line-height: 3em;
}
/*Internal Pages Images*/
.cont_img {
max-width: 50%;
margin-left:auto;
margin-right:auto;
margin-top: 15px;
margin-bottom: 10px;
}
.cont_img_2 {
max-width: 80%;
margin-left:auto;
margin-right:auto;
margin-top: 40px;
margin-bottom: 35px;
}
/* Media Queries ------------------------------------------------------------------- */
/* Medium ----------- */
@media screen and (max-width: 950px) {
.logo {
width: 100%;
text-align: center;
}
.logo img{
max-width: 40%;
margin: 0;
padding: 0px 0;
}
.header .nav {
clear: both !important;
text-align: center !important;
position: relative;
width: 100%;
margin-right: 0;
}
.header .nav ul {
width: 100%;
}
.header .nav li a {
padding: 0.5em 00;
}
.gv, .ss, .gp {
margin-top: 0;
}
}
@media screen and (max-width: 660px) {
.grid_1,
.grid_2,
.grid_3,
.grid_4,
.grid_5,
.grid_6,
.grid_7,
.grid_8,
.grid_9,
.grid_10,
.grid_11,
.grid_12 {
width: 100%;
}
.header .nav {
text-align: center;
position: relative;
width: 90%;
margin: 0;
margin-left: -1%;
}
.header .nav ul {
float: none !important;
width: 100%;
}
.header .nav li a {
padding: 0.5em 00;
}
#imgs_serv {
display: none;
}
#foot ul {
width: 100%;
text-align: center;
position: relative;
padding: 10px 5px 20px 5px;
}
#foot li {
display: inline-block;
margin: 0 15px;
font-size: 1.5em;
}
#foot form,
#foot p,
#foot h1 {
display: none;
}
.gestion_procesos,
.gestion_ventas,
.sistema_scada,
.cont_img_2 {
display: none;
}
}
James Barnett
39,199 PointsWhen posting this much code it's usually a good idea to make a working demo using codepen
Ana Camelo
Courses Plus Student 13,218 PointsWhoops! I'm sorry, I'm not sure how to use it. Can you pleas explain me? and then how do i link it to this post?
Thanks a lot!