r/csshelp • u/HotTrash88 • Oct 04 '23
Request I Have an HTML Container in Wordpress with some code that’s adding effects to a different block, I don't want the code to work on the phone or Tablet View, the Responsive Settings don't work in this situation. How can i stop the Code from working on phone and tablet view?
I tried using Ai for it like ChatGPT or and codewp.ai to edit the code saying it to do the mentioned command but it doesnt seem to work either.
This I’ve mentioned the original and edited code below
Original
<style>
/*Blur Zoom Hover Effect*/
.main-section{
--zoom-in: 1.2;
--zoom-out: 0.9;
--hover-background: #792C1A;
}
.main-section{
transition: all .5;
}
.main-section:hover .card{
filter: blur(5px);
transform: scale(var(--zoom-out));
}
.card{
transform: scale(1);
transition: all .5s;
}
.card:hover{
transform: scale(var(--zoom-in)) !important;
z-index: 2;
filter: blur(0px) !important;
}
.main-section .elementor-widget-wrap{
transition: all .5s;
}
.main-section .card:hover .elementor-widget-wrap{
background: var(--hover-background) !important;
}
</style>
Codewp.ae
<?php
<?php
function cwpai_blur_zoom_hover_effect() {
if (wp_is_mobile() && wp_is_tablet()) {
return;
}
?>
<style>
/* Blur Zoom Hover Effect */
/* Check window width and only apply styles if greater than 1024px */
<?php if (cwpai_check_window_width()) : ?>
.main-section{
--zoom-in: 1.2;
--zoom-out: 0.9;
--hover-background: #792C1A;
}
.main-section{
transition: all .5;
}
.main-section:hover .card{
filter: blur(5px);
transform: scale(var(--zoom-out));
}
.card{
transform: scale(1);
transition: all .5s;
}
.card:hover{
transform: scale(var(--zoom-in)) !important;
z-index: 2;
filter: blur(0px) !important;
}
.main-section .elementor-widget-wrap{
transition: all .5s;
}
.main-section .card:hover .elementor-widget-wrap{
background: var(--hover-background) !important;
}
<?php endif; ?>
</style>
<?php
}
// Function to check if window width is greater than 1024px
function cwpai_check_window_width() {
?>
<script>
if(window.innerWidth > 1024) {
return true;
} else {
return false;
}
</script>
<?php
}
add_action('wp_head', 'cwpai_blur_zoom_hover_effect');
2
u/Blind_Newb Oct 04 '23
With this specific line of code:
<script> if(window.innerWidth > 1024) { return true; } else { return false; } </script>
Did you try adding css code for "display: none;" if return false?
2
u/toi80QC Oct 04 '23
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent