JSFiddle - React, Tailwind, and code Playground
by Venkatesh Dematti
HTML
<a href="https://example.com/survey" id="feedback-box" class="feedback-box" target="_blank" aria-label="Give feedback">
<span id="close-btn" class="close-btn">×</span>
<div class="cta">
<img src="icon.png" alt="Feedback Icon" class="icon">
<span class="text">Your feedback is important!</span>
</div>
</a>
CSS
/* Basic styling for the feedback box */
.feedback-box {
position: fixed;
right: 0;
bottom: 0;
padding: 10px;
background-color: #ffffff;
box-shadow: 0 0 10px rgba(0,0,0,0.2);
border-radius: 5px;
/* Hidden by default */
z-index: 1000;
text-decoration: none; /* Remove default link underline */
}
/* Display feedback box when scrolled past top third */
.feedback-box.active {
display: block;
}
.feedback-box .cta {
display: flex;
align-items: center;
}
.feedback-box .cta .icon {
margin-right: 10px;
}
.feedback-box .cta .text {
font-size: 14px;
color: #007bff;
}
/* The close button 'X' */
.feedback-box .close-btn {
display: none;
position: absolute;
top: 10px;
right: 10px;
cursor: pointer;
color: #333;
}
/* Show 'X' on hover */
.feedback-box:hover .close-btn {
display: block;
}
/* Responsive design */
@media (max-width: 768px) {
.feedback-box {
bottom: 250px; /* 250px distance on mobile */
}
}
@media (min-width: 769px) {
.feedback-box {
bottom: 350px; /* 350px distance on desktop */
}
}