how to add hover effect to button using css - html

i'm trying to add hover effect to my menu.This is my html
<div class="nav-top-menu nav-top">
<span class="menu-icons">
<button class="menu-button hoverEfect">
<i class="fa fa-cog fa-2x"></i>
<span class="menu-icons-text" id="userName">Enhanzer(pvt)ltd</span>
</button>
</span>
</div>
i just want to change color when mouse over.This is css that i tried
.nav-top-menu .hoverEfect button:hover
{
color: #65b4d7;
}
can anyone help me to do this. i don't want to use javascript or jquery

Change this:
.nav-top-menu .hoverEfect button:hover
To this:
.nav-top-menu .hoverEfect:hover
As .hoverEffect is itself a button
You may also use:
.nav-top-menu button.hoverEfect:hover
{
color: #65b4d7;
}

spaces in css chain to children. as such you will need to adjust your css to the following:
.nav-top-menu button.hoverEfect:hover
{
color: #65b4d7;
}

.nav-top-menu .hoverEfect button:hover
{
background-color: #65b4d7;
}
you need to change back ground color for the effect or change the font color etc.

Related

Change Bootstrap icon color

I print this icon into a table using php code like this:
echo '<button Onclick="" style="border: none; background: none; color:green"><a title="Reenviar" data-toggle="tooltip"><i class="material-icons"></i></a></button>';
And I'd ike to change the icon's color. I tried to add the color to the button style; however it does not seem to work.
You should add style to i tag
<i style = "color:blue;" class="material-icons"></i>
also, you can create a css class
.blue {
color:blue
}
and then just add that class to a tag
<i class="material-icons blue"></i>
You have to add the styling to the icon itself if you are using inline styling.
<i style="color: #ff0000" class="material-icons"></i>
Better yet you can use some some css to make this cleaner and more manageable and do something in css like this
.material-icons {
color: #ff0000;
}
Checkout the css w3 schools code examples https://www.w3schools.com/css/

how to change color of icon of bootstrap icon?

How can I change the color of glyphicon? The current color is showing in black, I want to change it to white.
I have tried to do it as :
.glyphicon {
color: white;
}
<button class="nav-bar1"><span class="glyphicon glyphicon-cog"></span><p>Dashboard</p></button>
Also, I have cleaned my browser history but still it doesn't work, I am using Bootstrap-3.3.7. click here to see my html in browser.
You can also target the ::before component which is where the content is, like this:
.glyphicon::before {
color: white;
}
You can add !important after color to override it
Add :
.white-icon{
color:white !important;
}
.white-icon{
color:white !important;
}
<button class="nav-bar1"><span class="glyphicon white-icon glyphicon-cog"></span><p>Dashboard</p></button>
Hope this helps
<button class="nav-bar1"><span class="glyphicon glyphicon-cog" style="color: white;"></span><p>Dashboard</p></button>
The example above uses inline styling. The example below is what you should add into your stylesheet if you prefer that way.
.glyphicon glyphicon-cog{
color:white;
}
You can either add this directly to the style:
<span class="glyphicon glyphicon-cog" style="color:blue!important"></span>
Or you can add it as a class to your icon and then set the style color to it in CSS
HTML
<span class="glyphicon glyphicon-cog blue"></span>
CSS
.blue {
color: blue!important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<button class="nav-bar1"><span style="color:blue!important" class="glyphicon glyphicon-cog"></span><p>Dashboard</p></button>
.nav-bar1 .glyphicon{
color:blue !important;
}
That should do it.

Adding css style to button while popover is open. Remove it when it closes

Im trying to use an fa-cog as a button that opens a popover in AngularJS using Angular UI. I realise this is possible using js/jQuery, but I am looking for a css/html solution.
HTML:
<span
class="fa fa-cog fa-2x"
uib-popover-template="'popoverTemplate.html'"></span>
CSS:
fa.cog{
color: grey;
}
fa.cog:hover{
color: black;
}
//Doesn't work
fa.cog :active or :focus or :target etc.{
color: black
}
What I am trying to do is, when the popover is not showing, the cog should have the color grey. When the popover is open, the cog should be black.
I've tried css selectors like fa-cog:active and fa-cog:focus, but they didn't do much.
Unsure how i can achieve this, any ideas?
The popover directive has a helper attribute called tooltip-is-open, it provides you with a read-only variable that tell you if the popover is open or not.
Then you can use either ngClass or ngStyle to conditionally apply your css
<span class="fa fa-cog fa-2x"
uib-popover-template="'popoverTemplate.html'"
popover-is-open="iAmOpen"
ng-class="{'active': iAmOpen}">
</span>
this should work
fa.cog{
color: grey;
}
fa.cog:hover{
color: black;
}
fa.cog:active, fa.cog:focus{
color: grey;
}
you are setting black color when active or focused, not grey

Changing the colour of a button

I'm having problems in order to change the colour of this button. This is the code:
<div class = "Petrol">
<a href="PayMethod.php"><button class="btn btn-default btn-lg" type="button"><span class="Text">Petrol<br><small>(Hi-Grade)</small></span></button>
</a>
</div>
Can you please help me?
if you need to change the color of the button do this:
.btn {
background-color:blue;
}
if you need to change the text inside the color of the button
.btn {
color:red;
}
Assuming by the classes you used, I think you are using Bootstrap. Bootstrap provide pre-defined classes to change bg color of buttons. Replace btn-default by any of the following to get a different color. btn-primary, btn-success, btn-info, btn-warning, btn-danger, and btn-link.
Take a look at the docs.
You could also apply a custom class btn-custom and style it.
.btn-custom {
background: #ff0; /* use your color here */
}
Straightfoward way works fine
.btn {
color:blue;
}
Example

Can I change the color of Font Awesome's cog icon?

I have to wrap my icon within an <a> tag for some reason.
Is there any possible way to change the color of a font-awesome icon to black?
or is it impossible as long as it wrapped within an <a> tag? Font awesome is supposed to be font not image, right?
<i class="icon-cog"></i> Edit profile
This worked for me:
.icon-cog {
color: black;
}
For versions of Font Awesome above 4.7.0, it looks this:
.fa-cog {
color: black;
}
HTML:
<i class="icon-cog blackiconcolor">
css :
.blackiconcolor {color:black;}
you can also add extra class to the button icon...
You can specify the color in the style attribute:
<i class="icon-cog" style="color:black"></i> Edit profile
Try this:
<i class="icon-cog text-red">
<i class="icon-cog text-blue">
<i class="icon-cog text-yellow">
To change the font awesome icons color for your entire project use this in your css
.fa {
color : red;
}
If you don't want to alter the CSS file, this is what works for me. In HTML, add style with color:
<i class="fa fa-cog" style="color:#fff;"></i>
Is there any possible way to change the color of a font-awesome icon to
black?
Yes, there is. See the snipped bellow
<!-- Assuming that you don't have, this needs to be in your HTML file (usually the header) -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Here is what you need to use -->
Edit Profile
Font awesome is supposed to be font not image, right?
Yes, it is a font. Therefore, you are able to scale it to any size without losing quality.
To hit only cog-icons in that kind of button, you can give the button a class, and set the color for the icon only when inside the button.
HTML:
<a class="my-nice-button" href="/users/edit">
<i class="icon-cog"></i>
Edit profile
</a>
CSS:
.my-nice-button>i { color: black; }
This will make any icon that is a direct descendant of your button black.
With reference to #ClarkeyBoy answer, below code works fine, if using latest version of Font-Awesome icons or if you using fa classes
.fa.icon-white {
color: white;
}
And, then add icon-white to existing class
For me the only thing that worked is inline css + overriding
<i class="fas fa-ellipsis-v fa-2x" style="color:red !important"></i>
just give and text style whatever you want like :D
HTML:
<a href="javascript:;" class="fa fa-trash" style="color:#d9534f;">
<span style="color:black;">Text Name</span>
</a>
.fa-search{
color:#fff;
}
you write that code in css and it would change the color to white or any color you want, you specify it
You can change the Font Awesome's icon color with the bootstrap class
use
text-color
example
text-white
Sometimes changing the colour in the external css file doesn't work. You can add inline css property in the icon tag and that will work.
For example
<i class="fa-solid fa-keyboard" style="color: grey;"></i>
just give it the style whatever you want like
style="color: white;font-size: 20px;"
You can change the color of a fontawesome icon by changing its foreground color using the css color property. The following are examples:
<i class="fa fa-cog" style="color:white">
This supports svgs also
<style>
.fa-cog{
color:white;
}
</style>
<style>
.parent svg, .parent i{
color:white
}
</style>
<div class="parent">
<i class="fa fa-cog" style="color:white">
</div>
Write this code in the same line, this change the icon color:
<li class="fa fa-id-card-o" style="color:white" aria-hidden="true">
Use color property to change the color of your target element as follow :
.icon-cog { // selector of your element
color: black;
}
Or in the newest version of font-awesome , you can choose among filled or not filled icons
If you want to change the color of a specific icon, you can use something like this:
.fa-stop {
color:red;
}
It might a little bit tricky to change the color of font-awesome icons. The simpler method is to add your own class name inside the font-awesome defined classes like this:
.
And target your custom_defined__class_name in your CSS to change the color to whatever you like.
Open the svg file in vs code or something
change the line
path fill="gray" to what ever color you want! in my case i change it to gray!
I added a style, then color of your choice and make sure to make it bold
HTML:
<i class="icon-cog blackiconcolor">
css :
.blackiconcolor {color:black;}
Using class will give you a free binding property which you can apply on any tag you require.