As a newcomer to CSS, I am exploring ways to change the font size and color of a specific word in my sentence after an animation. My initial attempt was to enclose the word within a span class like this:
<h2>I'm <span style = "font-size: 20px; color: red">available</span> for work</h2></span>
I also tried creating a class in my CSS file to achieve the desired effect:
.my-class {
font-size: 20px;
color: red;
}
Unfortunately, neither of these methods seemed to produce any results. How can I modify the size and color of a single word using CSS?
/* Global Variables */
:root {
--main-bg-color: #DDD0C8;
--secondary-bg-color: #323232;
}
* {
box-sizing: border-box;
line-height: 1.5em;
padding: 0;
margin: 0;
}
html {
font-size: var(--main-font-size);
scroll-behavior: smooth;
}
body {
margin: 0;
background-color: beige;
}
/*---CONTACT SECTION---*/
.contact-container {
background-color: darkgray;
padding-top: 10px;
text-align: center;
}
.contact-text h2 {
font-weight: 700;
text-align: center;
font-size: 20px;
font-family: 'Poppins', sans-serif;
}
.contact-text p {
font-weight: 700;
text-align: center;
font-size: var(--main-font-size);
font-family: 'Poppins', sans-serif;
}
.shine_animation {
background: linear-gradient(90deg, #000, #fff, #000);
letter-spacing: 5px;
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
background-repeat: no-repeat;
background-size: 80%;
animation: shine 5s linear infinite;
animation-fill-mode: forwards;
animation-iteration-count: 1;
position: relative;
}
@keyframes shine {
0% {
background-position-x: -500%;
}
100% {
background-position-x: 500%;
background-color: var(--main-bg-color);
}
}
<!DOCTYPE html>
<html lang="en">
<!-- Head -->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Cedarville+Cursive&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="animate.css">
</head>
<body>
<!-- Contact Section -->
<div class="contact-container">
<div class="contact-text" , id="contact">
<h2>I'm <span style = "font-size: 20px; color: red">available</span> for work</h2>
</span>
<span><p>Get in touch with me today.</p></span>
</div>
</div>
</body>
</html>