使用 CSS 溢出属性可以轻松使 div 水平滚动。溢出属性有不同的值。
例如溢出:自动;和轴隐藏程序,如溢出-x: auto;。它只会制作一个水平滚动条。
对于水平滚动条,使用 x 和 y 轴。设置溢出-y:隐藏;和溢出-x:自动;这将自动隐藏垂直滚动条并仅显示水平滚动条。空白:nowrap;属性用于将文本包装在一行中。此处滚动 div 将可水平滚动。
示例 1:
HTML
Making a div horizontally
scrollable using CSS
GeeksforGeeks
Making a div horizontally
scrollable using CSS
It is a good platform to learn programming.
It is an educational website. Prepare for
the Recruitment drive of product based companies
like Microsoft, Amazon, Adobe etc with a free
online placement preparation course. The
course focuses on various MCQ's & Coding question
likely to be asked in the interviews & make your
upcoming placement season efficient and successful.
Also, any geeks can help other geeks by writing
articles on the
GeeksforGeeks, publishing articles follow few steps
that are Articles that need little modification or
improvement from reviewers are published first.
To quickly get your articles reviewed, please refer
existing articles, their
formatting style, coding style, and try to make you
are close to them. In case you are a beginner, you
may refer Guidelines to write an Article
HTML
Making a div horizontally
scrollable using CSS
GeeksforGeeks
Making a div horizontally
scrollable using CSS
It is a good platform to learn programming.
It is an educational website. Prepare for
the Recruitment drive of product based companies
like Microsoft, Amazon, Adobe etc with a free
online placement preparation course. The
course focuses on various MCQ's & Coding question
likely to be asked in the interviews & make your
upcoming placement season efficient and successful.
Also, any geeks can help other geeks by writing
articles on the
GeeksforGeeks, publishing articles follow few steps
that are Articles that need little modification or
improvement from reviewers are published first.
To quickly get your articles reviewed, please refer
existing articles, their
formatting style, coding style, and try to make you
are close to them. In case you are a beginner, you
may refer Guidelines to write an Article
输出:
示例 2:在本示例中,使用 auto 代替 overflow-y: hidden;和溢出-x:自动;使 div 可水平滚动。
HTML
Making a div horizontally
scrollable using CSS
GeeksforGeeks
Making a div horizontally
scrollable using CSS
It is a good platform to learn programming.
It is an educational website. Prepare for
the Recruitment drive of product based companies
like Microsoft, Amazon, Adobe etc with a free
online placement preparation course. The
course focuses on various MCQ's & Coding question
likely to be asked in the interviews & make your
upcoming placement season efficient and successful.
Also, any geeks can help other geeks by writing
articles on the
GeeksforGeeks, publishing articles follow few steps
that are Articles that need little modification or
improvement from reviewers are published first.
To quickly get your articles reviewed, please refer
existing articles, their
formatting style, coding style, and try to make you
are close to them. In case you are a beginner, you
may refer Guidelines to write an Article
输出: