Align Flex items at the beginning of a container using CSS

PHPz
Release: 2023-09-11 18:29:02
forward
628 people have browsed it

使用 CSS 将容器开头的 Flex 项目对齐

Align flex items at the beginning using the justify-content property with the value flex-start.

You can try running the following code to implement the flex-start value

Example

Live demonstration

<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: red;
            justify-content: flex-start;
         }
         .mycontainer > div {
            background-color: orange;
            text-align: center;
            line-height: 60px;
            font-size: 30px;
            width: 100px;
            margin: 5px;
         }
      </style>
    </head>
   <body>
      <h1>Result</h1>
      <div class = "mycontainer">
         <div>Rank1</div>
         <div>Rank2</div>
         <div>Rank3</div>
         <div>Rank4</div>
      </div>
   </body>
</html>
Copy after login

The above is the detailed content of Align Flex items at the beginning of a container using CSS. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!