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?

k.k.FactoryAdvent Calendar 2024

Day 23

CSSを学びたい Step23 三角関数を利用する

Posted at

はじめに

CSSを学びたいのStep23です。今回は三角関数のsin,cosを学んでいきます。
※CSSって三角関数使えたんですね。。知らんかった😅

成果物

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>CSSで三角関数を使用する例</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <h2>CSSで三角関数を使用する例</h2>
  <div class="circle-container">
    <div class="circle"></div>
  </div>
</body>
</html>
styles.css
body {
  font-family: Arial, sans-serif;
  background-color: #f4f4f4;
  margin: 0;
  padding: 20px;
}

h2 {
  text-align: center;
  color: #333;
}

.circle-container {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
  background-color: #ddd;
  border-radius: 50%;
}

.circle {
  position: absolute;
  width: 20px;
  height: 20px;
  background-color: #007BFF;
  border-radius: 50%;
  top: calc(50% - 10px); /* 中心に配置 */
  left: calc(50% - 10px); /* 中心に配置 */
  transform: translate(calc(100px * cos(45deg)), calc(100px * sin(45deg)));
}
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?