+ 3

Border-Bottom Hover Effect

Why is my hover effect from right to left not working? https://code.sololearn.com/WC6KO5NuHKRI/#

9th Apr 2022, 1:57 PM
Junior
Junior - avatar
20 Answers
0
if there is no relative element in the container elements it will go after the body, and all absolute ones will stack on each other, and for more specify, it is the "li" which has relative position, and the green bars ::after are called pseudo elements, those ones who have the absolute value
9th Apr 2022, 9:47 PM
Mohamed Ayaou
+ 4
Change your name if you want people to help https://code.sololearn.com/W0t42PCvG9Bd/?ref=app do not use animation for hover, insted use transition and do not give ids to many similar items and border bottom width depends on its element width so on hover you change the width of all the element from 100% to 100% so you need another element, and this is pseudo element by ::after kryword
9th Apr 2022, 3:51 PM
Mohamed Ayaou
+ 2
show us your code
9th Apr 2022, 1:59 PM
SoloProg
SoloProg - avatar
+ 1
It seems to work, a lime border appears under the hovered element, what's wrong?
9th Apr 2022, 2:16 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
0
Read the code, i want it to be animated so when you hovee the border comes from the left to right (not right to left)
9th Apr 2022, 2:17 PM
Junior
Junior - avatar
0
Mohamed Ayaou thank u, one question, I know what position relative and absolute do in general but i dont get the meaning of it here. When i get rid of that position relative in line 24 my li::after does not work or works in a strange way. do u know the reasoning behind this?
9th Apr 2022, 5:18 PM
Junior
Junior - avatar
0
the element with position absolute needs its container to has position relative to let top and right,bottom,left properties work and the the absolute posotion lets you move the element as you want, if you remove it the pseudo element will come after the text
9th Apr 2022, 5:20 PM
Mohamed Ayaou
0
I looked it up and understand it a but better, but what does that have to do with it “seprating” my li::after?
9th Apr 2022, 5:28 PM
Junior
Junior - avatar
0
?? I didn't understand your question.
9th Apr 2022, 5:31 PM
Mohamed Ayaou
0
Im not to sure how to explain it but go to yoir code nowand at line 24 get rid of the position relative and press run and youll get what i mean
9th Apr 2022, 5:35 PM
Junior
Junior - avatar
0
Oh, that since li::after element have positions absolute for moving them to the bottom of its elements, and to stuck with its elements the it needs to be relative to hold the absolute elements relative: makes the element movabel by top,left,.. etc properties, but it will move from its normal place absolute: makes the element completly free from its original place and also can be moved by the same ways, but after it got free from its place it will fly to the nearest relative element in the html code so I make the word a relative and no other changes, the I create pseudo element that will come after the word and I make it free by "absolute" to fly out of that place and it will go to the top and left of the word since it is relativ element, then I move it to the bottom by "bottom:100%"
9th Apr 2022, 7:53 PM
Mohamed Ayaou
0
Okay, but why have a position: relative; in line 24 when theres no top,left,bottom, or right involved?
9th Apr 2022, 7:57 PM
Junior
Junior - avatar
0
you need it to make the absolute ones stick with tye relative ones, so when you remove it all the absolute elements will lose thier placese and go after the div
9th Apr 2022, 8:23 PM
Mohamed Ayaou
0
What if i get rid of the div? Then what does the absolute go after?
9th Apr 2022, 8:24 PM
Junior
Junior - avatar
0
I get it
9th Apr 2022, 10:12 PM
Junior
Junior - avatar
0
Oh ye, i dont think i aksed about this, but what about word spacing it dont work Mohamed Ayaou
9th Apr 2022, 11:51 PM
Junior
Junior - avatar
0
Mohamed Ayaou Do u mind also helping me with my word-spacing, I think its not working cause of my display but im not sure
10th Apr 2022, 3:52 PM
Junior
Junior - avatar
0
What do mean by that? space between words verticaly can be done by adding margin-bottom to the li itself.
10th Apr 2022, 7:41 PM
Mohamed Ayaou
0
I want my HOME ABOUT SERVICE CONTACT to not be jammed together i want it to have more space so it is like HOME ABOUT SERVICE CONTACT, you can look up word-spacing on w3schools
10th Apr 2022, 7:50 PM
Junior
Junior - avatar
0
Oh, I'm using sololearn from mobile so they are apuon each other, for tgat just add margin left to the li
10th Apr 2022, 8:08 PM
Mohamed Ayaou