Html/Css flickering when i hover over a button - html

i've been looking for some solutions here but i seem to stupid to change it the way i need to, so i decided to make a post.
Following problem:
button {
font-family: custom-bold;
width: 100%;
font-size: 1.1rem;
outline: none;
padding: 10px;
background-color: rgba(0, 0, 0, 0.322);
border: none;
border-radius: 5px;
color: white;
box-shadow: 3px 3px 3px 3px rgba(0, 0, 0, 0.5);
text-shadow: 3px 3px 3px 3px rgba(0, 0, 0, 0.5);
}
button:hover {
background-color:rgb(255, 255, 255);
display: inline-block;
transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
position: relative;
overflow: hidden;
transition-property: color;
transition-duration: 0.5s;
color:rgb(0, 0, 0);
}
<button>thatsabutton</button>
when u hover over it, it flickers. When for example i add a margin-top to it with 1%, i would prevent the flickering but it would fk over with the other things i've made. Any idea what i can do it to prvent it with out adding margin to it? Regards!

You are only transitioning the color, change it to 'all' and you're OK.
Also add it to the button class for the reverse action.
button {
font-family: custom-bold;
width: 100%;
font-size: 1.1rem;
outline: none;
padding: 10px;
background-color: rgba(0, 0, 0, 0.322);
border: none;
border-radius: 5px;
color: white;
box-shadow: 3px 3px 3px 3px rgba(0, 0, 0, 0.5);
text-shadow: 3px 3px 3px 3px rgba(0, 0, 0, 0.5);
transition-property: all;
transition-duration: 0.5s;
}
button:hover {
background-color:rgb(255, 255, 255);
display: inline-block;
transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
position: relative;
overflow: hidden;
transition-property: all;
transition-duration: 0.5s;
color:rgb(0, 0, 0);
}
<button>thatsabutton</button>

Related

How to style a button like the image?

I am trying to create a button like this image with PURE CSS. Please could you help me with the CSS ?
This Image
I am trying using below but not giving exact same result -
.styled {
border: 0 !important;
line-height: 2.5;
font-weight: bold;
text-align: center !important;
color: rgba(11,44,20,255) !important;
border-radius: 8px !important;
padding: 5px 16px 5px 16px;
transition: 0.2s all;
background-image: linear-gradient(to top left,
rgba(0, 0, 0, .2),
rgba(0, 0, 0, .2) 100%,
rgba(0, 0, 0, 0)) !important;
box-shadow: inset 7px 7px 3px rgba(255, 255, 255, .6),
inset -7px -7px 3px rgba(0, 0, 0, .7) !important;
}
This is closest as I can get without the button background. You can try experimenting with CSS gradients until you hit the actual angle.
#button{
width: 69px;
height: 34px;
position: relative;
background: #3F4E4C;
background: -webkit-radial-gradient(bottom right, #3F4E4C, #7CD9BA);
background: -moz-radial-gradient(bottom right, #3F4E4C, #7CD9BA);
background: radial-gradient(to top left, #3F4E4C, #7CD9BA);
border: none;
outline: none;
border-radius: 8px;
}
#external{
position: absolute;
top: 6px;
left: 6px;
background: #3ade66;
width: calc(100% - 12px);
height: calc(100% - 12px);
border-radius: 6px;
text-align:center;
color: black;
line-height: 2.2;
font-size: 10px;
font-weight: bold;
}
<button id="button">
<div id="external">Start</div>
</button>
Add an onclick event to the image.
function myFunction() {
alert("Button clicked");
};
img {
/*Disables dragging of the image*/
-webkit-user-drag: none;
-khtml-user-drag: none;
-moz-user-drag: none;
-o-user-drag: none;
user-drag: none;
/*Sets the mouse to pointer when hovered*/
cursor: pointer;
}
<img src="https://i.stack.imgur.com/Rggof.png" onclick="myFunction();">
Got the similar view using -
.styled {
border: 0 !important;
line-height: 2.5;
font-weight: bold;
text-align: center !important;
color: rgba(11,44,20,255) !important;
border-radius: 10px !important;
transition: 0.2s all;
background-image: linear-gradient(to top left,
rgba(0, 0, 0, .2),
rgba(0, 0, 0, .2) 100%,
rgba(0, 0, 0, 0)) !important;
box-shadow: inset 6px 6px 1px rgba(255, 255, 255, .3),
inset -6px -6px 1px rgba(0, 0, 0, .3) !important;
}

Inserting a link

How can I turn the facebook font awesome icon into a link? Whenever I insert a link it pushes the icon out of the frame of the picture. I would like to put other social media icons beside the facebook icon aswell but at the moment I am just trying to solve the problem of getting the icon to link to facebook.
CSS
.polaroid-images a {
background: white;
display: inline;
float: left;
margin: 0 15px 70px;
padding: 10px 10px 25px;
text-align: center;
text-decoration: none;
-webkit-box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
-moz-box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
-webkit-transition: all .15s linear;
-moz-transition: all .15s linear;
transition: all .15s linear;
z-index: 0;
position: relative;
}
.polaroid-images a,
:after {
color: #333;
font-size: 20px;
content: attr(title);
position: relative;
top: 15px;
}
.polaroid-images img {
display: block;
width: inherit;
}
.polaroid-images a,
i:nth-child(3n) {
-webkit-transform: rotate(-24deg);
-moz-transform: rotate(-24deg);
transform: rotate(-24deg);
}
.polaroid-images a:hover {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
transform: scale(1.2);
z-index: 10;
-webkit-box-shadow: 0 10px 20px rgba(0, 0, 0, .7);
-moz-box-shadow: 0 10px 20px rgba(0, 0, 0, .7);
box-shadow: 0 10px 20px rgba(0, 0, 0, .7);
}
.polaroid-images i {
position: relative;
font-size: 1em;
top: 15px;
margin-right: .5em;
color: #3b5998;
}
HTML
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-
awesome.min.css" rel="stylesheet"/>
<div class="polaroid-images">
<a href="" title="Alex"><img height="200"
src="http://kenwheeler.github.io/slick/img/fonz1.png" alt="Island"
title="Alex" class=fishes /><i class="fa fa-facebook fa-3x"></i></a>
</div>
So, as of right now you have a link that is wrapping your entire card. You should probably remove this unless you want the whole card to link to Facebook. Here's what I would do:
.polaroid-images div {
background: white;
display: inline;
float: left;
margin: 0 15px 70px;
padding: 10px 10px 25px;
text-align: center;
text-decoration: none;
-webkit-box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
-moz-box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
-webkit-transition: all .15s linear;
-moz-transition: all .15s linear;
transition: all .15s linear;
z-index: 0;
position: relative;
}
.polaroid-images div,
:after {
color: #333;
font-size: 20px;
content: attr(title);
position: relative;
top: 15px;
}
.polaroid-images img {
display: block;
width: inherit;
}
.polaroid-images div,
i:nth-child(3n) {
-webkit-transform: rotate(-24deg);
-moz-transform: rotate(-24deg);
transform: rotate(-24deg);
}
.polaroid-images div:hover {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
transform: scale(1.2);
z-index: 10;
-webkit-box-shadow: 0 10px 20px rgba(0, 0, 0, .7);
-moz-box-shadow: 0 10px 20px rgba(0, 0, 0, .7);
box-shadow: 0 10px 20px rgba(0, 0, 0, .7);
}
.polaroid-images i {
position: relative;
font-size: 1em;
top: 15px;
margin-right: .5em;
color: #3b5998;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-
awesome.min.css" rel="stylesheet"/>
<div class="polaroid-images">
<div title="Alex">
<img height="200"
src="http://kenwheeler.github.io/slick/img/fonz1.png" alt="Island"
title="Alex" class=fishes />
<i class="fa fa-facebook fa-3x"></i>
</div>
</div>
Essentially, I just removed the a tag from the entire block and only wrapped it around four FB icon. Then I changed your container to a div and changed the style accordingly.
Hope this helps!

Hidding top border in bootstrap 4

I'm trying to build simple pricing table using bootstrap 4 card element, but i can't find solution to one problem.
.card {
border: 0;
border-radius: 0px;
-webkit-box-shadow: 0 3px 0px 0 rgba(0, 0, 0, .08);
box-shadow: 0 3px 0px 0 rgba(0, 0, 0, .08);
transition: all .3s ease-in-out;
padding: 2.25rem 0;
position: relative;
&:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 0%;
border: 3px solid $primary-color;
transition: 0.5s;
}
&:hover {
transform: scale(1.05);
-webkit-box-shadow: 0 20px 35px 0 rgba(0, 0, 0, .08);
box-shadow: 0 20px 35px 0 rgba(0, 0, 0, .08);
&:after {
border: 3px solid $primary-color;
width: 100%;
}
Live Codepen
This is code responsible for drawing line in top part of the tables on the hover. The problem is i have no idea how to hide this small green rectangle in the left top corner of each table. I was trying to make border white and change to green once customer hover table. It works, but then fade effect is visible. I would prefer to keep it as it's now, just somehow get rid of this rectangle.
Remove border from :after and add height: 3px instead, also remove border from :after on :hover
.card {
border: 0;
border-radius: 0px;
-webkit-box-shadow: 0 3px 0px 0 rgba(0, 0, 0, .08);
box-shadow: 0 3px 0px 0 rgba(0, 0, 0, .08);
transition: all .3s ease-in-out;
padding: 2.25rem 0;
position: relative;
&:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 0%;
height: 3px;
background: $primary-color;
transition: 0.5s;
}
&:hover {
transform: scale(1.05);
-webkit-box-shadow: 0 20px 35px 0 rgba(0, 0, 0, .08);
box-shadow: 0 20px 35px 0 rgba(0, 0, 0, .08);
&:after {
width: 100%;
}

HTML Class reference

I've a little problem with this code.
My css class has the name:
section.border button
From what I would like to create a href with the look of < button >
<a data-scroll href="#link" class="section border button">Go to</a>
This method unfortunately isn't working.
<section class="border">
<button>Click</button> <- it's OK
<a data-scroll href="#test" class="section border button">Go to Google</a> <- NOPE
</section>
CSS
section.border button {
color: #f6f6f6;
background: rgba(0,0,0,0);
border: solid 2px #f6f6f6;
padding:10px 40px 10px 40px;
text-transform: uppercase;
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-property: box-shadow;
transition-property: box-shadow;
-webkit-transition-property: background-color;
transition-property: background-color;
font-size: 1.0em;
font-family: "Lato";
text-transform: uppercase;
text-shadow: 0px 2px 0px rgba(0, 0, 0, 0.4), 0px 2px 2px rgba(0, 0, 0, 0.3);
-moz-box-shadow: box-shadow: 0 0 12px 2px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: box-shadow: 0 0 12px 2px rgba(0, 0, 0, 0.2);
box-shadow: 0 0 12px 2px rgba(0, 0, 0, 0.2);
/* Hack to improve aliasing on mobile/tablet devices */
}
section.border button:hover,
section.border button.hover,section.border button:active,
section.border button.active {
border-color: white;
background-color: rgba(187,187,187, 0.3);
text-shadow: 0px 2px 0px rgba(0, 0, 0, 0.4), 0px 2px 2px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 12px 2px rgba(0, 0, 0, 0.2);
}
Simply use a custom css name, and add it to every items you want to show as a button.
section.border button, .myButton { ... }
<section class="border">
<button>Click</button>
<a class="myButton">Go to Google</a>
</section>
<a class="myButton">Go to Bing</a>
Go to Google
does't match any of those css rules.
The css rule is for a button inside a section that has a border class
<section class="border">
<button >Go to Google</button>
</section>

iOS like toggle button using checkbox looks different for different browsers

I am kinda new to web designing. Trying to create a toggle iOS like button but the issue is with its appearance on different browsers. It looks different in different browsers. As I tested it it works properly on Chrome.
Can somebody help me to make it look same on all browsers? Sorry for the broken english?
jsfiddle Link : http://jsfiddle.net/racy2408/Let1y8yr/
Given below is CSS I tried:
body {
margin: 30px;
text-align: center;
}
input[type=checkbox],
input[type=radio] {
display: inline-block;
width: 50px;
height: 30px;
position: relative;
cursor: pointer;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
box-shadow: inset 0px 5px 40px -13px rgba(0, 0, 0, 0.75);
-webkit-box-shadow: inset 0px 5px 40px -13px rgba(0, 0, 0, 0.75);
-moz-box-shadow: inset 0px 5px 40px -13px rgba(0, 0, 0, 0.75);
-o-box-shadow: inset 0px 5px 40px -13px rgba(0, 0, 0, 0.75);
border-radius: 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
-o-border-radius: 15px;
background-color: #fff;
padding: 1px;
margin: 0px;
transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transform: scale(1);
-webkit-transform: scale(1);
/*Adjust size here*/
-moz-transform: scale(1);
-o-transform: scale(1);
}
input[type=checkbox]:checked,
input[type=radio]:checked {
box-shadow: inset 0px 0px 0px 20px #53d76a, inset 0px 5px 40px -13px rgba(132, 132, 132, 1);
-webkit-box-shadow: inset 0px 0px 0px 20px #53d76a, inset 0px 5px 40px -13px rgba(132, 132, 132, 1);
-moz-box-shadow: inset 0px 0px 0px 20px #53d76a, inset 0px 5px 40px -13px rgba(132, 132, 132, 1);
-o-box-shadow: inset 0px 0px 0px 20px #53d76a, inset 0px 5px 40px -13px rgba(132, 132, 132, 1);
}
input[type=checkbox]:after,
input[type=radio]:after {
content: " ";
position: absolute;
width: 28px;
height: 28px;
cursor: pointer;
border-radius: 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
-o-border-radius: 15px;
box-shadow: 0px 2px 2px 1px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 2px 2px 1px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 2px 2px 1px rgba(0, 0, 0, 0.2);
-o-box-shadow: 0px 2px 2px 1px rgba(0, 0, 0, 0.2);
background-color: #fff;
/* background-image: url(../images/toggle.png);
background-repeat: no-repeat;
background-size: contain; */
transition: all 0.2s ease-in 0.2s;
-webkit-transition: all 0.2s ease-in 0.2s;
-moz-transition: all 0.2s ease-in 0.2s;
-o-transition: all 0.2s ease-in 0.2s;
}
input[type="checkbox"]:checked:after,
input[type="radio"]:checked:after {
left: 23px;
}
input[type=checkbox]:focus,
input[type=checkbox]:active,
input[type=radio]:focus,
input[type=radio]:active {
outline: 0;
}
<h1>Checkbox :</h1>
<input type="checkbox" />
<input type="checkbox" checked />
<h1>Radio :</h1>
<input type="radio" name="group" />
<input type="radio" name="group" checked />
<input type="radio" name="group" />
inputs aren't supposed to be able to add before and after psuedo-elements because they aren't containers (e.g. an <input> can't have child elements).
There is some more information in the comment here: https://stackoverflow.com/a/4660434/4338477
You could add labels to get the same effect though (this works in Firefox and IE9+):
http://jsfiddle.net/8okjwLxx/2/
<h1>Checkbox :</h1>
<input id="checkbox1" type="checkbox" />
<label for="checkbox1"></label>
<input id="checkbox2" type="checkbox" checked />
<label for="checkbox2"></label>
<h1>Radio :</h1>
<input id="radio1" type="radio" name="group" />
<label for="radio1"></label>
<input id="radio2" type="radio" name="group" checked />
<label for="radio2"></label>
<input id="radio3" type="radio" name="group" />
<label for="radio3"></label>
body {
margin: 30px;
text-align: center;
}
input[type=checkbox],
input[type=radio]{
display: none;
}
input[type=checkbox] + label,
input[type=radio] + label {
display: inline-block;
width: 50px;
height: 30px;
position: relative;
cursor: pointer;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
box-shadow: inset 0px 5px 40px -13px rgba(0, 0, 0, 0.75);
-webkit-box-shadow: inset 0px 5px 40px -13px rgba(0, 0, 0, 0.75);
-moz-box-shadow: inset 0px 5px 40px -13px rgba(0, 0, 0, 0.75);
-o-box-shadow: inset 0px 5px 40px -13px rgba(0, 0, 0, 0.75);
border-radius: 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
-o-border-radius: 15px;
background-color: #fff;
padding: 1px;
margin: 0px;
transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transform: scale(1);
-webkit-transform: scale(1); /*Adjust size here*/
-moz-transform: scale(1);
-o-transform: scale(1);
}
input[type=checkbox]:checked + label,
input[type=radio]:checked + label {
box-shadow: inset 0px 0px 0px 20px #53d76a, inset 0px 5px 40px -13px rgba(132, 132, 132, 1);
-webkit-box-shadow: inset 0px 0px 0px 20px #53d76a, inset 0px 5px 40px -13px rgba(132, 132, 132, 1);
-moz-box-shadow: inset 0px 0px 0px 20px #53d76a, inset 0px 5px 40px -13px rgba(132, 132, 132, 1);
-o-box-shadow: inset 0px 0px 0px 20px #53d76a, inset 0px 5px 40px -13px rgba(132, 132, 132, 1);
}
input[type=checkbox] + label:after,
input[type=radio] + label:after {
left: 0;
content: " ";
position: absolute;
width: 28px;
height: 28px;
cursor: pointer;
border-radius: 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
-o-border-radius: 15px;
box-shadow: 0px 2px 2px 1px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 2px 2px 1px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 2px 2px 1px rgba(0, 0, 0, 0.2);
-o-box-shadow: 0px 2px 2px 1px rgba(0, 0, 0, 0.2);
background-color: #fff;
/* background-image: url(../images/toggle.png);
background-repeat: no-repeat;
background-size: contain; */
transition: all 0.2s ease-in 0.2s;
-webkit-transition: all 0.2s ease-in 0.2s;
-moz-transition: all 0.2s ease-in 0.2s;
-o-transition: all 0.2s ease-in 0.2s;
}
input[type=checkbox]:checked + label:after,
input[type=radio]:checked + label:after {
left: 23px;
}
input[type=checkbox]:focus,
input[type=checkbox]:active,
input[type=radio]:focus,
input[type=radio]:active {
outline: 0;
}