JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Double Click Selection Demo</title>
<style>
body {
font-family: system-ui, -apple-system, sans-serif;
display: flex;
justify-content: center;
padding-top: 50px;
background-color: #ffffff;
}
/* The Scrollable Container */
.scrollable-container {
width: 400px;
height: 300px;
overflow-y: auto;
/* Visualizing the container bounds */
border: 4px solid #333333;
background-color: #e2e8f0; /* Gray background to show empty space */
/* Creating the empty space you want to click on */
padding: 50px;
}
/* The Paragraph Elements */
.scrollable-container p {
/* Visualizing the paragraph bounds */
border: 2px dashed #2563eb;
background-color: #eff6ff;
padding: 15px;
margin: 0 0 20px 0;
line-height: 1.6;
color: #1e293b;
}
/* Just to make the instructions stand out */
.instructions {
position: absolute;
top: 10px;
text-align: center;
color: #64748b;
}
</style>
</head>
<body>
<div class="instructions">
Double-click the <strong>gray area (padding)</strong> inside the dark box.
</div>
<div class="scrollable-container">
<p>This is the first paragraph. Double-click exactly on a word here to select it. Or, try double-clicking in the gray area outside this dashed box.</p>
<p>This is the second paragraph. The gray area surrounding these blue boxes is the padding of the scrollable container. Notice how wide the...