Click here to Skip to main content
15,435,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I change my button-tag wich has a css animation to it into a a-tag some parts of the css stopped working... I made only use of a class, so I don't know what the issue can cost.
ASP.NET
<--HTML-->
<a class="btnNavigator2" role="button" data-target="#LoginModal" data-toggle="modal" runat="server">Login</a>

C#
<--CSS-->
.btnNavigator2 {
    border: 1px solid #f24646;
    background: none;
    padding: 10px 20px;
    font-size: 20px;
    font-family: Consolas;
    cursor: pointer;
    transition: 0.8s;
    color: #fff;
    position: relative;
    overflow: hidden;
    margin: 5px;
}

.btnNavigator2:hover {
    color: #f24646;
}

.btnNavigator2::before {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 0%;
    background: #f24646;
    z-index: -1;
    transition: 0.8s;
    bottom: 0;
    height: 180%;
}

.btnNavigator2:hover::before {
    height: 0%;
}

What it should do:
https://gyazo.com/786a2d9545a0aa25b564d641a7a9e248[^]

What it does:
https://gyazo.com/bd857bf8f31bb15106647d14ad41480a[^]

What I have tried:

I tried to check if every class is named correct...
Posted
Updated 22-Jul-19 9:37am
v5
Comments
Anurag Gandhi 21-Jul-19 2:32am    
Just check if it overlaps with another css applied on 'a' tag. If yes, then you need to fix it by providing more precedence to applied class.

Clear your browser's cache. It happens to me quite frequently.
 
Share this answer
 
There is nothing wrong with your CSS or HTML, that I can think of, because you are using the class name and not element selector. Before you try what Solution 2 says (which is one step beyond my solution) try CTRL and F5, that will perform a hard refresh on the page and load everything from scratch. This will be an automatic process and your browser will reload everything and apply.

Try this code here on the JSFiddle, Edit fiddle - JSFiddle[^], works just fine. :-)

If this doesn't work, then a good answer can be found in the browser debug consoles. You can try using the Inspect Element option and see which styles are being applied and where they are coming from. F12 will bring the options up, hover over the element and preview the styles being applied. Google Chrome will even show the file and the line number from where a specific style is coming from.
 
Share this answer
 
v4
I can't see your screen-shots, but pasting your HTML and CSS into a new JSFiddle reveals the problem:
Edit fiddle - JSFiddle[^]

The ::before is not being constrained to the dimensions of the <a> element, whereas it is being constrained on the <button> element.

The cause is fairly simple: the <a> element is set to display:inline;, whereas the <button> element is set to display:inline-block;. Explicitly setting the display property on your btnNavigator2 rule resolves the issue:
Edit fiddle - JSFiddle[^]
CSS
.btnNavigator2 {
    ...
    display: inline-block;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900