Home > Web Front-end > CSS Tutorial > How to realize li display without line breaks in css

How to realize li display without line breaks in css

醉折花枝作酒筹
Release: 2023-01-05 16:10:58
Original
3636 people have browsed it

Implementation method: 1. Use the display attribute to convert li into an inline or inline block label. You only need to set the "display:inline|inline-block" style for li; 2. Use the float attribute to float , just set the "float:left" style to the element.

How to realize li display without line breaks in css

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

Method one:

display method, you need to convert li into an inline label or an inline block label

<html>
<head>
    <style type="text/css">
        li {
              display: inline;  <-- 或者inline-block -->
              list-style:none; 
              margin:0 20px;
        }
        div {
              display: none;
        }
    </style>
</head>
<body>
<ul>
  <li>aa</li>
  <li>bb</li>
  <li>cc</li>
  <li>dd</li>
</ul>
</body>
</html>
Copy after login

Method two:

Select left Float mode, float: left;

<html>
<head>
    <style type="text/css">
        li {
              float: left; 
              list-style:none; 
              margin:0 20px;
        }
        div {
              display: none;
        }
    </style>
</head>
<body>
<ul>
  <li>aa</li>
  <li>bb</li>
  <li>cc</li>
  <li>dd</li>
</ul>
</body>
</html>
Copy after login

Recommended learning: css video tutorial

The above is the detailed content of How to realize li display without line breaks in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
li
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