1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CSSを学びたい Step24 flexbox-order

Posted at

はじめに

CSSを学びたいのStep24です。FlexBoxのorderについて学んでいきます!!

成果物

image.png

ソースコード

index.html
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Flexbox Orderの例</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <h2>Flexbox Orderの例</h2>
  <div class="flex-container">
    <div class="flex-item" style="order: 3;">アイテム1</div>
    <div class="flex-item" style="order: 1;">アイテム2</div>
    <div class="flex-item" style="order: 2;">アイテム3</div>
  </div>
</body>
</html>
styles.css
body {
  font-family: Arial, sans-serif;
  background-color: #f4f4f4;
  margin: 0;
  padding: 20px;
  text-align: center;
}

h2 {
  margin-bottom: 20px;
}

.flex-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  background-color: #ddd;
  padding: 20px;
  border-radius: 10px;
}

.flex-item {
  background-color: #007BFF;
  color: #fff;
  padding: 20px;
  border-radius: 5px;
  flex: 1;
  text-align: center;
}

htmlの記載順でなく、orderで定義した順番に適用されるようになりましたね!!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?