CSSを使用して画像の中央にテキストを配置する方法
画像を中央に配置するためにテキストを配置するには、CSSのtransformプロパティを使用します。画像の中央に配置されたテキストに対して次のコードを実行してみてください
例
<!DOCTYPE html>
<html>
<head>
<style>
.container {
position: relative;
}
.topleft {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 18px;
}
img {
width: 100%;
height: auto;
opacity: 0.3;
}
</style>
</head>
<body>
<h2>Image Text</h2>
<p>Add some text to an image in the center of an image:</p>
<div class = "container">
<img src = "trolltunga.jpg" alt = "Norway" width = "1000" height = "300">
<div class = "topleft">Center</div>
</div>
</body>
</html> -
CSSでテキストボタンのスタイルを設定するにはどうすればよいですか?
以下は、CSSでテキストボタンのスタイルを設定するコードです- 例 <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> button { border: none; color: white; font-weight: bolder; &nb
-
CSSで光るテキストを作成するにはどうすればよいですか?
CSSを使用して光るテキストを作成するためのコードは、次のとおりです- 例 <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body { background-color: rgb(0, 0, 0); font-family