
-
AuthorPosts
-
November 2, 2021 at 9:28 am #1327397
I want to hide the Leaflet map via CSS in /enfold-child/style.css when screen is small.
I have tried many things like
@media screen and (max-width 768px) { #footer .container .flex_column #block-8, #footer .leaflet-container, #block-8 > div { display:none !important; } }
But nothing works. Please help me hide the Leaflet map when screen size is smaller than 768px.
November 2, 2021 at 12:27 pm #1327434Hey forevershining,
Thank you for the inquiry.
You can toggle the visibility of the element by adjusting the Advanced > Responsive > Element Visibility options. You can also apply a unique class name or ID to the element and use it to hide the element on certain screen sizes.
// https://kriesi.at/documentation/enfold/add-custom-css/
Best regards,
IsmaelNovember 4, 2021 at 5:57 am #1327722Thanks for trying to help.
I cannot find ‘Advanced > Responsive > Element Visibility‘. There is ‘Advance Styling‘ in Enfold options but there is no ‘Responsive > Element Visibility‘.nor can I find Leaflet element in drop-down list.
I followed the link you gave to “provide a unique class name or ID” (viz. https://kriesi.at/documentation/enfold/add-custom-css/). The page says to “go to Enfold options > Layout Builder and select “Show element options for developers“. However, there is no “Show element options for developers” under the latter Enfold options.
Both methods you suggest for hiding Leaflet maps in footer widget on smaller screens fail to work for me. Please help.
November 5, 2021 at 5:18 am #1327856Hi,
Thanks for the update. Could you post a link to where we can see the element which you want to hide please?
Best regards,
RikardNovember 8, 2021 at 3:36 am #1328163Thanks for the help. The URL is in the Private Content below. The Leaflet map is in the second column of the footer.
I want to hide the map on smaller screens (display:none).
November 8, 2021 at 5:50 am #1328169Hi,
Thank you for the link.
We actually thought that you are using the OSM Leaflet element from the theme. To remove the map widget in the footer container, try to use this css code.
#footer .widget .leaflet-map { display: none !important; }
Make sure to place the code inside a css media query to limit the changes to mobile view.
Best regards,
IsmaelNovember 8, 2021 at 6:25 am #1328171I have tried your suggestion. Your selector is correct (as are the examples I gave in first post showing failed attempts). However, it still fails to hide the element on narrow screen widths.
@media screen and (max-width 768px) { #footer .widget .leaflet-map { display: none !important; } }
I can confirm that the styles.css (and your suggested code) is loading correctly.
BTW: I attempted to add Leaflet element into page using Avia Layout Builder. The button for the Leaflet however is disabled – hovering over the button shows “This element has been disabled […] You can enable it in Enfold -> Theme Extensions -> Leaflet Maps.
Like the suggestions made in your earlier posts, this menu option does not exist. Am I using an out-of-date theme? Are the instructions out-of-date?
November 8, 2021 at 9:29 am #1328192Hi,
Thank you for the update.
You may need to toggle or temporarily disable the Enfold > Performance > File Compression settings after adding the css code, and make sure to purge the cache or remove the browser history before testing the page.
Best regards,
IsmaelNovember 8, 2021 at 9:54 am #1328197As mentioned in previous post I can confirm that the CSS declaration (above) is loaded into browser correctly. I am also loading the site in an incognito window.
Nonetheless, I followed your instructions. The leaflet map is still not being hidden as per CSS declaration above.
I can enter the CSS declaration directly into Chrome DevTools’ inspector-stylesheet – and the map is hidden. However, something is preventing the CSS declaration in child theme’s style.css from being applied.
I suspect the javascript that creates the map element is also modifying the style attributes after my CSS file is being applied.
Also, could you please confirm that the instructions I’m being given are either a) out-of-date, or b) I’m running an old version of Enfold ? (See #1328171 & #1327722).
Current Parent Theme (Enfold) Version Number is 4.8.6.5
November 9, 2021 at 5:43 am #1328285So I’ve tried copying leaflet.css to my child theme and setting the URL in Leaflet map settings, and in (Enfold) Theme Extensions and the copied CSS file is loaded and works (except that the map marker loads a ‘broken image’ icon).
I added the CSS declaration above (without media query) to this copied CSS file and it hides the map as expected.
However, as soon as I nest the CSS declaration in a media query, it doesn’t work.
November 10, 2021 at 2:57 pm #1328518Hi,
Thank you for the update.
However, as soon as I nest the CSS declaration in a media query, it doesn’t work
What do you mean by “nest the CSS declaration”, and why did you copy the whole leaflet.css file? We may need to access the dashboard in order to check the issue properly. Please post the login details in the private field.
Best regards,
IsmaelNovember 11, 2021 at 4:16 am #1328588What do you mean by “nest the CSS declaration”
I mean wrap the declaration in a media query.
why did you copy the whole leaflet.css file?
Because there’s an option in Enfold Extensions -> Leaflet to set the location of ‘css File’. (I have to admit, I don’t really understand what this option is supposed to do, but whatever, I managed to get the map to source the CSS from a copy of the css file in child theme folder.)
Login details to live website in Private Content below. I’ve been doing development on localhost and haven’t touched the live site in a while. However, the live site does have a leaflet map in the footer which I haven’t been able to hide on narrow-width screens.
November 12, 2021 at 4:08 am #1328714Hi,
Thank you for the info.
Did you toggle or temporarily disable the Enfold > Performance > File Compression settings after adding the css code? We tried to access the dashboard using the login account above but it doesn’t seem to be valid.
Best regards,
IsmaelNovember 15, 2021 at 5:07 am #1329014Sorry about the login details. I’ve updated the password and checked that it’s good. See below.
Did you toggle or temporarily disable the Enfold > Performance > File Compression settings
As I said above, I followed your instructions. Also, as mentioned above, I can see that the CSS file with suggested declaration is requested and downloaded by browser correctly. However, the declaration is not being applied.
If I remove the media query the map is hidden as expected. If I nest the declaration in a media query, it is not applied when the media query requirements are met.
BTW, I want to share some screenshots with you. I uploaded to imgur.com but cannot make the images visible with tool img button. Please tell me how to share screenshots uploaded with imgur.
The imgur link is: https://imgur.com/a/nfA69Ax
-
This reply was modified 3 years, 5 months ago by
forevershining.
November 17, 2021 at 2:59 am #1329298Hi,
Thank you for the info.
We modified the css code a bit and fixed a few errors in the Quick CSS field. We also disabled the Performance > File Compression settings temporarily.
.header-scrolled .logo img { padding-top: 0; } .logo img { padding-top: 0px; } @media only screen and (max-width: 768px) { #footer .widget .leaflet-map { display: none !important; } }
Please make sure to purge or flush the cache before checking.
Best regards,
IsmaelNovember 18, 2021 at 6:11 am #1329436Thanks for your help. I can confirm that what you did now hides the map on narrow screens.
Can you now tell me how to make it work using child-theme /wp-content/themes/enfold-child/style.css please?
Also, I need to ask: did you install a number of plugins? There’s now half a dozen new plugins that have appeared.
November 19, 2021 at 5:40 am #1329601Hi,
Glad to know that it is now working.
You can actually copy or move the code from the Quick CSS field to the child theme’s style.css file directly. You may need to toggle or temporarily disable the Enfold > Performance > File Compression settings again after doing so.
did you install a number of plugins?
We did not install any plugins, only added and modified the css. Is there anyone else that have access to the site?
Best regards,
IsmaelNovember 19, 2021 at 5:40 am #1329603Hi,
Glad to know that it is now working.
You can actually copy or move the code from the Quick CSS field to the child theme’s style.css file directly. You may need to toggle or temporarily disable the Enfold > Performance > File Compression settings again after doing so.
did you install a number of plugins?
We did not install any plugins, only added and modified the css. Is there anyone else that have access to the site?
Best regards,
IsmaelNovember 22, 2021 at 4:16 am #1329877OK. So I copied the CSS from the Quick CSS field to
\wp-content\themes\enfold-child\style.css
, toggled Performance -> Compression, also Deleted old JS CSS files (under Performance) and flushed the cache from the command line with wp-cliwp cache flush
.I also loaded the site into an Incognito window and flushed the browser cache.
I did this several times and the CSS in child theme style.css failed to be applied when the browser screen is less than 768px.
I can confirm that the CSS rules from
style.css
(above) are being loaded. If I remove the media query from around thedisplay:none !important
declaration, the map is – as expected – not displayed.We’re back at the beginning of this issue and discussion. Please help. I want to hide the map on narrow screens and want to put the CSS in the child theme’s style.css.
-
This reply was modified 3 years, 5 months ago by
forevershining.
November 24, 2021 at 3:40 am #1330207Hi,
Since the css is working correctly when in the Quick CSS field, it is possible that there are some invalid css code in your child theme’s style.css file. You have to correct those in order to fix the issue. Temporarily, you can just leave the css in the Quick CSS field.
Best regards,
IsmaelNovember 25, 2021 at 3:46 am #1330375/* Theme Name: Enfold child Description: Enfold child theme Author: My Name Template: enfold Version: 0.1.0 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html */ /*@media screen and (max-width 768px) {*/ #footer .widget .leaflet-map { display: none !important; } /*}*/
This is the content of enfold-child/style.css. The CSS declaration successfully hides the map.
However, if I uncomment the media query, the map is not hidden on screens less than 768px (or any other size).-
This reply was modified 3 years, 5 months ago by
forevershining.
November 25, 2021 at 2:36 pm #1330479Hi,
Thank you for the info.
The css media query that you copied is invalid, it is missing the only keyword, which we already corrected in the Quick CSS field. This is the correct one.
@media only screen and (max-width: 767px) { /* Add your Mobile Styles here */ }
Again, you can move it back in the Quick CSS field.
Best regards,
IsmaelNovember 29, 2021 at 4:08 am #1330769I have changed the CSS declaration to include the
only screen
inenfold-child/style.css
.I have disabled all file merging and compression, and checked
Delete old CSS and JS files
. I have also flushed the cache with wp-cliwp flush cache
. I can confirm that the updatedstyle.css
is being loaded by the browser (Chrome Version 96.0.4664.45 (Official Build) (32-bit)). I can see the updatedstyle.css
in Chrome’s Dev tools, and when I remove the media query, the map is successfully hidden.However, as before, the map is not being hidden on screen sizes less than 768px with the media query including
only
keyword inenfold-child/style.css
.I’m not sure why you think including
only screen
instead ofscreen
will make any difference. The function of theonly
keyword is to simply hide the CSS declaration from older browsers. See https://stackoverflow.com/questions/8549529/what-is-the-difference-between-screen-and-only-screen-in-media-queries. I am not using an older browser; and anyway, as stated above, the only difference between usingonly
and not usingonly
would be that the CSS declaration would not be applied on older browsers if usingonly
keyword.In summary, the CSS declaration including media query works in the Quick CSS field but not in
enfold-child/style.css
. The stylesheet is loaded but the rules are not being applied.November 29, 2021 at 4:33 am #1330772Hi,
Thank you for the info.
There is a missing colon after the max-width declaration in the css media query.
/*Hide leaflet OpenStreet map in footer when on screen sizes smaller than 768px*/ /* NOTE: this does not work!! @media only screen and (max-width: 768px) {*/ @media screen and (max-width 768px) { #footer .widget .leaflet-map { display: none !important; } }
.. should be.
/*Hide leaflet OpenStreet map in footer when on screen sizes smaller than 768px*/ /* NOTE: this does not work!! @media only screen and (max-width: 768px) {*/ @media only screen and (max-width: 768px) { #footer .widget .leaflet-map { display: none !important; } }
We just noticed that the site contains an older version of the theme. Please try to update the theme from v4.8.6.5 to the latest version, v4.8.7.1, then go to the Enfold > Performance panel and enable the Delete old CSS and JS files? option to delete the old css and script files. You should also toggle or temporarily disable the Performance > File Compression settings.
And do a hard browser refresh before testing the page again.
Best regards,
IsmaelNovember 29, 2021 at 6:20 am #1330792It finally works! Thanks for your help and spotting the missing colon.
November 30, 2021 at 9:21 am #1330951 -
This reply was modified 3 years, 5 months ago by
-
AuthorPosts
- The topic ‘Leaflet map CSS styling’ is closed to new replies.