CSS for module size (similar to #media)? - css

I have a Joomla Module that I'm trying to keep responsive for different screen sizes but displaying and hiding columns. This works well on full page displays.
#media (max-width: 800px) {
.team_name { display:none; }
.team_abbr { display:inline-block;}
.overall { display: inline-block;}
.divisional { display:inline-block;}
.wide { display:none;}
#btn_row { display:inline-block;}
#div_split { display:none;}
}
#media screen and (min-width: 800px) {
.team_name { display: inline-block; }
.team_abbr { display:none;}
.overall { display: inline-block;}
.divisional { display:inline-block;}
.wide { display:inline-block;}
#btn_row { display:none;}
#div_split ( display:inline-block;)
}
But now my challenge is that I want to have this same page/module used inside another page as a module position (which is only about 200 pixels wide).
Is there a CSS command similar to #media that will get the module width instead of the entire page width that the module is on?
Thanks in advance...

One way to do this is to add a class to your module, then size the elements inside the module relative to their parent (ie the module)
(1) Start by going to the module you want to work on > advanced tab > module class suffix
(2) Add a class and remember to include a space at the start, eg ' my-module-class'
(3) Finally, size your module elements relative to the module, eg
#media (max-width: 800px) {
.team_abbr {
...
width:50%;
}
}
Good luck, I hope this helps!

Related

How to increase specificity weight

<td class>
<div class="browser indicator">
<div class="mobile indicator">
In this code, the class indicator has a display:inline-block. How do I increase the specificity weight of the class browser and mobile so I can give them a separate value for display?
You can do that by specifying both classes "chained", meaning browser when it has indicator as well use this style.
.browser.indicator {
}
.mobile.indicator {
}
The important part for you is to not have the space between the classes because doing this will style children with the class indicator
.browser .indicator {
}
.mobile .indicator {
}
U can use this one:
.indicator {
display:inline-block;
width: 100%;
}
#media only screen and (max-width: 600px) {
.indicator {
display: block;
}
}
if screen size will be less 600px all styles which u have at #media will provide for page.

Hide a Shopify section based on users screen size using CSS

I would like help with code that will show a different slideshow section on Shopify based on the users screen size. I am using the code below which works great on a mobile device but on my laptop I see both slideshows.
What code do I need to add to hide the mobile slideshow when the screen size is above a certain amount of pixels?
#shopify-section-mobile-slideshow {
display: none !important;
}
#media (max-width: 450px){
#shopify-section-slideshow {
display: none !important;
}
#shopify-section-mobile-slideshow {
display: block !important;
}
}
Question answered by #stenley -
Use inspector elements to ascertain the section ID
For me:
#shopify-section-1586161998623 { display: none; }
#media (max-width: 768px){
#shopify-section-slideshow {
display: none !important;
}
#shopify-section-1586161998623 { display: block; }
}

how to hide/show a div using a media query but not when it's within another div

I'm trying to hide a specific div using a media query which is working fine. However, I need it to show when that div is within another specific div. Is this possible. This is the CSS:
#media (min-width: 665px) {
.mrbcircle-ipad:not(.link-inside.mrbcircle-ipad) {
position:absolute;
display:none;
}
}
so .mrbcircle-ipad should be hidden over 665px unless it's within .link-inside.
Currently this is showing .mrbcircle everywhere so I know it's wrong. How can I fix this?
Thanks
Anthony
#media (min-width: 665px) {
.mrbcircle-ipad {
position:absolute;
display:none;
}
.link-inside .mrbcircle-ipad{
position relative;
display: block;
}
}
Use two rules inside the media query: The first to hide it when the viewport is wider than 665px, the second to make it visible if it's inside a certain parent:
#media (min-width: 666px) {
.mrbcircle-ipad {
position:absolute;
display:none;
}
.link-inside .mrbcircle-ipad{
display: block;
}
}

Mobile Page not showing up - Joomla

Hi I am looking for some help in regards to understanding why the following page does not show up on a mobile size screen (480px) as all the other pages that have been built show up fine.
http://leicesterbakery.co.uk/index.php/product
I have a module class suffix with the following styles within the media queries in order to control what is shown on a mobile and what is shown a desktop.
(media query with max-width: 480px)
.range_full {
display: none;
}
.range_resp {
display: block;
}
Normal CSS file
.range_full {
display: block;
}
.range_resp {
display: none;
}
Would appreciate it if somebody could advise as really cant work out this isnt showing up.
You have a display: none on .range_full
Change it to block and it will show:
#media (max-width: 480px) {
/***** BASIC LAYOUT *****/
.range_full {
display: block;
}
.range_resp {
display:block;
}
.fullrange_full {
display:none;
}

How can I use media queries more efficiently with LESS?

I'm working with Bootstrap and LESS on a responsive webpage design.
One of the reasons I have enjoyed LESS in the past is because it can keep all attributes for HTML elements together.
What I have below is some rules to define a .sponsors block, and then one rule that applies to an element inside that block when the viewport is >= 768px
I don't like how that one rule requires a lot of extra code, and how that rule is apart from the rest of the rules. It also feels wrong.
What is a better way to do this / organize this? Do I need to start out by breaking everything down into top level #media groups?
.sponsors
{
li
{
.thumbnail
{
padding-top:20px;
padding-bottom:15px;
img
{
display:block;
margin:0 auto;
}
}
}
}
#media (min-width: 768px)
{
.sponsors
{
li
{
.thumbnail
{
padding-bottom:0px!important;
}
}
}
}
It would be pretty sweet if there was something like:
.thumbnail
{
&[#mediaWidth >=768]
{
padding-bottom:0px!important;
}
}
I think you can nest media queries and LESS (>1.3.0) will 'bubble' them to the root of your stylesheet during compilation.
.sponsors
{
li
{
.thumbnail
{
padding-top:20px;
padding-bottom:15px;
#media (min-width: 768px) {
padding-bottom:0px!important;
}
img
{
display:block;
margin:0 auto;
}
}
}
}

Resources