CSS: disable scrolling - html

unfortunately I have a little problem with a CSS class I implemented on my website. The menu on the page is displayed by the CSS code. Unfortunately I can't manage to disable scrolling while the menu is open. I already tried using "position: fixed !important;" and "overflow". Somehow, it did not work.
Here is the CSS code:
<style>
/*****************************************/
/*********| FULLSCREEN MENU CSS |*********/
/*****************************************/
/* Move the hamburger to the right of the header */
.de-burger-menu .et_pb_menu__wrap {
justify-content: flex-end !important;
}
/* Hide the desktop menu */
.de-burger-menu .et_pb_menu__wrap .et_pb_menu__menu {
display: none !important;
}
/* Force the mobile version of the menu */
.de-burger-menu .et_pb_menu__wrap .et_mobile_nav_menu {
display: block !important;
align-items: center !important;
}
/* Fullscreen Menu Style when Opened*/
.de-burger-menu .opened #mobile_menu1 {
width: 100vw !important; /* Make it span the full width of the viewport */
position: fixed !important;
top: 0em !important;
left: 0vw !important;
height: 100vh !important; /* Make it span the full height of the viewport */
display: flex !important;
justify-content: center !important;
flex-direction: column !important;
transition: visibility 0.3s, opacity 0.3s ease-in-out; /* Animate the menu to fade in */
padding: 0 !important;
background-color: #ffffff!important; /* Fullscreen menu background color */
}
/* Show fullscreen menu */
.de-burger-menu .opened #mobile_menu1 {
opacity: 1 !important; /* Make it visible by setting opacity to 1 */
visibility: visible !important; /* Show the menu */
}
/* Hide and fade out the Menu when closed */
.de-burger-menu .closed #mobile_menu1 {
opacity: 0 !important; /* Make it invisible by setting opacity to 0 */
visibility: hidden !important; /* Hide the menu */
transition: visibility 0.3s, opacity 0.3s, left 1s, ease-in-out !important; /* Animate the menu to fade out */
}
/* Remove Bullets next to LI Elements */
.de-burger-menu #mobile_menu1 li {
list-style: none !important;
text-align: center !important;
width: 100%
}
/* Make sure that the menu is above other elements */
.de-burger-menu .et_pb_menu__wrap span.mobile_menu_bar {
z-index: 999999 !important;
}
/* Set the close icon for when the menu is open */
.de-burger-menu .et_pb_menu__wrap .opened .mobile_menu_bar:before {
color: #562f2f !important; /* Icon color */
content: "\4d" !important; /* Divi font icon to use for the close icon */
left: -40px; /* Close icon position. You might need to play with this to make it look right */
}
/* Keep hamburger icon in fixed position on mobile */
.de-burger-menu .opened .mobile_menu_bar {
position: fixed !important;
}
/* Remove mobile menu border */
.de-burger-menu .et_mobile_menu {
border-top: none;
}
/* Make sure the menu items do not show a background */
.de-burger-menu .et_mobile_menu .menu-item-has-children>a {
background-color: transparent;
}
/* Remove the hover background from the menu items and add hover animation */
.et_mobile_menu li a:hover {
background-color: transparent;
opacity: 1;
transition: transform 0.3s ease-in-out !important; /* Animated the menu item when hovered */
transform: scale(1.15); /* Enlarge the hovered menu item by 15% when hovered */
}
/* Remove menu item bottom borders */
.de-burger-menu .et_mobile_menu li a {
border-bottom: none;
}
</style>
The website is: https://aureus-frankfurt.de/
I hope someone knows a solution.
Kind regards

Hi Welcome to the community:
You can target the mobile opened class with :has and make the body overflow:hidden
body:has(.mobile_nav.opened) {
overflow: hidden
}

Related

Make header transition smoother when scrolling up

I created a header, added a scroll-up effect, and changed its color. So it is transparent when on top, hidden when scrolling down and white & sticky when scrolling up.
What I want to achieve is a smoother transition from white to top transparent when scrolling up. Tried to add transition CSS variations, but not working.
Here is how it looks when scrolling to the top. the white turns transparent instantly. I want to add a smoother transition.
Any suggestions? Here is the code that I added to make it sticky:
document.addEventListener('DOMContentLoaded', function() {
jQuery(function($){
var mywindow = $(window);
var mypos = mywindow.scrollTop();
mywindow.scroll(function() {
if (mypos > 40) {
if(mywindow.scrollTop() > mypos) {
$('#transparentsticky').addClass('headerup');
} else {
$('#transparentsticky').removeClass('headerup');
}
}
mypos = mywindow.scrollTop();
}); }); });
#transparentsticky{
-webkit-transition: margin 0.3s ease;
transition : margin 0.9s ease-in-out;
}
.headerup{
margin-top: -150px !important; /*adjust this value to the height of your header*/
}
I also added this code to the Header section which adds the white transition ( white header appearing) Maybe something can be added here to make it smoothly fade into transparent as well?
.elementor-sticky--effects {
background: #ffffff!important; /* change the background color here*/
transition: .3s all ease-in-out!important;
}
.elementor-sticky--effects .sticky-menu-items ul li a /* change the menu text color here*/ {
color: #fff!important;
}
.elementor-sticky--effects, .sticky-menu-items ul li a {
transition: .3s all ease-in-out;
}
/* HIDES THE DARK LOGO */
.d-logo {
display: none;
}
/* SWITCHES LOGO ON SCROLL */
.elementor-sticky--effects .d-logo {
display: inline-block;
}
.elementor-sticky--effects .l-logo {
display: none;
}
/* CHANGES THE MENU COLOR ON SCROLL */
.elementor-sticky--effects .sticky-menu-items ul li a {
color: #000000!important;
}
/*Change the search icon color on scroll*/
.elementor-sticky--effects .search-on-scroll i {
color: #000000!important;
}
/*Change the hamburger icon color on scroll*/
.elementor-sticky--effects .hamburgericon i {
color: #000000!important;
}
/*Change the cart icon color on scroll*/
.elementor-sticky--effects .menucart i {
color: #000000!important;
}
/* CONTROLS THE TRANSITION SPEED - KEEP ALL SAME SPEED TO HAVE A CLEAN EFFECT */
.elementor-sticky--effects .sticky-menu-items ul li a {
transition: .3s all ease-in-out!important;
}
.elementor-sticky--effects {
transition: .3s all ease-in-out!important;
}
/*change color to the mobile menu toggle*/
.elementor-sticky--effects .sticky-menu-items i {
color: #000000/*add your color here*/!important;
}
/* CHANGES THE TEXT HOVER COLOR ON SCROLL */
.elementor-sticky--effects .sticky-menu-items ul li a:hover {
color: #3F525F/*add your color here*/!important; /* edit here to change your text color for sticky header */
}
/* CHANGES THE SEARCH HOVER COLOR ON SCROLL */
.elementor-sticky--effects .search-on-scroll i:hover {
color: #3F525F/*add your color here*/!important; /* edit here to change your text color for sticky header */
}
/* CHANGES THE HAMBURGER HOVER COLOR ON SCROLL */
.elementor-sticky--effects .hamburgericon i:hover {
color: #3F525F/*add your color here*/!important; /* edit here to change your text color for sticky header */
}
/* CHANGES THE CART HOVER COLOR ON SCROLL */
.elementor-sticky--effects .menucart i:hover {
color: #3F525F/*add your color here*/!important; /* edit here to change your text color for sticky header */
}

z-index not working as expected on hovered side nav

I have sample page here: https://jsfiddle.net/solaris_9/17dwfmap/16/
.area-toc a {
position: absolute; /* Position them relative to the browser window */
left: -120px; /* Position them outside of the screen */
transition: 0.3s; /* Add transition on hover */
/*padding: 2px; *//* 15px padding */
width: 140px; /* Set a specific width */
text-decoration: none; /* Remove underline */
font-size: 15px; /* Increase font size */
color: white; /* White text color */
border-radius: 0 2px 2px 0; /* Rounded corners on the top right and bottom right side */
text-align: center;
background-color: #76a000;
z-index: 99;
}
.area-toc a:hover{
left: 0;
z-index: 99;
}
.table-main{
border-style:solid;
border-color:#aad69e;
border-width:1px 1px 1px;
z-index:9;
position:relative;
}
Generally speaking, when the mouse hovers at the side nav, I want the link could be rendered in front of the table. I set the z-index of it to 99, while the table is 9, but it doesn't work.
Do you have any idea? Does it link to the flex display of the table?
This is a problem I often face too when working with z-index's. The way I workaround this is to just set the z-index of the element I want to be lower, to a negative number.
https://jsfiddle.net/17dwfmap/27/
On line 113, I changed
z-index:9;
to
z-index:-10;

Custom styling progress bar in CSS

I have a progress bar and i want to style it away from default.
I tried bit of things but it didn't work as I expected.
I want to change the background color and border radius of the progress bar.
When I set the background color, it changes from the default blue to green color and not to the color I set.
<progress class="amount-progress" value="60500" max="120000">70 %</progress>
You can see the fiddle.
When i set the background-color the color changes from blue to green which has to change to a different blue.
And i want the progress bar to have a smooth edge.
I did set border-radius but this also didn't work out.
.amount-progress {
width: 80%;
margin-left: -11.5%;
height: 22px;
background-color: #0091EA;
}
You have to work with the kit of HTML5 progress bar.These are currently the entire selectors for styling HTML5 progress bar:
progress {
/* style rules */
}
progress::-webkit-progress-bar {
/* style rules */
}
progress::-webkit-progress-value {
/* style rules */
}
progress::-moz-progress-bar {
/* style rules */
}
so :
progress {
border-radius: 7px;
width: 80%;
height: 22px;
margin-left: -11.5%;
box-shadow: 1px 1px 4px rgba( 0, 0, 0, 0.2 );
}
progress::-webkit-progress-bar {
background-color: yellow;
border-radius: 7px;
}
progress::-webkit-progress-value {
background-color: blue;
border-radius: 7px;
box-shadow: 1px 1px 5px 3px rgba( 255, 0, 0, 0.8 );
}
progress::-moz-progress-bar {
/* style rules */
}
<progress value="3333" max="10000">33%</progress>
One thing to keep in mind is that there are two types of progress bars: indeterminate and determinate. If you use the above you will be changing the style for both. If you only want to change the style for a determinate bar you can do the below. This is useful if you want to style the indeterminate progress bar different, for example with a rounded spinner or anything like that.
progress {
display: block;
}
/* Determinate: */
progress[value] {
/* style rules */
}
progress[value]::-webkit-progress-bar {
/* style rules */
}
progress[value]::-webkit-progress-value {
/* style rules */
}
progress[value]::-moz-progress-bar {
/* style rules */
}
/* Indeterminate: */
progress:not([value]) {
/* style rules */
}
progress:not([value])::-webkit-progress-bar {
/* style rules */
}
progress:not([value])::-webkit-progress-value {
/* style rules */
}
progress:not([value])::-moz-progress-bar {
/* style rules */
}
<p>Determinate:</p>
<progress value="66" max="100">Determinate</progress>
<p>Indeterminate:</p>
<progress>Indeterminate</progress>

How do I make the dropdown fade in and out transition?

I want to make the dropdown menu fade in/out slightly. I tried to add opacity and hover, but I could not figure it out.
nav ul li:hover > .midbox {
opacity:1;
transition: all 0.5s ease;
}
I than set opacity:0 on .midbox with the same transition applied.
Below is a fiddle with an example.
https://jsfiddle.net/skf5v0Lw/
Am I supposed to use the other element hover state to affect the state of the dropdown?
CSS transition does not work on display property. Use visibility instead. Also it should be set on the dropdown UL rather than the inner element.
/* Hide Dropdowns by Default
* and giving it a position of absolute */
nav ul ul {
/* display: none; */
position: absolute;
width: 800px;
top: 60px;
opacity: 0;
visibility: hidden;
transition: all 0.5s ease;
}
/* Display Dropdowns on Hover */
nav ul li:hover > ul {
/* display:block; */
opacity: 1;
visibility: visible;
}
https://jsfiddle.net/skf5v0Lw/5/
Not sure if this helps, but you could check out dropotron, it allows for a bunch of settings like fade in dropdown, hover delay, and that sort of thing.
https://github.com/n33/jquery.dropotron

Applying opacity to a nested list item for a fade effect using CSS3

Well, I'm completely at a loss. I'm designing a website with 4 social icons on the top right hand side. When one hovers over the icons, they increase from .7 to 1.0 opacity, and a line of text appears underneath. This is best demonstrated by an example (the images are broken, but no matter):
http://jsfiddle.net/7hZYj/
It's a rather simple effect which I've achieved through the use of CSS3 and lists:
#pageHeader .social ul ul {
position: absolute;
top: 30px;
right:0;
width:160px;
text-align: right;
opacity: 0.0;
-moz-transition:ease .6s; /* Firefox 4 */
-webkit-transition:ease .6s; /* Safari and Chrome */
-o-transition:ease .6s; /* Opera */
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
}
#pageHeader .social ul li:hover ul {
opacity: 1.0;
}
The problem is that if one hovers right below the images, the text shows up anyway. For instance, if you hover right below the image furthest to the right, the "join the e-list" line shows up. I only want it to reach 1.0 opacity when the image is hovered over...which is what I thought I specified in the CSS above.
What am I doing wrong?
opacity leaves the element there and since it's a child of the li, when you hover over the invisible element, you're hovering over the li.
#pageHeader .social ul ul {
position: absolute;
top: 30px;
right:0;
width:160px;
text-align: right;
opacity: 0.0;
-moz-transition:ease .6s; /* Firefox 4 */
-webkit-transition:ease .6s; /* Safari and Chrome */
-o-transition:ease .6s; /* Opera */
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
left: -9999px;
}
#pageHeader .social ul li:hover ul {
opacity: 1.0;
left: auto;
}
Adding left:-9999px; seems to fix the issue. You can adjust the transition if you don't want it to automatically go back to the left when you are no longer hovering, as seen in this fiddle