What causes my horizontal scroll bar to disappear while the vertical scroll bar remains visible?

Here are the CSS entries I am using...

div { overflow: hidden; overflow-y: hidden; overflow-x: hidden;}
div:hover { overflow:visible; overflow-y: visible; overflow-x: visible;}

I expected the vertical and horizontal scroll bars to only appear when a user hovers over a rectangle. However, this is only working for the horizontal scroll bar.

When the mouse is outside the rectangle: horizontal scroll bar is hidden, vertical scroll bar is visible.

https://i.sstatic.net/eOOGp.png

When the mouse is inside the rectangle: the horizontal scroll bar appears.

https://i.sstatic.net/WoSor.png

Update: The HTML code for my list is:

<nav>
  <ul>
    <li><a href=...>blah blah blah</a></li>
    <li><a href=...>blah blah blah</a></li>
    <li><a href=...>blah blah blah</a></li>
    ...
  </ul>
</nav>

Update: I tried using the following CSS...

div { overflow: hidden; overflow-y: hidden; overflow-x: hidden; width:300px;height:200px; }
div:hover { overflow:scroll; overflow-y: scroll; overflow-x: scroll;}

However, it did not work as expected. Here is how my rectangle looks before I hover over it:

https://i.sstatic.net/LSVl8.png

Both horizontal and vertical scroll bars appear. And here is how my rectangle looks on mouseover:

https://i.sstatic.net/Rmoet.png

The scroll bars remain but the text disappears!

Answer №1

To display scroll bars, you should use the 'scroll' property instead of 'visible'. The 'visible' property shows the content while 'scroll' enables the scrollbars.

div { overflow: hidden; overflow-y: hidden; overflow-x: hidden;

width:300px;height:200px;
}
div:hover { overflow:scroll; overflow-y: scroll; overflow-x: scroll;}
<div>
Content here
</div>

Answer №2

For optimal experience in different browsers, consider using the following CSS:

{overflow: -moz-scrollbars-none; }
for Firefox and
::-webkit-scrollbar { width: 0 !important }
for Chrome, Safari, or Opera (newer versions).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Apply CSS to a dynamically generated class

My system allows users to create multiple unordered lists (<ul>) with custom class names pulled from a database. Users can add or delete these lists and assign a color to each one. While I can save the color information in the database, I am unsure h ...

Performing a GET call within the configuration settings of AngularJS

I found a similar question here but unfortunately it didn't solve my issue. I am currently using Angular-UI's Google Maps API, which requires configuration as follows: .config(function(uiGmapGoogleMapApiProvider) { uiGmapGoogleMapApiProvider ...

Scrolling to ID or Anchor using jQuery: Automatically scrolls to the top if already at the designated section

I've been on a quest to uncover the cause and solution for this issue. Lately, I've been utilizing $("#content").animate({scrollTop:$(#elementId).offset().top-183}, 600); to achieve smooth scrolling to an ID within a <div>. The number 18 ...

Filtering Items with Checkboxes in JavaScript

I'm currently working on creating a filter system using checkboxes. Here is an example of what I have: Red squares Red circles Blue squares Blue circles I am aiming to set up filters based on both color and shape. However, I am facing some challe ...

What is causing the click function to malfunction after selecting a second item?

I'm struggling to understand why my click function isn't functioning properly. You can view the JSFiddle here: http://jsfiddle.net/adbakke/ve9oewvh/ This is a condensed version of my HTML structure: <div class="projectDisplay"></div&g ...

When using Array() as a constructor in JavaScript, what type of array is generated?

What is the reason Array(42) does not function with an iterator, whereas Array (42).fill() does? ...

Determine if I'm actively typing in the input field and alter the loader icon accordingly with AngularJS

Just delving into the world of AngularJS and attempting to tweak an icon as I type in an input box. Currently, I can detect when the box is focused using the following code: $scope.loading = false; $scope.focused = function() { console.log("got ...

Getting the local folder name using AngularJs

Is there a way to retrieve the directory name by browsing to a folder and clicking a button? I was considering utilizing <input type="file" /> to achieve this. ...

ways to verify ng-if post modification occurrence

Currently, my project is utilizing Angular 6. In the code, there is a div element with *ng-if="edited" as shown below: <div *ngIf="edited"> {{langText}} </div> Initially, when the page loads, edited is set to false and the div is not vis ...

Encountering an error when attempting to access an object property dynamically by using a passed down prop as a variable in Vue 2 & Vuex

I have been struggling for hours to find a solution to this problem, but so far I've had no luck. I've looked at these two questions, but they didn't provide the answers I needed: Dynamically access object property using variable Dynamical ...

Managing control among various child popups

In the situation I am facing, a parent window with login fields is present. In order to manage its controls, I have stored the window handle using: String parentWindow = idriver.getWindowHandle(); After entering the login credentials, a new popup (let&ap ...

Is there a way to choose multiple dropdown items that share the same header?

Utilizing the Fluent UI React Northstar Dropdown component in my React project, I've encountered an issue with multiple item selection. It seems that when there are several items sharing the same header value, only one can be selected at a time. What ...

How can we use JavaScript to retrieve an element with custom styling?

I've encountered a strange issue with my script where it seems to stack up borders and display a 2px border instead of the intended 1px border when switching elements on click. Here is the link code I am using: <li ><a href="plumbing.php"&g ...

Is the camera.lookAt() method still available in the THREE.js library?

While searching for information on setting up the camera, I came across references to the lookAt function in various posts. However, when I checked the THREE.js documentation, I couldn't locate this method. Can anyone help me understand where it went ...

Ways to resolve - Error: Unable to access 'comments' property of null

I am currently working on developing a blog web application and I am facing an issue with enabling user comments on posts. Despite extensive research and attempts to troubleshoot by searching online, I have not been able to find a solution. I have been str ...

Shifting elements between positions using jquery or angular

Here's the issue I'm facing... I have an array of movie divs (image and description) displayed using ng-repeat. Now, when I select one of them, I want to implement the following (almost like a game of positioning): 1) I want to smoothly remove t ...

Delegating events with .on('click') and using the CSS negation selector :not()

Struggling to implement event delegation for a dynamically added or removed class? I need to create an event for elements that are clicked, but without a specific class. Here's the code I have so far, but it doesn't seem to be working. Could it b ...

Generate visual representations of data sorted by category using AngularJS components

I am facing an unusual issue with Highcharts and Angularjs 1.6 integration. I have implemented components to display graphs based on the chart type. Below is an example of the JSON data structure: "Widgets":[ { "Id":1, "description":"Tes ...

Tips for showcasing boxed numerical characters on a website

Currently, I am tackling a project that involves converting a PDF into HTML. The original .ai file shows some numeric characters inside a box: https://i.sstatic.net/dAMU2.png Even though I am aware that the font used in the file is GothicMB101Pro DeBold- ...

What is the best way to use AngularJS to extract values from the first dropdown menu that are linked to the values selected in the second

How can I link values in two dropdowns using AngularJS? Hello everyone, I have set up two dropdown fields in MyPlunker and within the ng-option tag, I have applied a filter like filter:{roles: 'kp'} to only display users with the role of kp. T ...