Home > Web Front-end > CSS Tutorial > How to change vertical arrangement into horizontal arrangement in css

How to change vertical arrangement into horizontal arrangement in css

anonymity
Release: 2019-05-28 14:07:08
Original
12875 people have browsed it

There are two ways to convert a vertical list into a horizontal list. Use inline or float list items.

How to change vertical arrangement into horizontal arrangement in css

Both methods are fine, but if you want links to have the same size, you have to use the float method.

Inline list items

One way to create a horizontal navigation bar is to specify the element,

Instance

li{
    display:inline;
}
Copy after login

display :inline; - By default, the

  • element is a block element. Here we remove the newlines before and after each list item to display a single line.

    Floating list items

    In the above example the links have different widths.

    For all links to be of equal width, float the

  • element and specify the width of the element:

    Example

    li{
        float:left;
    }
    a{
        display:block;
        width:60px;
    }
    Copy after login

    float:left - use Slides of floating block elements next to each other

    display:block - displays links to block elements, making the whole clickable link area (not just the text), it allows us to specify the width

    width:60px - The maximum width of block elements by default. We want to specify a width of 60 pixels

    The above is the detailed content of How to change vertical arrangement into horizontal arrangement in css. For more information, please follow other related articles on the PHP Chinese website!

  • 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