I am learning to develop wordpress theme and I found some strange and irritating problem.
on the desktop, everything is fine but when I opened it from mobile phone It gives different look.
I am attaching two screenshots of google chrome and Firefox output.
Where Firefox is giving decent look but google chrome is giving text bigger and does not sound good.
How can I fix the coding so that both could look same.
HERE IS THE CODE OF CSS
.home-2-article {
display: flex;
background-color: white;
box-shadow: 0 0 8px rgba($font-color, .5);
margin-bottom: 20px;
#media only screen and (max-device-width: 599px) {
display: flex;
flex-direction: column;
margin-bottom: 3rem;
}
& > * {
padding: .3rem;
}
&__thumbnail {
flex: 0 0 35%;
margin-right: 1rem;
#media only screen and (max-device-width: 599px) {
margin: 0;
}
img {
width: 100%;
height: auto;
}
}
&__wrapper {
&__title {
h2 {
font-size: 1.5em;
#media only screen and (max-device-width: 599px) {
font-size: 3em;
text-align: center;
}
}
}
&__meta {
display: flex;
#media only screen and (max-device-width: 599px) {
font-size: 1.7em;
justify-items: center;
justify-content: center
}
;
& > * {
padding: 0.5rem;
}
}
&__excerpt {
padding-bottom: .5rem;
p {
font-size: 1em;
#media only screen and (max-device-width: 599px) {
font-size: 2em;
padding: 0.3rem;
}
}
}
.home-2-article__rm {
a {
background-color: $primary-color-dark;
padding: 0.2rem .6rem;
color: white;
#media only screen and (max-device-width: 599px) and (max-width: 599px) {
font-size: 1.7em;
text-align: center;
display: block;
}
&:hover {
background-color: $primary-color;
transition: 1s all ease-in-out;
}
}
}
}
}
Related
I created this website and i have a problem with the mobile site. Which it does not fit to the content. How do i need to fix this? i have attached the css of the responsive below.
I have tried several codes. But it does not fit to the content. The website is smaller than the device. And making the width 100% did not work.
Thanks in Advance
#media only screen and (max-width: 600px) {
.content-area {
float: center;
width: 100%;
}
.social-navigation li a::before,
.sidebar-toggle {
font-size: 16px;
}
.sidebar-toggle {
height: 46px;
}
.site-title {
font-size: 32px !important;
}
}
#media only screen and (max-width: 500px) {
.content-area {
padding: 0;
width: 100%;
}
.container {
width: 100%;
}
.site-logo {
width: 50px;
text-align: left;
}
.site-title,
.entry-title {
padding-top:20px;
font-size: 18px !important;
}
.site-description {
margin-top: 0;
font-size: 16px !important;
}
}
Im very confused at the moment, so im trying to create a responsive website.
For some reason my media queries are not triggering? I have the below CSS and it works fine from X-Small Below 480px and up to 575.98px. but past the media query, anything that I add into the 767.98px range isnt working at all?
#media only screen and (min-width : 480px) {
.card-4{
display: none;
}
}
#media (max-width: 575.98px) {
#about{
padding: 0 0.5rem 0 0.5rem;
}
.about-photo img{
width: 70%;
}
.about-text{
margin: auto;
text-align: center;
padding: 1rem 0 3rem 0;
}
.about-text h1, .about-text p{
text-align: center;
float: none;
}
.table{
margin: 0;
padding-left: 0;
}
.table li{
margin: auto;
padding-top: 0.3rem;
padding-left: 2rem;
text-align: left;
}
#skills-list{
margin: 0 2rem 0 2rem;
}
#skills-list li{
text-align: left;
padding-bottom: 1rem;
}
.card-1{
display: none;
}
.card{
margin-left: auto !important;
margin-right: auto !important;
text-align: center;
}
.cards-container{
margin: 0 !important;
}
.timeline > li > .timeline-panel {
width: 85%;
float: right;
padding: 1.2rem;
}
.timeline:before {
left: 6%;
}
.timeline > li > .timeline-badge {
width: 44px;
height: 44px;
left: 6%;
}
.timeline > li > .timeline-panel:before {
border-left-width: 0;
border-right-width: 15px;
left: -15px;
right: auto;
}
.timeline > li > .timeline-panel:after {
border-left-width: 0;
border-right-width: 14px;
left: -14px;
right: auto;
}
.square-1-text, .square-2-text, .square-3-text{
height: 31rem;
}
.square-1{
order:1;
}
.square-1-text{
order:2;
}
.square-2{
order:3;
}
.square-2-text{
order:4;
}
#passions-section{
padding-bottom: 0;
}
#skills-list li.i{
list-style-position: outside !important;
display: none;
}
/*// Small devices (landscape phones, less than 768px)*/
#media (max-width: 767.98px) {
}
/*// Medium devices (tablets, less than 992px)*/
#media (max-width: 991.98px) {
}
/*// Large devices (desktops, less than 1200px)*/
#media (max-width: 1199.98px) {
}
Using the right breakpoints in your CSS media queries is likely the most important decision when implementing a fully responsive site.
Min-width: 320px (smaller phone viewpoints)
Min-width: 480px (small devices and most phones)
Min-width: 768px (most tablets)
Min-width: 992px (smaller desktop viewpoints)
Min-width: 1200px (large devices and wide screens)
In your case Try this one
#media (min-width:500px) and (max-width:750px)
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;
}
I have a div with display:none (mobile first approach):
#my_div {
display: none;
color: red;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
I use some media queries (after in the css) to display this div with some padding and font-size:
/* Between 600px and 649px */
#media (min-width: 600px) and (max-width: 649px) {
#my_div {
display: inline-block;
padding-top: 26px;
padding-left: 15px;
font-size: 18px;
}
}
/* Between 650px and 699px */
#media (min-width:650px) and (max-width:699px) {
#my_div {
display: inline-block;
padding-top: 24px;
padding-left: 20px;
font-size: 20px;
}
}
/* Between 700px and 914px */
#media (min-width: 700px) and (max-width: 914px) {
#my_div {
display: inline-block;
padding-top: 22px;
padding-left: 35px;
font-size: 22px;
}
}
All works well until 699px. The third media query is not applied and the div isn't displayed.
If I use the following media queries, the div is displayed, but #media (min-width: 700px) is not applied. The #media (min-width:650px) is applied:
#media (min-width: 600px) {
#my_div {
display: inline-block;
padding-top: 26px;
padding-left: 15px;
font-size: 18px;
}
}
#media (min-width:650px) {
#my_div {
display: inline-block;
padding-top: 24px;
padding-left: 20px;
font-size: 20px;
}
}
#media (min-width: 700px) {
#my_div {
display: inline-block;
padding-top: 22px;
padding-left: 35px;
font-size: 22px;
}
}
By using the chrome inspector I can see that over 700px it's applied the rule:
#my_div {
display: none;
...
}
EDIT
I have added one more media query
#my_div {
display: none;
color: red;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
#media (min-width: 600px) {
#my_div {
display: inline-block;
padding-top: 26px;
padding-left: 15px;
font-size: 18px;
}
}
#media (min-width:650px) {
#my_div {
display: inline-block;
padding-top: 24px;
padding-left: 20px;
font-size: 20px;
}
}
#media (min-width: 768px) {
#my_div {
display: none; /* it doesn't work, also with !important */
}
}
#media (min-width: 915px) {
#my_div {
display: inline-block;
padding-top: 22px;
padding-left: 35px;
font-size: 22px;
}
}
The only rule that is not applied is #media (min-width: 768px).
In my CSS, there aren't other rules that affect the display of my_div div. I'm using Bootstrap 3.
EDIT 2
I added the Bootstrap hidden-sm class to the div my_div:
<div id="my_div" class="hidden-sm"><strong>My slogan</strong></div>
In this way the div isn't displayed between 768px and 991px, but I would to display it again from 915px.
SOLUTION
I updated the JSfiddle by AngelosCharalis and, by copying and paste my code, I found an invisible dot character. Now it works.
First you must start from the highest pixel.
#media (max-width: 914px) {
#myId {
}
}
#media (max-width: 699px) {
#myId {
}
}
#media (max-width: 649px) {
#myId {
}
}
#media (max-width: 599px) {
#myId {
}
}
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%;
}
}