I can't figure out where there's an error in the following CSS:
#media all and (min-width: 570px) and (max-width: 970px) {
.contain {
padding: 0 0 0;
}
.two {
display: none;
width: 0;
margin-right: 0;
}
.two .tube {
padding: 0 0 0;
}
nav#primary .contain {
padding: 0 240px 0 0;
margin: 0 auto;
}
nav#primary .contain .two {
display: inherit;
width: 240px;
margin-right: -240px;
}
}
/*
* Keep headers in proportion
*/
#media all and (min-width: 971px) and (max-width: 1060) {
header#mast h1 {
font-size: 3.2em;
}
}
The first #media query works, the second #media block is ignored. The W3C CSS Validator complaints that "only 0 can be a length. You must put a unit after your number ) { header#mast h1 { font-size: 1em; } }".
Am I missing something really obvious?
Where is the HTML ?
Well... Here is a version of what you wrote without all of the unnecessary or redundant parts. But I can't test it without the HTML.
#media (min-width: 570px) { /* =========START=== */
.contain {
padding: 0;
}
.two {
display: none;
width: 0;
margin-right: 0;
}
.two .tube {
padding: 0;
}
.primary .contain {
padding: 0 240px 0 0;
margin: 0 auto;
}
.primary .contain .two {
width: 240px;
margin-right: -240px;
}
} /* =====================================END=== */
#media (min-width: 971px) { /* =========START=== */
.mast h1 {
font-size: 3.2em;
}
} /* =====================================END=== */
Related
My page has a white space on the right side when using margins and padding in the mobile view.
My page:
https://www.blazor.nl/uploads/get/a83c2617117c88b0/IMG-0002
My CSS:
.page-wrapper .page-container {
margin: 0;
padding: 0;
position: relative; }
.page-wrapper .page-container .content-wrapper {
margin: 0 50px 0 50px;
min-height: 600px;
position: relative;
top: -120px; }
.page-wrapper .page-container .content-wrapper .maincontent {
padding: 30px; } }
#media only screen and (min-width: 768px) and (max-width: 992px) {
.page-wrapper .page-container .content-wrapper .maincontent {
padding: 20px; } }
.page-wrapper .page-container {
margin: 0;
padding: 0;
position: relative; }
.page-wrapper .page-container .content-wrapper > h2 {
color: #ffffff;
margin: 0 0 10px;
font-weight: 300; }
#media (max-width: 767px) {
.page-wrapper .page-container .content-wrapper > h2 {
color: #696969;
font-size: 24px; } }
#media (max-width: 992px) {
.page-wrapper .page-container .content-wrapper {
margin: 30px 30px 0 150px; } }
#media (max-width: 767px) {
.page-wrapper .page-container .content-wrapper {
margin: 15px; } }
I am using a snippet which can be found here: https://bootsnipp.com/snippets/dexRM. I also use Bootstrap 3.
Thanks
How we can change background color of google ads info button from css. We have customized the ad but we cannot change background color of google ad info button. I have seen some native ads that have changed the color, even thoug I delete add every part of the code it doesn't go anywhere so how can I change background color of it? I have added the css code and picture
/* Note: 1px = 1dp in this css */
/* == Colors == */
body {
background-color: #ffffff;
}
.title-link {
color: #000000;
}
.button {
background-color: #9D0000;
}
.button-text,
.button-link {
color: #FFFFFF;
}
.price,
.reviews {
color: rgba(0,0,0,0.5);
}
.reviews svg {
fill: rgba(0,0,0,0.7);
}
.url-link {
color: rgba(0,0,0,0.3);
}
.body {
color: rgba(0,0,0,0.7);
}
/* == Fonts == */
body {
font-family: "Lobster";
font-weight: normal;
font-size: 10px;
}
#media (min-height: 300px) {
body {
font-size: 11px;
}
}
#media (min-width: 360px) and (min-height: 300px) {
body {
font-size: 12px;
}
}
#media (min-width: 700px) and (min-height: 300px) {
body {
font-size: 16px;
}
}
.title {
font-size: 1.1em;
line-height: 1.2em;
}
.button {
font-size: 1.1em;
}
.body,
.price,
.reviews,
.url {
font-size: 1em;
line-height: 1.1em;
}
#media (min-width: 360px) and (min-height: 300px) {
.title {
font-size: 1.2em;
line-height: 1.25em;
}
.button {
font-size: 1.2em;
}
}
#media (min-width: 700px) and (min-height: 300px) {
.title {
font-size: 1.3em;
line-height: 1.35em;
}
.button {
font-size: 1.3em;
}
}
/* == Layout == */
.title {
margin-bottom: 5px;
padding: 5px 0 0 8px;
}
.body {
margin: 2px 8px;
}
.button {
position: absolute;
bottom: 8px;
left: 8px;
}
/* == App install and video ad layouts == */
.app-icon {
float: left;
margin: 0 8px 4px 8px;
padding: 0;
}
.image-gallery,
.video {
margin: 0 auto 8px auto;
}
/* == Content ad layout == */
.image {
margin: 0 auto 4px auto;
}
/* == Body == */
.body {
/* add more customizations here */
}
/* == App icon == */
.app-icon img {
height: 50px;
width: 50px;
border-radius: 20%;
}
#media (min-width: 360px) and (min-height: 300px) {
.app-icon img {
height: 70px;
width: 70px;
}
}
/* == Title == */
.title {
display: block;
text-align: left;
}
/* == Button == */
.button {
border: none;
border-radius: 20px;
box-shadow: 0 0 2px rgba(0,0,0,0.12), 0 2px 2px rgba(0,0,0,0.24);
}
.button-link {
display: block;
position: relative;
padding: 0 1em;
}
.button svg {
display: none;
}
.button {
width: 90%;
width: calc(100% - 16px);
height: 2.8em;
}
.button-text {
display: block;
line-height: 2.8em;
text-align: center;
}
#media (min-width: 700px) and (min-height: 300px) {
.button {
height: 2em;
}
.button-text {
line-height: 2em;
}
}
/**
* == Large image and video ==
* App install:
* Use .image-gallery selector
* Content:
* Use .image selector
* Video:
* Use .video selector
*/
.image-link,
.image img {
width: 100%;
height: 100%;
}
.image-gallery a,
.image a {
display: block;
line-height: 0;
}
.image-gallery,
.video,
.image {
width: 90%;
width: calc(100% - 16px);
}
.image-gallery,
.video {
height: 50%;
height: calc(100% - 11em);
}
.image {
height: 50%;
height: calc(100% - 10em);
}
#media (min-width: 700px) and (min-height: 300px) {
.image-gallery,
.video {
height: calc(100% - 8.5em);
}
.image {
height: calc(100% - 8em);
}
}
/* == Attribution == */
.attribution {
background-color: #ffffff;
border-radius: 2px;
color: #aeaeae;
display: table;
font-size: 10px;
line-height: 13px;
margin: 4px 8px;
padding: 0 3px;
position: absolute;
top: 0;
left: 0;
}
.rtl .attribution {
background-color: #ffffff;
left: auto;
right: 0;
}
/* == Other == */
.ads a {
text-decoration: none;
}
.ads, .ad {
/**
* DO NOT TOUCH OR REMOVE
* Will break image rendering
*/
height: 100%;
width: 100%;
padding: 0;
word-wrap: break-word;
}
.ad {
/* Padding for attribution */
padding-top: 23px;
height: calc(100% - 23px);
}
#DanielStorm found how to change it but now Admob does not allow it
I'm not really familiar with CSS but you can inspect the element and see that the id is abgbg and that its color is set to #cdcccc by default. I've changed it to orange(#FFA500) in the screenshot. I'm not sure how to express this in CSS, or if it is even possible, but this should point you in the right direction.
Edit:
After playing around with it for a miniute you can change the background color like so:
.abgbg {
fill: #FFFFFF !important;
}
ERRORS
#media only screen (min-width: 1021px) and (max-width: 1180px) {
.twee img {
margin-top: 3em;
}
.drie {
margin-top: 3em;
}
.audiovisual iframe {
width: 90%;
}
.cp img {
width: 75%;
height: 75%;
display: inline;
padding: 0;
}
}
#media only screen (min-width: 791px) and (max-width: 1020px) {
body {
background-image: url(IMG/Sam-open-copy-1020.jpg);
}
.twee img {
margin-top: 7em;
}
.drie {
margin-top: 7em;
}
.zes {
margin-top: 2em;
}
.audiovisual iframe {
width: 90%;
}
.kaart iframe {
width: 75%;
height: 75%;
padding: 0;
margin: 0;
padding-bottom: 2em;
}
.cp img {
width: 75%;
height: 75%;
display: inline;
padding: 0;
}
#totop {
right: 0;
}
}
So this is my code, my mediaqueries won't apply on my HTML.
When I validate I got these errors.(see the image ERRORS) But I can't find out what's wrong with it? I checked everything but probably I can't find it because I look over it or something....
Add an extra 'and' in your #media query:
#media only screen and (min-width: 1021px) and (max-width: 1180px) { ...
I have a media query written but it breaks at certain point, I am now trying to optimize the query to the following :
#media only screen and (max-width: 1366px) and (min-width: 1280px) {
}
#media only screen and (max-width: 1280px) and (min-width: 1024px) {
}
#media only screen and (max-width: 1024px) and (min-width: 768px) {
}
#media only screen and (max-width: 768px) and (min-width: 640px) {
}
#media only screen and (max-width: 640px) and (min-width: 320px) {
}
Here is the one which i am using now
#media only screen and (max-width: 1366px) {
.menuTemplate3
{
margin-top: 3%;
}
.menuTemplate3 a
{
padding: 0 30px;
}
.wrap{
width:95%;
}
.span_of_2 {
padding: 3% 0;
margin: 4% 0;
}
.menu li {
margin: 6px 16px;
}
}
#media only screen and (max-width: 1280px) {
.menuTemplate3
{
margin-top: 3% !important;
}
.menuTemplate3 a
{
padding: 0 25px !important;
}
.wrap{
width:95%;
}
.menu li {
margin: 6px 12px;
}
.booking_room h4 {
font-size: 1.2em;
}
.booking_room p {
font-size: 0.8125em;
}
.f_nav li {
margin-left: 10px;
}
}
#media only screen and (max-width: 1024px) {
.menuTemplate3
{
margin-top: 3% !important;
}
.menuTemplate3 a
{
padding: 0 17px !important;
}
.wrap{
width:95%;
}
.menu li {
margin: 10px 8px;
}
.menu li a {
font-size: 0.8725em;
}
.reservation ul li.span1_of_3 {
width: 14.33333%;
margin-left: 15px;
}
.f_nav li a {
padding: 0 0px;
}
.grid1_of_3 {
float: left;
width: 100% !important;
margin-left: 0%;
}
}
#media only screen and (max-width: 768px) {
.menuTemplate3
{
margin-top: -3% !important;
}
.menuTemplate3 a
{
padding: 0 9px !important;
}
.wrap{
width:95%;
}
.row .grid_3 {
float: right;
width: 38.333333% !important;
}
.menu {
display: none;
}
.logo img
{ margin-left: -14% !important; }
.h_right {
width: 100%;
float: none;
}
.row {
width: 70% !important;
}
.top-nav {
display: block;
margin: 10px 0;
z-index: 999;
position: relative;
}
.nav a{
display: block;
}
.reservation ul li {
float: none;
display: inline-block;
}
.booking_room {
float: none;
width: 98%;
}
.reservation {
float: none;
width: 98%;
}
.b_room {
display: inline-block;
}
.grid1_of_3 h4 a {
font-size: 1.4em;
}
.copy {
float: none;
text-align:center;
}
.f_nav {
float: none;
text-align:center;
margin-top: 20px;
}
.soc_icons {
text-align: center;
margin: 20px 0;
}
.content {
float: none;
width: 100%;
margin-right: 0%;
}
.sidebar {
float: none;
width: 100%;
padding-left: 0%;
border-left: none;
}
.sidebar h4 {
margin: 4% 0 4%;
}
.sel_room {
float: none;
width: 100%;
}
.sel_room.left {
margin-left: 0%;
}
.service_list li {
width: 48.3333%;
margin-bottom:4%;
}
.service_list li:nth-child(3){
margin-left: 0;
}
.reservation h5 {
margin: 10px 0;
}
}
#media only screen and (max-width: 640px){
.menuTemplate3
{
margin-top: 3% !important;
}
.menuTemplate3 a
{
padding: 0 8px;
}
.wrap{
width:95%;
}
.logo{
width: 20%;
}
.h_right{
width:100%;
}
.row .grid_3 {
width: 70.333333% !important;
}
.reservation ul li.span1_of_1 {
width: 100%;
}
.row .grid_3 {
width: 70.333333% !important;
}
.book_date input[type="text"] {
width: 96% !important;
}
.reservation ul li.left {
margin-left: 0px;
}
.reservation ul li.span1_of_2 {
width: 49.33333%;
}
.reservation ul li.span1_of_3 {
width: 47.33333%;
margin-left: 10px;
}
.grid1_of_3 {
float: left;
width: 100%;
margin-left: 0%;
}
.grid1_of_3 h4 a {
margin: 2% 0;
}
.grid1_of_3 img{
margin-top:4%;
width: 10%;
}
.online_reservation {
margin-top: -30px;
}
.reservation ul li.span1_of_2 {
width: 48.33333%;
}
.res_btn form input[type="submit"] {
width: 50% !important;
padding: 10px;
}
.contact_left {
float: none;
margin-right: 0%;
width: 100%;
}
.contact_right {
float: none;
width: 100%;
}
.logo img{
margin-left: 0%;
margin-top: 2%;
}
}
#media only screen and (max-width: 530px) {
.menuTemplate3
{
margin-top: -11%;
width: 70%;
}
.menuTemplate3 a
{
padding: 0 15px;
}
.wrap{
width:95%;
}
.logo{
width: 32.333333%;
}
.h_right{
width:60.333333%;
}
.row .grid_3 {
width: 70.333333% !important;
}
.online_reservation {
margin-top: 0px;
}
.date_btn {
margin: 0 0 20px;
}
.logo img{
margin-left: 0%;
margin-top: 2%;
}
}
#media only screen and (max-width: 320px) {
.menuTemplate3
{
margin-top: -11%;
width: 70%;
}
.menuTemplate3 a
{
padding: 0 15px;
}
.wrap{
width:95%;
}
.logo{
width: 38.333333%;
}
.h_right{
width:60.333333%;
}
.row .grid_3 {
width: 70.333333% !important;
}
.reservation {
padding: 10px;
width: 97%;
}
.booking_room {
width: 97%;
padding: 10px;
}
.hide{
display: none;
}
.reservation ul li.span1_of_2 {
width: 100%;
}
.reservation ul li.span1_of_3 {
width: 100%;
margin-left: 0px;
}
.book_date input[type="text"] {
width: 93% !important;
}
.soc_icons ul li {
margin-left: 0px;
}
.grids_of_img {
float: none;
width: 100%;
}
.grids_of_para {
float: none;
width: 100%;
margin-left: 0%;
}
.span2_of_1 {
float: none;
width: 100%;
margin-left: 0%;
}
.res_btn form input[type="submit"] {
width: 60% !important;
padding: 10px;
}
.service_list li {
float:none;
margin-left:0;
width: 100%;
margin-bottom: 4%;
}
.contact-form input[type="text"], .contact-form textarea {
width: 93% !important;
}
.contact-form input[type="submit"] {
padding: 10px;
width: 50% !important;
}
.logo img{
margin-left: 0%;
margin-top: 2%;
}
}
Can anybody help me with the use the optimized media query? I am confused to place the classes.
you should use max-width and min-width both for media query like this is example
You'll want to use both min and max widths to optimize:
#media (min-width: 1281px) and (max-width: 1366px) {
}
#media (min-width: 1025px) and (max-width: 1280px) {
}
#media (min-width: 769px) and (max-width: 1024px) {
}
#media (min-width: 641px) and (max-width: 768px) {
}
#media (min-width: 321px) and (max-width: 640px){
}
#media (min-width: 1px) and (max-width: 320px) {
}
I'm wondering why some of my media queries are not overriding the native styles at the view port their being called. I'm trying to restyle a menu responsively, to stack, and have the navigation area's height longer in a WP theme. But every which way I add the specs I create to get this effect via editing Live CSS in Safari or FF inspect element - the styles I insert under the specific viewport I'm targeting are not being read. I know I'm using media queries correctly as it reads NEW styles, just doesn't override native? I'm missing something here? Here's what I'm trying to add that won't read.
#media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
#access li {
float: none; // To translate to not to float to the left stack
position: relative;
}
#access {
background: url("http://testsite.com/wp-content/uploads/2012/01/menu_bg.gif") repeat scroll 0 0 transparent;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
clear: both;
display: block;
float: left;
height: 240px; //Changed the height to allow stack
width: 100%;
}
Edit: Here's the FULL set of Responsive styles I'm calling, if matters.
/* =Responsive Structure
----------------------------------------------- */
#media (max-width: 800px) {
body {
padding: 0;
}
#page {
margin-top: 0; overflow: hidden;
}
#branding {
border-top: none;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
#socialpost { margin-left: -100px; }
p {font-size: 12px; }
#sublogo { display: none; }
#footcontain { padding-left: 0;}
#access a {
color: #000000;
display: block;
font-family: arial;
line-height: 3.11em;
padding: 0 20px;
text-decoration: none;
#access a { font-size: 12px; }
#access li {
float: left;
margin-left: -28px;
position: relative; }
}
#media (max-width: 650px) {
/* #media (max-width: 650px) Reduce font-sizes for better readability on smaller devices */
body {
padding: 0;
}
#page {
margin-top: 0;
}
#branding {
border-top: none;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
p {font-size: 12px; }
#sublogo { display: none; }
#access a {
color: #000000;
display: block;
font-family: arial;
line-height: 3.11em;
padding: 0 13px;
text-decoration: none;
font-size: 11px;}
#footcontain { padding-left: 0;}
#access a {
padding: 0 15px; }
}
#media (max-width: 450px) {
#content .gallery-columns-2 .gallery-item {
width: 45%;
padding-right: 4%;
}
#content .gallery-columns-2 .gallery-item img {
width: 100%;
height: auto;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
p {font-size: 10px; }
.entry-content, .entry-summary {
padding: 1.625em 0 0;
width: 48%; }
#footcontain { padding-left: 0;}
#branding #s {
-moz-transition-duration: 400ms;
-moz-transition-property: width, background;
-moz-transition-timing-function: ease;
float: right;
height: 35px;
width: 47px; }
.widget-title { margin-top: 35px; }
.flexslider .slides img {
border: 0 none;
display: block;
max-width: 100%;
padding-bottom: 25px; }
#footcontain { display:none;}
#access li {
float: none;
position: relative;
}
#access {
height: 70px;
}
#access a {
color: #000000;
display: block;
font-family: arial;
font-weight: bolder;
line-height: 3.11em;
padding: 0 10px;
text-decoration: none;
}
#access ul {
font-size: 10px;
list-style: none outside none;
margin: 0 0 0 -80px;
padding-left: 0;
}
.flex-control-nav { display: none; }
.flexslider {
margin: 0 0 67px; }
.flex-caption { display: none; } //Could Display this here, need to make take half of slider
}
#media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
body { padding: 0; }
#access {
height: 70px;
}
#page {
margin-top: 0; overflow: hidden;
}
#branding {
border-top: none;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
p {font-size: 10px; }
#sublogo { display: none; }
#access a { padding: 0 10px; }
#access li {
float: none;
position: relative;
}
.entry-content, .entry-summary {
padding: 1.625em 0 0;
width: 35%; }
#footcontain { display: none; }
#branding #s {
-moz-transition-duration: 400ms;
-moz-transition-property: width, background;
-moz-transition-timing-function: ease;
float: right;
height: 35px;
width: 47px; }
#footcontain { display: none; }
.widget-title { margin-top: 35px; } //Attempt to Create Space for Slider Page Nation
#access { height: 70px; }
#access li {
float: none;
position: relative;
}
.flex-control-nav { display: none; }
.flex-caption { display: none; } //Could Display this here, need to make take half of slider, check
.flexslider {
margin: 0 0 67px; }
}
The CSS code from your post is not working because it's a device-specific style and you are viewing it on a Safari, Chrome or Firefox using a laptop/desktop. You are forgetting that Media Queries are giving you the possibility to apply different styles when a page is being displayed in a 'browser' - resized to 480px and on an iPhone (which has a max-device-width of 480px).
Example CSS:
/* max-width */
#media screen and (max-width: 480px) {
.one {
background: #F9C;
}
}
/* min-width & max-width */
#media screen and (min-width: 480px) and (max-width: 900px) {
.two {
background: #9CF;
}
}
/* min-width */
#media screen and (min-width: 900px) {
.three {
background: #F90;
}
}
/* iphone specific css */
#media screen and (max-device-width: 480px) {
.iphone {
background: #ccc;
}
}
In the example above you can target both and still have a separate style for your device of choice. If you want to test it in a browser just use the min-width or max-width properties.
Hope this helps.
On the top example there's a missing closing bracket.
#media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
#access li {
float: none; // To translate to not to float to the left stack
position: relative;
}
#access {
background: url("http://testsite.com/wp-content/uploads/2012/01/menu_bg.gif") repeat scroll 0 0 transparent;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
clear: both;
display: block;
float: left;
height: 240px; //Changed the height to allow stack
width: 100%;
}
}