Home > Web Front-end > CSS Tutorial > How to arrange images horizontally in css

How to arrange images horizontally in css

藏色散人
Release: 2022-12-30 11:11:28
Original
12148 people have browsed it

How to arrange pictures horizontally in css: first create a div to wrap all the pictures; then hide the vertical scroll bar of the outer div, set the horizontal scroll bar to automatic; finally set the white of the outer div The value of the -space attribute is nowrap.

How to arrange images horizontally in css

The operating environment of this tutorial: windows7 system, HTML5&&CSS3 version, Dell G3 computer.

Recommended: css video tutorial

css arranges pictures horizontally

The following will be introduced directly through code examples:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title></title>
  <style>
  .wrap{
    height: 130px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
  }
  .b{
    width: 200px;
    height: 100px;
  }
  </style>
</head>
<body>
  <div class="wrap">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
    <img src="1.jpg" alt="" class="b">
  </div>
</body>
</html>
Copy after login

Rendering:

How to arrange images horizontally in css

Note that the img tag cannot float left, and the outer container must be added without line breaks.

The above is the detailed content of How to arrange images horizontally in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template