How can I remove a bootstrap buttons hover effect? - css

I've gotten an assignment to remove the hover effect of the following button:
Visit http://www.appsbayou.se, search for the text "Kontaktinformation". Above it there's a button, "Skicka" which has an ugly black hover effect. This style comes from existing css.
I'm using Chrome and even if I open up Devtools I can't nail down the style rule that does this effect.
How can I remove this black hover color or at least change it to a color of my choosing?

You will need to toggle the hover state inside the developer tools in order to view the CSS which is applied to the button on hover state. Adding this CSS to your stylesheet will fix the problem:
input[type=submit]:hover {
background-position: 0px;
}

You have these rules:
input[type=submit]:hover {
color: #fff;
background-color: #222; // Here is the black background-color
text-decoration: none;
background-position: 0 -15px; // moves the background
-webkit-transition: background-position .1s linear;
-moz-transition: background-position .1s linear;
-o-transition: background-position .1s linear;
transition: background-position .1s linear;
}
.wpcf7-submit:hover {
background-image: linear-gradient(to bottom,#fb8800,#975200) !important; // remove this?
}
Simply change the backgound-color to your choice of color. I would also suggest removing the gradient hover and the background positioning if you only wish to change a color. (And of course then the transitions doesn't make much sense either. )

Go into the HTML and you will see this line which is the button:
<input class="wpcf7-form-control wpcf7-submit" type="submit" value="Skicka">
Remove the wpcf7-submit to get rid of the orange. It changes the color of the button but it may be a solution.
Or go into the CSS file and change this attribute:
.wpcf7-submit {
background-image: linear-gradient(to bottom, #fb8800, #975200) !important;
}
The code for the orange is #fb8800

remove this from the page
.wpcf7-submit:hover{
background-image: linear-gradient(to bottom,#fb8800,#975200) !important;
}
or do a search for it... find it... then kill it!

In BS4 you also need to overwrite the button:before pseudo-selector to set opacity to zero, otherwise hover remains, so you will end up with something like:
button.greyed-out-disabled,
button.greyed-out-disabled:focus,
button.greyed-out-disabled:hover {
background-color: #E3E3E3 !important;
color: #9E9E9E !important;
outline: none;
}
button.greyed-out-disabled:before {
background: rgba(255,255,255,0) !important;
}

Related

How to inherit color properties from figures to figcaptions

I'm trying to make a figure that changes the background color of the contained image when i hover over it with my mouse. I was able to do as much and then trying to go up a level by trying to change the color of the caption and the background using a class but when i hover over the image it isn't working fully.
What i tried to do was to place the class with the background and text color in the figure and thought that it would just make the caption inherit the text color but that didn't happen.
I also tried, alternatively, to give the caption its own hover property, and it does work, but not properly.
You see if I give the figure a background color and text color then only the background changes color as seen below
Before hovering
After hovering
The text is still blue and i have written it to be white.
and when i apply the code directly on the caption this happens
Not hovering on the caption
When hovering on the caption
So as you can see, the caption only lights up when my cursor is on it, but i want it to light up when my cursor is hovering over any part of the image, so what i really want to know is, if there even is a way to do this, any help would be really helpful.
Here is the code i used for this
figcaption {
color: #3a7cc4;
}
.change {
box-shadow: 0px 0px 30px lightgray;
transition: all 0.2s linear;
}
.change:hover{
background-color: #3a7cc4;
transition: all 0.2s linear;
color: white;
}
And then i changed the caption color separately, to make it change color
figcaption:hover {
color: white;
}
Edit-
Here's a working snippet as well for the code:
.change {
box-shadow: 0px 0px 30px lightgray;
transition: all 0.2s ease-in;
}
.change:hover {
background-color: #3a7cc4;
transition: all 0.2s ease-in;
color: white;
}
figcaption:hover {
color: white;
}
<div class="column change">
<figure>
<img src="https://i.imgur.com/N7vSN08.jpeg">
<figcaption>Tree Fort</figcaption>
</figure>
</div>
Assuming it is the figure that has the change class then it can set the color for the text and it can be inherited by the caption.
In the CSS given in the question however the figcaption overrides any inherited color by setting it itself. Hence it doesn't change when the figure is hovered.
So this snippet removes that and instead places the blueish color setting in the figure. This then gets inherited when there is no hovering. When there is hovering the setting of color as white gets inherited.
<style>
.change {
box-shadow: 0px 0px 30px lightgray;
transition: all 0.2s linear;
color: #3a7cc4;
}
.change:hover {
background-color: #3a7cc4;
transition: all 0.2s linear;
color: white;
}
</style>
<figure class="aligncenter size-full change"><img loading="lazy" width="477" height="587" src="https://cid17970jan2022.kinsta.cloud/wp-content/uploads/2022/01/image.jpg" alt="" class="wp-image-6889" srcset="https://cid17970jan2022.kinsta.cloud/wp-content/uploads/2022/01/image.jpg 477w, https://cid17970jan2022.kinsta.cloud/wp-content/uploads/2022/01/image-244x300.jpg"
sizes="(max-width: 477px) 100vw, 477px">
<figcaption>Tree Fort</figcaption>
</figure>
Note: if it is an ancestor element rather than the figure that has the change class the CSS selectors will need changing to .change figure

CSS color transition triggers multiple animations when loading the website

This is my first question in this forum so if it's not well explained, feel free to ask me for more details.
I have a color transition in all the links on my navbar, that triggers when you hover your mouse over them. This work wells, the problem is that when the website loads, all those elements began to resize or move to their initial positions.
CSS
nav{
height: 80px;
width: 100%;
background-color: rgba(250,250,250,1);
font-size: 13px;
border-bottom: 1px solid #D8D8D8;
color: #6E6E6E;
position: fixed;
margin-top: -80px;
}
nav a{
padding: 20px 20px;
line-height: 80px;
-webkit-transition: all 0.8s;
transition: all 0.8s;
}
nav a:hover{
color:#00BFFF;
}
UPDATE
I have tried to make a JSFiddle with the problem, but even when the CSS and HTML is exactly the same its seem to work correctly on the demo
I have changed the transition property from all to color. This has solved the problem partially, since now the elements don't move when the page loads, but the problem now is that all links that include this color transition, when the website loads, show an initial blue color (inexistent in my CSS) taking the transition time to change to the correct color. This initial blue color is similar to the visited links standard color (but I have also used the selector a:visited without positive result.
This only happens on Firefox.
As due to my low reputation I can't post images, I have taken the blue initial tone: RGB (6,6,231)
You only need animate the color:
-webkit-transition: color 0.8s;
transition: color 0.8s;
note that I change all for color only.
note 2 you can do
transition: color 0.8s, height 0.2s ease-out, opacity 1s linear 0.5s;
Try adding script tag at footer of the html page.This worked for me.
<script> </script>

Background-Image Gradient Not Animating

I am hoping someone can help clear this up.
I'm working on a search bar using HTML5 CSS3 here is the working example http://jsfiddle.net/4Mr6D/
text-decoration: none;
transition: all 400ms;
-webkit-transition: all 400ms;
-moz-transition: all 400ms;
-o-transition: all 400ms;
starting line 164 or where I commented 'SEARCH RESULTS'
I am trying to get the gradient background to animate on hover, it seems to only work animating back to the original color on rollout.
I've tried using background-image to animate, that doesn't work. I then turned to using the keyword 'all' and that isn't working.
So far, only the text color will animate. Can someone help me and locate what I'm doing wrong in getting the background gradient to animate also?
Edit: In the modern day web you can use CSS variables as a part of your gradient and animate them instead to do this sort of animation. The below still works if you need it (for browser support).
Background images are not animatable. Since gradients in CSS use background images, you cannot use a transition to a new one like you would text color.
With that being said, if you only have text in the drop downs, you can do a work around using a pseudo element and animating its opacity instead. The following is an example of how to do so:
.container:after {
content: "";
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #59aaf4), color-stop(100%, #338cdf));
background-image: -webkit-linear-gradient(top, #FF0000, #770000);
background-image: -moz-linear-gradient(top, #FF0000, #770000);
background-image: -ms-linear-gradient(top, #FF0000, #770000);
background-image: -o-linear-gradient(top, #FF0000, #770000);
background-image: linear-gradient(top, #FF0000, #770000);
position:absolute;
top:0;left:0;
opacity:0;
width:100%; height:100%;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
z-index: -1;
}
.container:hover { color:white; }
.container:hover:after { opacity:1; }
Demo
Also, I'd remove the 900ms delay that you have (I did in my demo). It is REALLY annoying for users, they want immediate feedback, not feedback a second later.
P.S. You should localize your code to the relevant parts like I did in order to get a quicker, better response. No one wants to look through 300 lines of code for a problem that only takes 20.
Special thanks to vals for improving it using z-index.
Sorry bud, but transitions on gradient images are not supported yet. Yeah I think thats crazy too.
But there is hope: Here's a work around in a fiddle. You can set the background of your search input to your primary color and transition it to the secondary color on hover. This way you get a color transition effect that looks like your gradient is transitioning.
Reduced example for clarity:
.search {
background: primary_color;
background-image: linear-gradient(top, primary_color, secondary_color);
transition: background 1s ease-out;
}
.search:hover {
background: secondary_color;
}

How to fade in and out a CSS ":after" pseudo element when adding or removing a class

I know there are a lot of other questions on using transitions on CSS pseudo element but after going through a whole bunch of them I still can't get my scenario to work.
Basically, I want to add a class to an element, the class has a :after pseudo element with some content and a background. I'd like a fading effect on the :after element when adding or removing the class.
I've been trying this out in this jsfiddle and the code I have so far it this:
HTML
<div id="divA">Div test</div>
<button id="btnAdd">Add it</button>
<button id="btnRemove">Take Away</button>
CSS
div {
width: 200px;
transition: all .5s linear;
background: red;
}
.test{
background: blue;
}
.test:after{
background: #0c0;
content: "Test";
}
jQuery
$("#btnAdd").click(function() {
$("#divA").addClass("test");
});
$("#btnRemove").click(function() {
$("#divA").removeClass("test");
});
Any help and hints would be most appreciated.
Forking #NilsKaspersson answer to make it work with your requirements.
Transition means from X to Y, you can't expect it to work with newly created attributes.
Then you have to create an initial attribute, and alter it later.
Since you don't want it to be there at the beginning, just use color: transparent; and background: transparent;
Running Demo
Code:
div {
width : 200px;
transition : all .5s linear;
background : red;
}
div:after {
transition : all .5s linear;
background : transparent;
color : transparent;
content : "Test";
}
.test{
background : blue;
}
.test:after{
background : #0c0;
color : black;
}
There are two things going on here.
1.) transition only works when there's something to transition from. Since your :after element is essentially created when the class test is added to it, there's no transition going on.
2.) transition doesn't inherit, so you'll need to declare it once again on the pseudo element.
Here's a quick n' dirty fork of your JSFiddle.
I moved the generic rules for the pseudo element to the classless div and added a transition to it. Then when the class test is added to it, the background changes and it can transition from it's old value.
If you don't want the pseudo element's content to be visible all the time, consider hiding it with opactiy: 0 and transition that to 1, or use the transparent color value for background and/or color.
Edit: Changing answer based on new fiddle.
On most case, CSS transition must apply on already-defined properties.
Additionnaly, the changing of a pseudo :after element content will make the element be removed and re-added, which removes the said properties at the same time.
I have made a demo with animating the text color and background-color while pre-setting the content, so the properties are already present.
CSS :
div {
width: 200px;
transition: all .5s linear;
background: red;
}
div:after {
transition: all .5s linear;
background: red;
color: red;
content: 'Test';
}
.test{
background: blue;
}
.test:after{
background: #0c0;
color: black;
}
Fiddle : http://jsfiddle.net/W5e9Q/10/

Need help on displaying text in a div when an Image Link is hovered over.

To paint the picture image I have two divs one on top to hold 5 thumbnail pics and the bottom div has 5 lines of text. The idea is when I hover over a picture div I want the project name of it to be displayed on the bottom div. I want this to happen for all 5 pictures. Been searching everywhere and found some things that were close but dead end. Any help is greatly appreciated as I am trying to help a student with their project. I am good with CSS I just can't wrap my head around this task.
Simple Demo
The HTML is pretty simple. The .photowrapper is optional, and the class could be just placed on the the a.
<div class="photowrapper">
<a href="#">
<img src="//placehold.it/200" alt="" />
<div class="label">Text</div>
</a>
</div>
We need everything to be an inline-block to act like an image.
.photowrapper {
border: 1px solid black;
display: inline-block;
}
.photowrapper a {
display: inline-block;
}
We default our label to being transparent. When our .photowrapper is hovered, its text color changes.
.photowrapper .label {
color: transparent;
}
.photowrapper:hover .label {
color: black;
}
If you want the underline, add another rule for .photowrapper:hover a where you set the decoration to underline. This disables it on hover and by default.
.photowrapper a {
text-decoration: none;
}
Absolute Positioning Demo
With the same HTML, we can position our labels so that they are in the same place.
.photowrapper .label {
opacity: 0;
color: black; background: yellow;
-moz-transition: opacity 1s ease;
-webkit-transition: opacity 1s ease;
transition: opacity 1s ease;
position: absolute;
top: 100%;
left: 0;
}
Fancyness
You can have supported browsers transition color changing for a less jerky result. Replace the label style with this:
.photowrapper .label {
min-height: 1em;
color: transparent;
-moz-transition: color 1s ease;
-webkit-transition: color 1s ease;
transition: color 1s ease;
}
demo
If your label is more than text, you can instead change/animate the opacity.
.photowrapper .label {
opacity: 0;
color: black; background: yellow;
-moz-transition: opacity 1s ease;
-webkit-transition: opacity 1s ease;
transition: opacity 1s ease;
}
.photowrapper:hover .label {
opacity: 1;
}
demo
What this does is uses the data attribute to attach a name, then when the image is hovered whatever is in the data attribute is set as the HTML for the p tag with the id "info"
In action: http://jsfiddle.net/calder12/HQQsb/
HTML
<div>
<img src="http://placehold.it/100x100" data-name="Image 1" class="project"/>
<img src="http://placehold.it/100x100" data-name="Image 2" class="project"/>
<img src="http://placehold.it/100x100" data-name="Image 3" class="project"/>
</div>
<div id="infodiv"><p id="info"></p></div>
jQuery
$(document).ready(function(){
$(".project").mouseover(function(){
$("#info").html($(this).data('name'));
}).mouseout(function(){
$("#info").html('');
});
});
You will need to use javascript or jquery to get it to appear on hover. Someone asked something pretty similar here:
http://stackoverflow.com/questions/1119956/hover-element-a-show-hide-element-b
Also there are many tutorials that can be accessed from a simple google search on creating a jquery script to do what you're asking. Let me know if you need anymore help or dont understand how to do it.

Resources