Home  >  Article  >  Web Front-end  >  How to change the spacing of li in ul with css

How to change the spacing of li in ul with css

WBOY
WBOYOriginal
2021-12-13 09:45:126590browse

In CSS, you can use the "margin-bottom" attribute to change the spacing of li in ul. This attribute is used to set the lower margin of the element. Use this attribute to set the lower margin of the li element in ul. , and then change the spacing of li, the syntax is "ul li{margin-bottom: spacing value;}".

How to change the spacing of li in ul with css

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

How to change the spacing of li in ul in css

In css, if we want to change the spacing of li in ul, we can use margin- The bottom attribute and the margin-bottom attribute are used to set the bottom margin of the element.

The attribute value of this attribute is as follows:

How to change the spacing of li in ul with css

Let’s take an example to see how to set the spacing of li in ul. The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    ul li{
        margin-bottom:20px;
    }
    </style>
</head>
<body>
<p>无序列表:</p>
<ul>
  <li>雪碧</li>
  <li>可乐</li>
  <li>凉茶</li>
</ul>
</body>
</html>

Output results:

How to change the spacing of li in ul with css

If you are interested, you can continue to click on css video tutorial to learn.

The above is the detailed content of How to change the spacing of li in ul with css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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