How to implement horizontal scrolling of elements using css

王林
Release: 2020-12-21 09:57:13
forward
4981 people have browsed it

How to implement horizontal scrolling of elements using css

Analysis:

Scrolling will occur when the width of the child element is greater than the parent element. Overflow-x: scroll; is horizontal scrolling, and overflow-y: scroll; is vertical scrolling. , horizontal horizontal scrolling is used here according to requirements.

(Learning video sharing:css video tutorial)

html code:

2

XXXXXX

满1000元可用

2

XXXXXX

满1000元减200

Copy after login

Main css code:

.content { width: 100%; overflow-x: scroll; // 子元素的宽度大于父元素的即可滚动 overflow-y: hidden; border-radius: 4px; } .content::-webkit-scrollbar { display:none } // 隐藏滚动条 .content-list{ display: -webkit-flex; display: -ms-flexbox; display: flex; float: left; // 使其脱离文档流 宽度为所有字元素的和 min-width: 100%; } .item { width: 150px; height: 50px; display: -webkit-flex; display: -ms-flexbox; display: flex; flex: 3; -webkit-align-items: center; -ms-flex-align: center; align-items: center; padding: 0 10px; }
Copy after login

Related Recommended:CSS tutorial

The above is the detailed content of How to implement horizontal scrolling of elements using css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!