Switch button transparent hover effect - css

I want to switch button hover effect between transparent background with solid color background, but so far i ruin it :(
If someone can help me it will be great, thank you Stackoverflow.
/*################ Test Button ##########*/
.tesbtn {
color: #EE6533;
border:solid 2px #EE6533;
border-radius: 6px;
box-shadow: 0 0 20px #EE6533;
padding: 9px 9px;
font-size: 14px;
display: inline-block;
width: 130px;
margin: 10px;
float: center;
font-family: 'Nunito Sans', sans-serif;
font-weight: bold;
text-align: center;
text-shadow: 0 0 5px #EE6533;
transition-duration: 0.4s;
-webkit-transition-duration: all 0.4s;
}
.tesbtn:hover {
background: #EE6533;
color: #fff;
box-shadow: 0 12px 16px 0 rgba(238,101,51,0.24),0 17px 50px 0 rgba(238,101,51,0.19);
}
.tesbtn:last-child {
margin-left: 5px;
}
<br/><br/>
<div style="text-align: center;">
<a class='tesbtn' href='#' target='_self'>Test</a>
<a class='tesbtn' href='#' target='_self'>Test</a>
</div>

if you want to make background transparent, you can use opacity:

try using the transform: opacity(); property

Related

Hover doesn't work on button element

Hopefully this will be an easy thing to fix, but I have tried searching for an answer and nothing seems to fit.
I'm trying to make a hover effect on a button:
button {
min-width: 20vw;
max-width: 40vw;
border: none;
color: white;
font-size: 1.5vw;
padding: 15px 32px;
text-align: center;
text-decoration: none;
background-color: blue;
border-radius: 20px;
transition: 0.4s;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
.button:hover {
color: black;
background-color: lightcyan;
}
When I test this in a browser (vivaldi & edge) nothing changes. The test site is http://wyrdling.com/skulpturjagt by the way.
PS. I tried using the chrome developer tool, but I'm too much of a newb to figure out how to read it XD
Unless its a typo in your question, you use .button:hover. That will apply to elements with a class of hover. Swap it to button:hover
Here are some example plunkers.
Example 1:
button {
min-width: 20vw;
max-width: 40vw;
border: none;
color: white;
font-size: 1.5vw;
padding: 15px 32px;
text-align: center;
text-decoration: none;
background-color: blue;
border-radius: 20px;
transition: 0.4s;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
button:hover {
color: black;
background-color: lightcyan;
}
<button>My button.</button>
Example 2 :
.button {
min-width: 20vw;
max-width: 40vw;
border: none;
color: white;
font-size: 1.5vw;
padding: 15px 32px;
text-align: center;
text-decoration: none;
background-color: blue;
border-radius: 20px;
transition: 0.4s;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
.button:hover {
color: black;
background-color: lightcyan;
}
<button class="button">My button</button>

Button with border bottom and border radius not expected results

Here's what i want to accomplish:
As you can see, there's a small border at the bottom, i've tried to add border-bottom: 1px solid #c1ad6f but it results to:
Border is not fully filled cause of radius.
.btn {
background: #d5c289;
border-bottom: 6px solid #c1ad6f;
font-weight: 500;
font-size: 1.125rem;
padding: 1.25rem;
border-radius: 4px;
}
<a class="btn" href="#form" role="button">Enroll</a>
You may consider box-shadow instead of border to achieve this in a better way:
.box {
display: inline-block;
margin: 10px;
height: 100px;
width: 200px;
background: #d5c289;
box-sizing:border-box;
border-radius: 0 0 20px 20px;
}
.shadow {
box-shadow: 0 -10px 0 0 #c1ad6f inset;
animation: anime 2s infinite linear alternate;
}
.border {
border-bottom: 10px solid #c1ad6f;
animation: anime-alt 2s infinite linear alternate;
}
#keyframes anime {
from {box-shadow: 0 -1px 0 0 #c1ad6f inset;}
to {box-shadow: 0 -30px 0 0 #c1ad6f inset;}}
#keyframes anime-alt {
from {border-bottom: 1px solid #c1ad6f;}
to {border-bottom: 30px solid #c1ad6f;}}
<div class="box shadow">
Good one with box-shadow
</div>
<div class="box border">
Not good with border
</div>
This is simple trick to make border rounded using box-shadow. it will
exactly giving the output what you want.
.btn-bordered {
background: #17aa56;
color: #fff;
border-radius: 15px;
box-shadow: 0 10px #119e4d;
padding: 25px 60px 25px 90px;
}
.btn-block {
border: none;
font-family: inherit;
font-size: inherit;
color: inherit;
background: #ddd;
cursor: pointer;
padding: 25px 80px;
display: inline-block;
margin: 15px 30px;
text-transform: Capitialize;
letter-spacing: 1px;
font-weight: 700;
position: relative;
overflow:hidden;
}
<button class="btn-bordered btn-block" type="button">Bottom Rounded Button</button>
#AlexanderKim, you could increase border-bottom. like this: border-bottom: 5px solid #c1ad6f;. I made this fiddle: jsfiddle.net/bektkdnz but increased padding so it was easier to see

How to fix glitchy transform:rotateX 3d button?

#learn-more-button {
position: relative;
top: 69%;
margin: 0 auto;
padding-top: 18px;
width: 185px;
height: 38px;
background-color: #009ee3;
font-family: 'Montserrat', sans-serif;
font-size: 15px;
color: #fff;
font-weight: 400;
text-align: center;
letter-spacing: 2px;
transition: 0.85s;
}
#learn-more-button:hover {
/*box-sizing: border-box;
border-bottom: 5px solid #c42c50;*/
-webkit-transform: rotateX(25deg);
transform: rotateX(25deg);
cursor: pointer;
border-bottom: 5px solid #0091c8;
}
<div id="learn-more-button">Button</div>
I have created a button that is just a blue, flat rectangle with "learn more" text. When hovered, I want it to slightly rotate on the X axis and have a slightly darker bottom border to create the illusion of a thin box style button rotating slightly. My method does work, however it seems quite "glitchy" (for lack of a better word). To try and explain, a tiny white line appears on the border for a split second and the rotation isn't smooth. The website isn't live yet so I'm not sure how I could show this if required.
Using a solid box-shadow will transition a bit more gracefully than border.
Either way, part of the glitchy feel was that you were transitioning from no border property to a 5px border (instead of a 0px border to 5px border), so the border popped away instead of animating on mouseout. In this case, I added a 0px box-shadow to the button before it animates, so the transition is smoother.
#learn-more-button {
position: relative;
top: 69%;
margin: 0 auto;
padding-top: 18px;
width: 185px;
height: 38px;
background-color: #009ee3;
font-family: 'Montserrat', sans-serif;
font-size: 15px;
color: #fff;
font-weight: 400;
text-align: center;
letter-spacing: 2px;
transition: 0.85s;
box-shadow: #0091c8 0 0 0;
}
#learn-more-button:hover {
/*box-sizing: border-box;
border-bottom: 5px solid #c42c50;*/
-webkit-transform: rotateX(25deg);
transform: rotateX(25deg);
cursor: pointer;
box-shadow: #0091c8 0 5px 0;
}
<div id="learn-more-button">Button</div>

Stop Hover Effect from Moving Other Elements Down on Page

I'm working on my navigation and I've added an effect that when you hover over a link, a blue border is added to the bottom. It works, but the only problem I'm having is that when you hover over a link, the border pushes all the other elements on the page down 3 pixels (the size of the border).
If anyone could clue me in on how to fix this it would be greatly appreciated. Here's the relevent code:
HTML
<div id="nav" class="wrapper">
<div class="site-navigation">
About
Work
<div class="site-title">Noelle Devoe</div>
Blog
Contact
</div>
</div>
CSS
.wrapper{
width: 1000px;
background-color: rgb(255,255,255);
margin: 0 auto;
overflow: hidden;
}
.site-navigation {
text-align: center;
overflow:hidden;
}
.site-navigation a{
font-family: 'Arvo', serif, Georgia;
width: 125px;
float: left;
padding: 50px 0 50px 0;
letter-spacing: 4px;
text-transform: uppercase;
-o-transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
transition:.5s;
color: rgb(82,82,82);
}
.site-navigation a:hover{
font-weight: bold;
border-bottom: 3px solid rgb(4,141,195);
text-shadow: rgb(200, 200, 200) 1px 1px 0px;
}
One easy fix is to add a transparent border when the element isn't being hovered.
Add border-bottom: 3px solid transparent; to .site-navigation a.
.site-navigation a {
font-family:'Arvo', serif, Georgia;
width: 125px;
float: left;
padding: 50px 0 50px 0;
letter-spacing: 4px;
text-transform: uppercase;
-o-transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
transition:.5s;
color: rgb(82, 82, 82);
border-bottom: 3px solid transparent;
}
How about adding below CSS:
border-bottom: 3px solid transparent;
to
.site-navigation a
Simple way to solve the hover problem!
<div class="main">
<div class="box"></div>
</div>
.main{
height: 205px;
width: 405px;
}
.box{
height: 200px;
width: 400px;
border:1px solid rgb(0, 0, 0);
transition:
0.3s;
}
.box:hover{
margin-left: 5px;
margin-bottom: 5px;
box-shadow: -5px 5px black;
}

CSS tooltip on image problem

I've got a problem with a CSS tooltip over an image. Using it on text works fine, however when I use an image instead of text, it seems to be having issues, the issues are a bit hard to explain so I'll just give you a link:
http://zorps.dk/css-tooltips/tooltip.html
CSS code:
.tooltip {
border-bottom: 1px dotted #000000; color: #000000; outline: none;
cursor: help; text-decoration: none;
position: relative;
}
.tooltip span {
margin-left: -999em;
position: absolute;
}
.tooltip:hover span {
border-radius: 5px 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
font-family: Calibri, Tahoma, Geneva, sans-serif;
position: absolute; left: 1em; top: 2em; z-index: 99;
margin-left: 0; width: 250px;
}
.tooltip:hover img {
border: 0; margin: -10px 0 0 -55px;
float: left; position: absolute;
}
.tooltip:hover em {
font-family: Candara, Tahoma, Geneva, sans-serif; font-size: 1.2em; font-weight: bold;
display: block; padding: 0.2em 0 0.6em 0;
}
.classic { padding: 0.8em 1em; }
* html a:hover { background: transparent; }
.classic {background: #FFFFAA; border: 1px solid #FFAD33; }
html code:
<p> <a class="tooltip" href="#"> <img src="icon_question.png" /> <span class="classic">The tooltip text goes here!</span></a></p>
Anyone know what the issue is?
Thanks!
Note: the code is taken from: http://sixrevisions.com/css/css-only-tooltips/
It's the code within the .tooltip:hover img class - If you remove it, it works well:
http://jsfiddle.net/RyRRM/
it's probably because the event is triggered by the tooltip's non-text-node parent. When you hover over the image, it detects a mouseout event for the parent. You could try making the image a css background and setting the width of the element instead of embedding the <img>
Your markup could then be
<a class="tooltip image" href="#"><span class="classic">The tooltip text goes here!</span></a>
and your css would be
.tooltip.image {
width: 12px;
height: 14px;
background-image: url("./icon_question.png");
display: block;
background-repeat: no-repeat;
}

Resources