The use of Css overflow property results in hiding all content, making it impossible to customize the scrollbars

My goal in the code is to achieve a simple layout. The white divs should always be centered horizontally with a fixed width of 80vw and relative height. I want to hide the vertical scrollbar and have the horizontal one set to auto. Unfortunately, I am facing an issue where the horizontal scrollbar appears unnecessarily. When I try to hide it, the entire content disappears and I am unable to identify the problem.

var array = ['cat', 'dog', 'lion', 'tiger', 'snake']
for (var i = 0; i < 50; i++) {
    var random = Math.floor(Math.random() * (array.length));
    var n = array[random];
    var container = document.getElementById("container");
    container.innerHTML += '<div class="box">' + n + '</div>';
}
*{
outline:none;
transition:1s;

}
::-webkit-scrollbar:horizontal {
    display: none; 
}
html,body {
   position:absolute;
   left:0;
   top:0;
  margin:0;
  padding:0;
  width:100vw;

}

#container {

  position:absolute;
  top:0;
  left:0;
    height:auto;
  width:100vw;
    background-color: black;

}

.box {
  height: auto;
  width:80vw;
  margin-left:10vw;
  margin-top:10vh;
text-align:center;
vertical-align:middle;
font-size:calc(2vh + 2vw);
    background-color: white;
 
}
<html>
<head>
</head>
<body>
<div id="container"></div>
</body>
</html>

Answer №1

Adjusting the body and #container widths to 100% typically resolves this issue

Answer №2

To determine whether scrolling is allowed, use the overflow attribute. Check out this link for details on how to implement it.

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

What is the best way to transfer information between two HTML pages using PHP?

While working on updating a record, I encountered an issue trying to pass the student's ID from one page to another without displaying it in the query string. Despite attempting to use window.location and AJAX for navigation between pages, I haven&apo ...

Utilize Selenium to easily navigate through joint selection and list elements

Attempting to scrape a website using beautifulSoup and selenium has led me to a roadblock with a particular dropdown select menu. The HTML structure in question looks something like this: <div class="selection-box" alt="selection" ti ...

Can SVG use a transformation matrix to switch the values of x and y coordinates?

Currently using the svgpath library to manipulate SVGs, I am looking for a way to alter the coordinate system so that the y-axis becomes the x-axis and the x-axis becomes the y-axis. Is there any method to achieve this? I have attempted to rotate around ...

The form does not support inserting all values through AJAX. We may need to implement a QUERY to handle this

Can someone help me find the issue in my code? I have checked the back end and can't seem to identify the logic error. The form submission shows as successful but does not insert the values into the database. I'm still learning how to use ajax, s ...

The npm install command failed due to a lack of suitable versions for pinkie-promise

I am currently attempting to perform a straightforward "npm install" from one of the repositories mentioned in a tutorial provided here Below is the content of the package.json: { "name": "react-playlist", "version": "1.0.0", "description": "A basi ...

What are the top strategies for loading models on a webpage in AJAX systems?

As we delve into the world of using ExtJS with .NET web services to create ajax applications, a question arises regarding best practices for retrieving the model on the client side. An example scenario is having a form with 10 comboboxes. Should each combo ...

Retrieve the concealed division element's HTML content along with its formatting

Help needed with appending a hidden div with its styles intact. Despite using the code provided below, the appended div does not retain its styles. Any suggestions for an alternative method? var warningMessage = $('#warningDiv').html() fun ...

Using a function within a map in SCSS looping

Forgive me if this question sounds trivial, but I am curious if it is achievable to generate a series of functions using a loop within a map in SCSS. The code snippet below unfortunately does not yield the desired outcome, however, it illustrates what I a ...

Is there a way to identify when a Tween.js animation has completed?

Is there a completed or finished event available when using this code for animating the camera in a scene with tween.js? tween : function (target){ var position = camera.position; var tween = new TWEEN.Tween(p ...

Looking for a reliable CSS aggregator for .Net that can merge and minimize style sheets effectively?

Is there an open source or free project that offers a CSS manager? I want to optimize performance and am hoping to find a pre-built solution rather than starting from scratch. Some key features I'm looking for include: Merging multiple .css files in ...

Connect the mileage tracker to a Datalist or grid view component

I recently downloaded the Odometer Sample from , however, I am facing an issue where only the first element in the Datalist is getting the Odometer display, while others are not displaying it. Here is the snippet of code: <script type="text/javascript" ...

Token-StripeError not found

Can someone help me figure out why I keep getting this error message? Error: Stripe \ Error \ InvalidRequest No such token: tok_1E6AbPFWwEbVuzsrPEO3KM3A \vendor\stripe\stripe-php\lib\ApiRequestor.php // dealing wit ...

When adding margin-left and margin-right, images do not appear in their designated positions

I have a chart displaying images, which are showing up correctly. However, I am facing an issue when I try to add some spacing to the chart by using margin-left and margin-right. Here is the CSS code I included: #chart1 { margin: 0 auto; ...

Extracting a variable established on the client side and passing it to a server-side node backend

I am currently working on creating a comments section for a web application. The front end of the app displays information about the threading level of each comment. When users submit comments, I need to pass this threading information to the back end in o ...

Is it possible to locate a particular value within a nested array?

Help Needed: I'm working with an array that contains a nested array and I need to loop through it to locate a specific value. arr = [['123456','234567'], ['345678']]; specificValue = '123456'; I am looking for ...

Using a combination of radio buttons and JavaScript to adjust the color of a div element

Currently, I am experimenting with radio buttons to modify the background color of my div tag. My goal is to incorporate more than one condition. For example, if button A and button B are both clicked, then change the color to green. This is what I have im ...

Achieving consistent outcomes across various devices: What's the secret?

Hey there, I am facing an issue with my form page that I created using HTML, CSS, and Javascript. It looks good on my computer but appears messy on a mobile phone. The elements are getting out of the white box (div) making the entire page look chaotic. Sin ...

A group of components simultaneously decide to retrieve an object

Recently, I encountered a scenario where my React component ended up looking like this: function MyComponent(props) { const dispatch = useDispatch(); // Redux dispatch function const isLoading = useSelector(selIsLoading); // flag from our Redux app ...

When working with VueJS and Vuex, using the splice method to replace an item (object) in an array stored in Vuex does not trigger a re-render of the

I have an array of records. Each record consists of an object with _id (mongo id), title, and value (value is an object with amount and currency). When displaying the list of records using v-for, the ':key' for each item in the list is set to th ...

UTF-8 encoding experiencing issues on select Android mobile devices

Our new website, powered by Wordpress, is up and running but some users are experiencing issues with displaying Swedish special characters. It seems to be happening specifically on Android devices, regardless of the browser being used. However, I have not ...