In this video, we will create an awesome text effect CSS only. This video on how to clip image on text using -webkit-background-clip. For a preview click on Demo If you want to get the complete source code in a zip file then click the "Fork me on GitHub" button below that will redirect you to my GitHub account where you found all my source code files. Copy Code(select code part and copy using "CTRL + C" or using R Click to mouse)🡇 HTML <! DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < meta http-equiv = "X-UA-Compatible" content = "IE=edge" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title >How to clip image on text</ title > <!-- style.css --> < link rel = "stylesheet" href = "style.css" > </ head > < body >
In this video, we will create a copy-paste functionality using HTML, CSS, and vanilla JavaScript.
You can create this mini-project easily with JavaScript. A simple and easy project for beginner's help.
If you want to get the complete source code in a zip file then click the "Fork me on GitHub" button below that will redirect you to my GitHub account where you found all my source code files.
Copy Code(select code part and copy using "CTRL + C" or using R Click to mouse)🡇
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- fontawesome cdn -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous" />
<!-- css -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrapper">
<div>
<textarea name="" id="copy" cols="32" rows="1" placeholder="Enter text you want to copy"></textarea>
<span id="copied">Copied</span>
<button id="btn">
<i class="far fa-copy"></i>
</button>
</div>
<textarea name="" cols="40" rows="2" placeholder="Enter text you want to paste"></textarea>
</div>
<!-- JavaScript -->
<script src="main.js"></script>
</body>
</html>
CSS
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@600&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
outline: none;
border: none;
font-family: 'Raleway', sans-serif;
transition: 0.4s;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-image: url(wallpaper2you_418284.jpg);
background-size: cover;
}
.wrapper {
position: relative;
}
.wrapper>div {
display: flex;
justify-content: space-between;
margin-bottom: 5px;
}
textarea {
padding: 10px;
margin: 5px 0;
font-size: 1.5em;
resize: none;
border: 5px solid #ffffff60;
border-radius: 10px;
background-color: #ffffff3d;
color: #3d3282;
}
textarea::placeholder {
opacity: .7;
color: #3d3282;
}
button {
padding: 10px 25px;
margin: 5px 0;
background-color: #ffffff3d;
border: 5px solid #ffffff60;
border-radius: 10px;
font-size: 2em;
cursor: pointer;
transition: .4s ease-in-out;
color: #3d3282;
}
button:active {
transform: scale(.9);
}
span {
position: absolute;
top: -40px;
right: 3px;
font-size: 1em;
background-color: #fff;
color: #3d3282;
padding: 10px 15px;
border-radius: 10px;
opacity: 0;
transition: .5s ease-in-out;
}
span::before {
content: '';
position: absolute;
width: 15px;
height: 15px;
background-color: #fff;
bottom: -5px;
left: 43%;
transform: rotate(45deg);
}
JavaScript
var copied = document.getElementById("copied");
var btn = document.getElementById("btn");
btn.addEventListener("click", () => {
var copy = document.getElementById("copy");
copy.select();
copy.setSelectionRange(0, 99999);
document.execCommand("copy");
copied.style.top = "-55px"
copied.style.opacity = "1"
setTimeout(() => {
copied.style.top = "-40px"
copied.style.opacity = "0"
}, 1000);
});
Fork me on GitHub
Subscribe to me on YouTube
Like & Comment on my video on YouTube & press the bell icon to get notification first.
Follow me on Instagram
Comment down any query if you have.
Comments
Post a Comment
If you have any doubts please let me know.