AIで画像の上に文字を表示させる html と css を作る※chatGPTと語る
AIで画像の上に文字を表示させる html と css を作ったときに、chatGPTをどう使っているかをお見せします。
基本chatGPTは、
すぐ忘れる。
すぐさぼる。
やったふりする。
怒られないように嘘をつく。
ほぼ公務員wwwww
です。そこをどう言って働いてもらうか考えながらやり取りするのが chatGPTを使ううえで面白いところです。
実際の業務に使うときは、別の言い方をしますが、小さいもので「楽しみながら」仕事をさせるときは、こういう対話形式が楽で楽しいです。
以下のやり取りでは、1度はイメージに近い門を出してきたのですが、最終的には、「画像の上に文字を乗せる」を最後まで覚えておいてくれなくて、結局手作業で合体させました。
それもありです、AIはまだまだ過渡期です。ですが、じわじわと成長するのではなく2030には、ぶっ飛びます。
だとしても、AIは2週間と同じ状態にない超進化中です。
実際「???を教えてください」の1行会話ではなく、対話をしてみてください。
ChatGPT:以下のHTMLとCSSを使用すれば、画像の右下に「画像はイメージです」というテキストを表示できます。
html
ChatGPT:画像の上に「画像はイメージです」というテキストを表示するHTMLとCSSは以下の通りです。
html
ChatGPT:画像に「画像はイメージです」のテキストを重ねて表示するHTMLとCSSを作成しました。
html
ChatGPT:画像の右下に「画像はイメージです」というテキストを小さく表示し、背景色なしで重ねるHTMLとCSSを作成しました。
html
でも、その自分に落とし込むという作業は、短文今後なくなっていくんだろうなと思っています。
chatGPTは、AIの機能をチャット(双方向会話)で使うものという意味です。
基本chatGPTは、
すぐ忘れる。
すぐさぼる。
やったふりする。
怒られないように嘘をつく。
です。そこをどう言って働いてもらうか考えながらやり取りするのが chatGPTを使ううえで面白いところです。
実際の業務に使うときは、別の言い方をしますが、小さいもので「楽しみながら」仕事をさせるときは、こういう対話形式が楽で楽しいです。
以下のやり取りでは、1度はイメージに近い門を出してきたのですが、最終的には、「画像の上に文字を乗せる」を最後まで覚えておいてくれなくて、結局手作業で合体させました。
それもありです、AIはまだまだ過渡期です。ですが、じわじわと成長するのではなく2030には、ぶっ飛びます。
だとしても、AIは2週間と同じ状態にない超進化中です。
実際「???を教えてください」の1行会話ではなく、対話をしてみてください。
AIで画像の上に文字を表示させる html と css を作る※chatGPTと語る
あなたはプロのHTMLコーダーです。画像の右下に「画像はイメージです」の文字を表示するHTMLとStyleを作ってください。
ChatGPT:以下のHTMLとCSSを使用すれば、画像の右下に「画像はイメージです」というテキストを表示できます。
html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>画像の右下にテキストを表示</title>
<style>
.image-container {
position: relative;
display: inline-block;
}.image-container img {
display: block;
max-width: 100%;
height: auto;
}.image-container .caption {
position: absolute;
bottom: 5px;
right: 5px;
background: rgba(0, 0, 0, 0.6);
color: white;
padding: 5px 10px;
font-size: 12px;
border-radius: 3px;
}</style>
</head>
<body><div class="image-container">
<img src="sample.jpg" alt="サンプル画像">
<div class="caption">画像はイメージです</div>
</div></body>
</html>
説明<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>画像の右下にテキストを表示</title>
<style>
.image-container {
position: relative;
display: inline-block;
}.image-container img {
display: block;
max-width: 100%;
height: auto;
}.image-container .caption {
position: absolute;
bottom: 5px;
right: 5px;
background: rgba(0, 0, 0, 0.6);
color: white;
padding: 5px 10px;
font-size: 12px;
border-radius: 3px;
}</style>
</head>
<body><div class="image-container">
<img src="sample.jpg" alt="サンプル画像">
<div class="caption">画像はイメージです</div>
</div></body>
</html>
- .image-container で画像を囲み、相対配置(position: relative;)を設定
- .caption に position: absolute; bottom: 5px; right: 5px; を適用し、画像の右下に配置
- 背景に半透明の黒(rgba(0, 0, 0, 0.6);)を適用し、視認性を向上
- 角丸(border-radius: 3px;)を追加してデザインを柔らかく
あなた:画像の上に文字を表示してください。
ChatGPT:画像の上に「画像はイメージです」というテキストを表示するHTMLとCSSは以下の通りです。
html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>画像の上にテキストを表示</title>
<style>
.image-container {
position: relative;
display: inline-block;
}.image-container img {
display: block;
max-width: 100%;
height: auto;
}.image-container .caption {
position: absolute;
top: 5px;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.6);
color: white;
padding: 5px 10px;
font-size: 12px;
border-radius: 3px;
white-space: nowrap;
}</style>
</head>
<body><div class="image-container">
<img src="sample.jpg" alt="サンプル画像">
<div class="caption">画像はイメージです</div>
</div></body>
</html>
ポイント<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>画像の上にテキストを表示</title>
<style>
.image-container {
position: relative;
display: inline-block;
}.image-container img {
display: block;
max-width: 100%;
height: auto;
}.image-container .caption {
position: absolute;
top: 5px;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.6);
color: white;
padding: 5px 10px;
font-size: 12px;
border-radius: 3px;
white-space: nowrap;
}</style>
</head>
<body><div class="image-container">
<img src="sample.jpg" alt="サンプル画像">
<div class="caption">画像はイメージです</div>
</div></body>
</html>
- .caption に position: absolute; top: 5px; を指定し、画像の上部に配置
- left: 50%; transform: translateX(-50%); で中央揃え
- background: rgba(0, 0, 0, 0.6); で半透明の黒背景を適用し、文字を読みやすく
- white-space: nowrap; を設定し、1行で表示
あなた:画像に重ねてください
ChatGPT:画像に「画像はイメージです」のテキストを重ねて表示するHTMLとCSSを作成しました。
html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>画像にテキストを重ねる</title>
<style>
.image-container {
position: relative;
display: inline-block;
}.image-container img {
display: block;
max-width: 100%;
height: auto;
}.image-container .caption {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(0, 0, 0, 0.5);
color: white;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
font-weight: bold;
text-align: center;
}</style>
</head>
<body><div class="image-container">
<img src="sample.jpg" alt="サンプル画像">
<div class="caption">画像はイメージです</div>
</div></body>
</html>
ポイント<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>画像にテキストを重ねる</title>
<style>
.image-container {
position: relative;
display: inline-block;
}.image-container img {
display: block;
max-width: 100%;
height: auto;
}.image-container .caption {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(0, 0, 0, 0.5);
color: white;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
font-weight: bold;
text-align: center;
}</style>
</head>
<body><div class="image-container">
<img src="sample.jpg" alt="サンプル画像">
<div class="caption">画像はイメージです</div>
</div></body>
</html>
- .caption に position: absolute; を適用し、画像に重ねる
- top: 50%; left: 50%; transform: translate(-50%, -50%); で画像の中央に配置
- background: rgba(0, 0, 0, 0.5); で背景を半透明にし、視認性を向上
- padding: 10px 20px; で余白を確保し、文字を見やすく
- font-weight: bold; で文字を強調
あなた:右下です。文字サイズを小さく、文字エリアの背景色はないで。←画像の上だけど中央に出るようにされた。
ChatGPT:画像の右下に「画像はイメージです」というテキストを小さく表示し、背景色なしで重ねるHTMLとCSSを作成しました。
html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>画像右下にテキストを重ねる</title>
<style>
.image-container {
position: relative;
display: inline-block;
}.image-container img {
display: block;
max-width: 100%;
height: auto;
}.image-container .caption {
position: absolute;
bottom: 5px;
right: 5px;
color: white;
font-size: 12px;
font-weight: bold;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}</style>
</head>
<body><div class="image-container">
<img src="sample.jpg" alt="サンプル画像">
<div class="caption">画像はイメージです</div>
</div></body>
</html>
ポイント<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>画像右下にテキストを重ねる</title>
<style>
.image-container {
position: relative;
display: inline-block;
}.image-container img {
display: block;
max-width: 100%;
height: auto;
}.image-container .caption {
position: absolute;
bottom: 5px;
right: 5px;
color: white;
font-size: 12px;
font-weight: bold;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}</style>
</head>
<body><div class="image-container">
<img src="sample.jpg" alt="サンプル画像">
<div class="caption">画像はイメージです</div>
</div></body>
</html>
- .caption に position: absolute; bottom: 5px; right: 5px; を設定し、右下に配置
- font-size: 12px; で文字サイズを小さく
- color: white; で文字を白に設定し、背景を透過
- text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8); で黒い影をつけ、背景が明るくても視認性を確保
あ、これまた画像の上に乗っけられるようにするまでには時間かかりそうだ、乗っける方法はわかったから打ち切って自分で直そう。
と思った。chatGPTは、一度間違いだすと元に戻すまですごく大変です。案外思い込みが減げしく頑固。さらに物忘れが激しくなる。言ったことを端折るなどろくなことにならないので、その場合会話を切ってやり直すのが正解。
と思った。chatGPTは、一度間違いだすと元に戻すまですごく大変です。案外思い込みが減げしく頑固。さらに物忘れが激しくなる。言ったことを端折るなどろくなことにならないので、その場合会話を切ってやり直すのが正解。
まとめ
ちょっとしたものを聞きたいとき、概念を聞いて自分の落とし込み何かをする・・・というのが普通の考え方です。でも、その自分に落とし込むという作業は、短文今後なくなっていくんだろうなと思っています。
chatGPTは、AIの機能をチャット(双方向会話)で使うものという意味です。