Page 212 - Computer Software Application TP - Volume 1
P. 212
COMPUTER SOFTWARE APPLICATION - CITS
TASK 3: Using Tooltips
1 Create a Bootstrap 5 Tooltips
• Open the text editor
• Write the following codes
<html lang=”en”>
<head>
<title>Bootstrap Example</title>
<meta charset=”utf-8”>
<meta name=”viewport” content=”width=device-width, initial-scale=1”>
<link href=https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css rel=”stylesheet”>
<script src=”https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js”></script>
</head>
<body>
<div class=”container mt-3”>
<h3>Tooltip Positioning</h3>
<p>The data-bs-placement attribute specifies the tooltip position.</p>
<a href=”#” data-bs-toggle=”tooltip” data-bs-placement=”top” title=”Hooray!”>Top</a>
<a href=”#” data-bs-toggle=”tooltip” data-bs-placement=”bottom” title=”Hooray!”>Bottom</a>
<a href=”#” data-bs-toggle=”tooltip” data-bs-placement=”left” title=”Hooray!”>Left</a>
<a href=”#” data-bs-toggle=”tooltip” data-bs-placement=”right” title=”Hooray!”>Right</a>
</div>
<script>
var tooltipTriggerList = [].slice.call(document.querySelectorAll(‘[data-bs-toggle=”tooltip”]’))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
</script>
</body>
</html>
• Save the program as a .html file
• Open the html file with a web browser
• Verify the output.
197
CITS : IT & ITES - Computer Software Application - Exercise 48