Display category on mobile and date on browser
-
Hi there,
When you scroll through home on my website, it originally displayed the “date,” “category,” and “Leave a comment” on desktop. On mobile it only displayed the date and leave a comment.
It was very important to me that the category be visible on mobile so I added this to my CSS:
.cat-links {
display: inline-block !important;
}span.posted-on {
display: none;
}.cat-links::before {
display: none;
}Is there a CSS code I can add which would show category+leave a comment on mobile and show the date+category+leave a comment on desktop?
TIA!
The blog I need help with is: (visible only to logged in users)
-
Hello @glamsalad,
You are almost there, just use media queries to target mobile devices and move span.posted-on inside the media query, like this:/*CSS for devices below 1000px width*/
@media only screen and (max-width: 1000px) { span.posted-on { display: none; } }And also, remove this code:
.cat-links::before { display: none; }It is redundant.
Hope this helps 🙂
-
Hi, When I did what you wrote, the date was apparent on mobile as well as desktop.
I want date / category / leave a comment to appear on desktop and category / leave a comment to appear on mobile.
Would you be able to send me the complete CSS code to insert? I’ll remove the one I wrote originally.
Thanks!
-
@glamsalad okay do this, remove/comment out all your CSS code.
I mean remove these:
.cat-links { display: inline-block !important; } span.posted-on { display: none; } .cat-links::before { display: none; }This will undo all your changes so that the date, category and leave comment will be visible on all devices.
And then, use this to hide, just the date on devices below 1024px width(mobile devices), so that only category and leave a comment will be visible on mobile:
@media only screen and (max-width: 1024px) { .posted-on { display: none !important; } }Let us know if it helps 🙂
-
This code came out well on desktop but on mobile devices it took off both the date & category – leaves just the comment part.
How do I hide just the date on mobile devices?
-
Okay, that should not happen because
category is using the class cat-links and i used display: none; for just posted-onCan you tell me which page or post you are looking at when you apply that code? I am looking here: https://glamsalad.com/ which not contains only category and leave a comment text. Are you looking at the same page too?
If yes, then please add that code, save and leave it like that so that i can take a look at what’s happening and provide you with corrections(if there are any).
Thanks! 🙂
-
-
Okay, i checked your site and understood what you meant. So there’s this additional CSS code on your theme:
@media screen and (max-width: 600px) { .entry-meta > span:nth-child(3) { display: none; } }Which hides the category on devices with width below 600px. So to override that, add this CSS code:
@media screen and (max-width: 600px) { .cat-links { display: inline-block !important; } }This will display the category along with the leave a comment text on mobile devices
Hope this helps now 🙂
-
Almost perfect! Except on mobile it showed the category with a “/” before it. It looked like this:
/ in 101 / leave a comment
How do I remove that? It should just be on mobile
In 101 / Leave a Comment -
@glamsalad i see that you removed the date and also were able to remove the slash “/” before the categories.
Do you still need help with this?
-
Yes please, I would really like to display the date + category + comment on desktop and just the category & leave a comment on mobile without the slash before the category.
-
@glamsalad okay, can you please restore the codes with the codes i gave above so that i can provide you the correct CSS code to hide the slash?
-
I added these two and I’m not sure why it hasn’t updated, it shows date / category / comments on both mobile and desktop.
@media screen and (max-width: 600px) {
.cat-links {
display: inline-block !important;
}
}If I insert these two, it’s supposed to show everything on desktop and just category/comments on mobile?
@media only screen and (max-width: 1024px) {
.posted-on {
display: none !important;
}
}@media screen and (max-width: 600px) {
.cat-links {
display: inline-block !important;
}
} -
-
Okay… notice this code?
@media only screen and (max-width: 1024px) { .posted-on { display: none !important; } }Just add this to the above code:
.cat-links:before { display: none; }After adding this, your final code should look like this:
@media only screen and (max-width: 1024px) { .posted-on { display: none !important; } .cat-links:before { display: none; } }Hope this helps 🙂
-
@glamsalad It’s not because of this recent code, you removed the code i gave you long time back right?
@media screen and (max-width: 600px) { .cat-links { display: inline-block !important; } }This one? This caused the category to force display on mobile devices, remember?
Add this.
-
Ah, wonderful!! Yes, I added it and now it’s perfect.
Thank you so much @optidusprime, I really appreciate your help.
-
- The topic ‘Display category on mobile and date on browser’ is closed to new replies.