1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.container {
position: relative;
text-align: center;
color: white;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: black;
font-size: 20px;
font-weight: bold;
background: white;
border-radius: 12px;
padding: 10px 20px;
}
body{
font-family: arial;
background: #eee;}
</style>
</head>
<body>
<h2>Centered Text on Image</h2>
<p>html css code on How to place text over an image:</p>
<div class="container">
<img src="https://unsplash.it/400/200" alt="Snow" style="width:100%;">
<div class="centered">Centered text on image</div>
</div>
</body>
</html>
|
Post a Comment