How TO – Text Blocks Over Image


Previous


Next

Learn how to place text blocks over an image.





Image Text Blocks

How to place text blocks over an image:

Nature

Nature

What a beautiful sunrise


Example

<!DOCTYPE html>
<html>
<head>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<style>
.container {
position: relative;
font-family: Arial;
}

.text-block {
position: absolute;
bottom: 20px;
right: 20px;
background-color: black;
color: white;
padding-left: 20px;
padding-right: 20px;
}
</style>
</head>
<body>

<h2>Image Text Blocks</h2>
<p>How to place text blocks over an image:</p>

<div>
<img src=”img_nature_wide.jpg” alt=”Nature” style=”width:100%;”>
<div>
<h4>Nature</h4>
<p>What a beautiful sunrise</p>
</div>
</div>

</body>
</html>

How To Place Text Blocks in Image

Step 1) Add HTML:

 

Example

<div class=”container”>
  <img src=”nature.jpg” alt=”Norway” style=”width:100%;”>
  <div class=”text-block”>
    <h4>Nature</h4>
    <p>What a beautiful sunrise</p>
  </div>
</div>

Step 2) Add CSS:

 

Example

<!DOCTYPE html>
<html>
<head>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<style>
.container {
position: relative;
font-family: Arial;
}

.text-block {
position: absolute;
bottom: 20px;
right: 20px;
background-color: black;
color: white;
padding-left: 20px;
padding-right: 20px;
}
</style>
</head>
<body>

<h2>Image Text Blocks</h2>
<p>How to place text blocks over an image:</p>

<div>
<img src=”img_nature_wide.jpg” alt=”Nature” style=”width:100%;”>
<div>
<h4>Nature</h4>
<p>What a beautiful sunrise</p>
</div>
</div>

</body>
</html>


Previous


Next

Scroll to Top