两个或多个相同高度的不同 div 可以使用 CSS 并排放置。使用 CSS 属性设置 div 的高度和宽度,并使用 display 属性以并排格式放置 div。
下面列出了使用的显示属性:
- 显示:表;此属性用于行为类似于表格的元素 (div)。
- 显示:表格单元格;此属性用于行为类似于 td 的元素 (div)。
- display:table-row:此属性用于行为类似于 tr 的元素 (div)。
示例 1:
html
GeeksforGeeks
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/
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.
html
输出:
示例 2:此示例包含使用 CSS 并排放置的多个 div。
html
输出: