I've been struggling with this issue for quite some time now. Despite scouring the first page of Google search results for "css change text on hover," I have not been able to find a solution.
Inside a div, I have text that is styled and positioned using its own inner div. What I want to achieve is changing the text when hovering over the containing div using CSS.
I tried implementing the content/:before/:after method as per some guides I found, but it only added to my confusion.
The current code performs its job well in creating circles in the services section:
.servicecircle {
width: 204px;
height: 204px;
background-image: url('/anonymous/for/reasons.png');
display: inline-block;
background-repeat: no-repeat;
margin-left: 22px;
margin-right: 22px;
/* Button transition*/
-o-transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
transition:.5s;
}
.servicecircle:hover{
background-image: url('/anonymous/for/reasons.png');
cursor: pointer;
}
I did manage to change the text with the following code, but it messed up the alignment of the divs. Unfortunately, I couldn't find a way to style the text within the content.
.servicecircle:after {
width: 204px;
height: 204px;
background-image: url('/anonymous/for/reasons.png');
display: inline-block;
background-repeat: no-repeat;
margin-left: 22px;
margin-right: 22px;
/* Button transition*/
-o-transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
transition:.5s;
/* Content is inserted */
content: 'Service 1';
}
.servicecircle:hover:after{
background-image: url('/anonymous/for/reasons.png');
cursor: pointer;
content: 'Service Description..';
}
This entire setup is contained within:
<div class="servicecircle">
</div>
Is what I'm trying to achieve possible with CSS?
P.S. If you could provide a link to a clear guide on this topic, it would be greatly appreciated. As someone still new to CSS, I may be venturing into advanced territory with this challenge. The existing guides are using unfamiliar code language for me.