


How to implement horizontal mouse wheel movement on a horizontal web page? _html/css_WEB-ITnose
How to move the mouse wheel horizontally on a horizontal webpage?
I am making a school food ordering webpage and want to make it horizontal. The webpage has already been made. How can I make the mouse wheel move the scroll bar horizontally?
Is it possible to add a button that when clicked will cause the scroll bar to move a certain number of pixels to the right? I only know static html web pages, please help me.
Reply to the discussion (solution)
Adding a button is as simple as changing the position of the component that needs to be scrolled in the button function. Using libraries such as jQuery also brings Scroll effects.
Vertical and horizontal orientation is a matter of the client operating system, just configure the mouse properties, if any.
(function() { var stepSize = 200, //每滚动一格鼠标,移动多少距离 doc = document.documentElement, body = document.body, docWidth = doc.clientWidth, scrollLeft = 0;//添加mousewheel事件if (document.addEventListener) { document.addEventListener('mousewheel', scroll, false);} else { document.attachEvent('onmousewheel',scroll) //针对老ie浏览器}//处理mousewheel事件的信息function scroll (event) { var direction = event.wheelDelta; //保证滚动到头的时候不再调用update函数 if (scrollLeft <= 0 && direction > 0) { return; } if (scrollLeft >= docWidth && direction < 0) { return; } //根据鼠标滚动的方向确定是往左还是往右移动 var distance = direction > 0? -stepSize : stepSize; update(distance);}//滚动function update (distance) { scrollLeft += distance; doc.scrollLeft = scrollLeft; body.scrollLeft = scrollLeft; //针对webkit浏览器} })();
Changing the stepsize in the first line can modify the distance of each scroll
JavaScript code?123456789101112131415161718192021222324252627282930313233343536( function() { var stepSize = 200, // How much distance does the mouse move every time doc = document.documentElement, body = documen...
There is a small problem. I changed it
(function() {var stepSize = 200, //每滚动一格鼠标,移动多少距离 doc = document.documentElement, body = document.body, docWidth = doc.clientWidth, scrollLeft = -1, ready = false;//添加鼠标滚轮事件if (document.addEventListener) { document.addEventListener('mousewheel', scroll, false); document.addEventListener('DOMMouseScroll', scroll, false); //针对firefox} else { document.attachEvent('onmousewheel',scroll) //针对老ie浏览器}//处理mousewheel事件的信息function scroll (event) { //第一次滚动需要获取当前滚动位置 if (!ready) { scrollLeft = doc.scrollLeft + body.scrollLeft; ready = true; } //firefox用detail反映滚动方向,而且方向和其他浏览器相反。其他浏览器用wheelDelta var direction = event.wheelDelta || -event.detail; //保证滚动到头的时候不再调用update函数 if (scrollLeft <= 0 && direction > 0) { return; } if (scrollLeft >= docWidth && direction < 0) { return; } //根据鼠标滚动的方向确定是往左还是往右移动 var distance = direction > 0? -stepSize : stepSize; update(distance);}//滚动function update (distance) { scrollLeft += distance; doc.scrollLeft = scrollLeft; body.scrollLeft = scrollLeft; //针对webkit浏览器} })();
There must be something like this in the css. One:
html, body { height: 100%;}
You can search for many solutions, you can refer to
(function() {var stepSize = 200, //每滚动一格鼠标,移动多少距离 doc = document.documentElement, body = document.body, docWidth = doc.clientWidth, scrollLeft = -1, ready = false;//添加鼠标滚轮事件if (document.addEventListener) { document.addEventListener('mousewheel', scroll, false); document.addEventListener('DOMMouseScroll', scroll, false); //针对firefox} else { document.attachEvent('onmousewheel',scroll) //针对老ie浏览器}//处理mousewheel事件的信息function scroll (event) { //第一次滚动需要获取当前滚动位置 if (!ready) { scrollLeft = doc.scrollLeft + body.scrollLeft; ready = true; } //firefox用detail反映滚动方向,而且方向和其他浏览器相反。其他浏览器用wheelDelta var direction = event.wheelDelta || -event.detail; //保证滚动到头的时候不再调用update函数 if (scrollLeft <= 0 && direction > 0) { return; } if (scrollLeft >= docWidth && direction < 0) { return; } //根据鼠标滚动的方向确定是往左还是往右移动 var distance = direction > 0? -stepSize : stepSize; update(distance);}//滚动function update (distance) { scrollLeft += distance; doc.scrollLeft = scrollLeft; body.scrollLeft = scrollLeft; //针对webkit浏览器} })();
There must be such an article in the css:
html, body { height: 100%;}
Could you please tell me how to quote this js code? Please help me, thanks!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

This article will introduce how to turn off the thumbnail function displayed when the mouse moves the taskbar icon in Win11 system. This feature is turned on by default and displays a thumbnail of the application's current window when the user hovers the mouse pointer over an application icon on the taskbar. However, some users may find this feature less useful or disruptive to their experience and want to turn it off. Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another drawback is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. but

How to send web pages to the desktop as a shortcut in Edge browser? Many of our users want to display frequently used web pages on the desktop as shortcuts for the convenience of directly opening access pages, but they don’t know how to do it. In response to this problem, the editor of this issue will share the solution with the majority of users. , let’s take a look at the content shared in today’s software tutorial. The shortcut method of sending web pages to the desktop in Edge browser: 1. Open the software and click the "..." button on the page. 2. Select "Install this site as an application" in "Application" from the drop-down menu option. 3. Finally, click it in the pop-up window

According to news from this site on July 12, Razer today announced the launch of the Razer|Pokémon Gengar wireless mouse and mouse pad. The single product prices are 1,299 yuan and 299 yuan respectively, and the package price including the two products is 1,549 yuan. This is not the first time that Razer has launched Gengar co-branded peripheral products. In 2023, Razer launched the Gengar-style Yamata Orochi V2 gaming mouse. The two new products launched this time all use a dark purple background similar to the appearance of the Ghost, Ghost, and Gengar families. They are printed with the outlines of these three Pokémon and Poké Balls, with the character Gengar in the middle. A large, colorful image of a classic ghost-type Pokémon. This site found that the Razer|Pokémon Gengar wireless mouse is based on the previously released Viper V3 Professional Edition. Its overall weight is 55g and equipped with Razer’s second-generation FOC

According to news from this website on March 31, HP recently launched a Professor1 three-mode Bluetooth mouse on JD.com, available in black and white milk tea colors, with an initial price of 99 yuan, and a deposit of 10 yuan is required. According to reports, this mouse weighs 106 grams, adopts ergonomic design, measures 127.02x79.59x51.15mm, has seven optional 4000DPI levels, is equipped with a Blue Shadow RAW3220 sensor, and uses a 650 mAh battery. It is said that it can be used on a single charge. 2 months. The mouse parameter information attached to this site is as follows:

Some netizens found that when they opened the browser web page, the pictures on the web page could not be loaded for a long time. What happened? I checked that the network is normal, so where is the problem? The editor below will introduce to you six solutions to the problem that web page images cannot be loaded. Web page images cannot be loaded: 1. Internet speed problem The web page cannot display images. It may be because the computer's Internet speed is relatively slow and there are more softwares opened on the computer. And the images we access are relatively large, which may be due to loading timeout. As a result, the picture cannot be displayed. You can turn off the software that consumes more network speed. You can go to the task manager to check. 2. Too many visitors. If the webpage cannot display pictures, it may be because the webpages we visited were visited at the same time.

This article explores issues that can arise when the mouse is unable to select or highlight text in Microsoft Word, and how to resolve them. Why can't I select text in Microsoft Word? The inability to select text in MSWord may be affected by a variety of reasons, such as permission restrictions, document protection, mouse driver issues, or file corruption. Solutions to these problems are provided below. Fix Microsoft Word cannot select or highlight text using mouse If Microsoft Word cannot select or highlight text using mouse, follow the solutions mentioned below: Make sure your left mouse button is working Check if you are eligible to change the file Update the driver of your mouse

According to news from this site on August 12, VGN launched the co-branded "Elden Ring" keyboard and mouse series on August 6, including keyboards, mice and mouse pads, designed with a customized theme of Lani/Faded One. The current series of products It has been put on JD.com, priced from 99 yuan. The co-branded new product information attached to this site is as follows: VGN丨Elden Law Ring S99PRO Keyboard This keyboard uses a pure aluminum alloy shell, supplemented by a five-layer silencer structure, uses a GASKET leaf spring structure, has a single-key slotted PCB, and the original height PBT material Keycaps, aluminum alloy personalized backplane; supports three-mode connection and SMARTSPEEDX low-latency technology; connected to VHUB, it can manage multiple devices in one stop, starting at 549 yuan. VGN丨Elden French Ring F1PROMAX wireless mouse the mouse

Many users don't know where the files installed by their Razer drivers go. These driver files are usually installed on the system disk, which is the C drive of the computer. The specific location is in the RAZE folder under programfiles. In which folder is the Razer mouse driver located? A: In the RAZE folder under programfiles on the system C drive. Generally, the driver will be installed on the C drive, just find it according to the location. Introduction to Razer mouse driver installation method 1. After downloading the file from the official website, double-click to run the downloaded EXE file. 2. Wait for the software to load. 3. Here you can choose which driver you want to install. 4. After selecting, click "Install" in the lower right corner.
