HTMLとCSSを使用して画像の上にテキストを配置するにはどうすればよいですか?
以下は、HTMLとCSSを使用して画像上にテキストを配置するためのコードです-
例
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
h1{
text-align: center;
}
.imageContainer {
margin-left:36%;
display: inline-block;
position: relative;
text-align: center;
color: rgb(64, 11, 124);
}
.caption{
font-size: 25px;
font-weight: bolder;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.BL {
position: absolute;
bottom: 8px;
left: 16px;
}
.TL{
position: absolute;
top: 8px;
left: 16px;
}
.TR {
position: absolute;
top: 8px;
right: 16px;
}
.BR {
position: absolute;
bottom: 8px;
right: 16px;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<h1>Place text on image example</h1>
<div class="imageContainer">
<img src="https://i.picsum.photos/id/59/500/500.jpg">
<div class="caption BL">Bottom Left Text</div>
<div class="caption TL" >Top Left Text</div>
<div class="caption TR">Top Right Text</div>
<div class="caption BR">Bottom Right Text</div>
<div class="caption center">Centered Text</div>
</div>
</body>
</html> 出力
上記のコードは次の出力を生成します-
-
HTMLとCSSを使用してサインアップフォームを作成するにはどうすればよいですか?
以下は、HTMLとCSSを使用してサインアップフォームを作成するためのコードです- 例 <!DOCTYPE html> <html> <head> <style> body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } * {box-sizing: border-box} input[type=text], input[type=password] { width: 100%; &n
-
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