CSS Transform Effects
- In the CSS, the transform effects allow you to manipulate elements in 2D or 3D space. You can rotate, scale, skew, or translate elements using the transform property. Transforms are often used in combination with transitions or animations to create engaging visual effects.
- It can be used to
- Rotate an element to create a 3D effect.
- Make an element large or small to create a zoom effect.
- Translate an element to move it around the page.
Example: Implementation of Tooltip with Transformation Effect
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>ToolTip CSS Transition Effects</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>w3wiki</h1>
<button class="tooltip-trigger">
Hover me for a tooltip
</button>
<span class="tooltip-content">
CSS Transform: Tooltip
</span>
</div>
</body>
</html>
h1 {
color: green;
text-align: center;
margin-top: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
position: relative;
text-align: center;
}
.tooltip-trigger {
cursor: pointer;
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 4px;
}
.tooltip-trigger:hover {
background-color: #0056b3;
}
.tooltip-content {
visibility: hidden;
opacity: 0;
position: absolute;
top: calc(100% + 10px);
left: 50%;
transform: translate(-50%, 10px) scale(0.8);
transition: transform 0.3s ease, opacity 0.3s ease;
background-color: #bd2323;
color: #fff;
padding: 8px;
border-radius: 4px;
white-space: nowrap;
}
.container:hover .tooltip-content {
visibility: visible;
opacity: 1;
transform: translate(-50%, 0);
}
Output:
How to Add Effects to Tooltips ?
Tooltips are small informational pop-ups that appear when users hover over or interact with certain elements, providing additional context or explanations.
Below are the approaches to add Effects to tooltips using CSS:
Table of Content
- CSS Transition Effects
- CSS Animation Effects
- CSS Transform Effects