Firefox and Opera rendering border incorrectly - css

I have created a circular menu using trapezoids made with pure CSS, but when I rotate them, Firefox shows a line in both sides and, on Opera, all trapezoids have a weird background/border-color, kind of transparent. The trapezoids look like this.
.trapezoid {
width: 100px; height: 0px;
margin: 55px auto 0 auto;
border-bottom: 140px solid black;
border-left: 35px solid transparent;
border-right: 35px solid transparent;
transition: rotate (100deg);
}
Chrome and IE9 are OK.
How can I find a way to fix this?

You'll want to use -moz for Firefox; -o for Opera. Those are the extensions to correctly format within those browsers. A great site for shapes here.
.trapezoid
{
border-bottom: 100px solid red;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
height: 0;
width: 100px;
transform:rotate(180deg);
-moz-transform:rotate(180deg); /* Firefox 4 */
-webkit-transform:rotate(180deg); /* Safari and Chrome */
-o-transform:rotate(180deg); /* Opera */
}
Also I'm not sure if your trying to alter an effect of some sort; but the transition code would look like this:
transition:width 2s, height 2s;
-moz-transition:width 2s, height 2s, -moz-transform 2s; /* Firefox 4 */
-webkit-transition:width 2s, height 2s, -webkit-transform 2s; /* Safari and Chrome */
-o-transition:width 2s, height 2s, -o-transform 2s; /* Opera */
Just add the transition before hand; then throw the transform on a hover. If your trying to add it like a button. Hopefully that helps.
I've used Firebug to view some additional data; with Firefox 16.02 this code worked:
.trapezium
{
height: 0px;
width: 80px;
border-bottom-width: 80px;
border-bottom-style: solid;
border-bottom-color: #2d9dcd;
border-left-width-value: 40px;
border-left-style-value: solid;
border-left-color-value: transparent;
border-right-width-value: 40px;
border-right-style-value: solid;
border-right-color-value: transparent;
margin-top: 30px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 10px;
}
I believe that is what you are looking for. Try that and let me know if it works.

This is happening because the vendor prefixes are missing.
Apply the vendor prefixes as following and you will get it right.
Transition property is used to set and time the transitions.
https://developer.mozilla.org/en-US/docs/CSS/Using_CSS_transitions
.trapezoid {
width: 100px; height: 0px;
margin: 55px auto 0 auto;
border-bottom: 140px solid black;
border-left: 35px solid transparent;
border-right: 35px solid transparent;
-webkit-transform: rotate(100deg);
-moz-transform: rotate(100deg);
-o-transform: rotate(100deg);
-ms-transform: rotate(100deg);
transform: rotate(100deg);
}

Related

CSS transition not working on Chrome

I've got some CSS code that works on Mozilla Firefox and doesn't on Google Chrome.
.lightBtn {
width: 500px;
height: 49px;
color: #000000;
background: white;
transition-duration: 0.4s;
-webkit-transition-duration: 0.4s;
display: inline-block;
-webkit-transition: all 0.25s;
transition: all 0.25s;
}
.lightBtn:hover {
background: black;
color: white;
}
.lightBtn span {
display: inline-block;
position: relative;
-webkit-transition: 0.25s;
transition: 0.25s;
}
.lightBtn span:after {
content: '>>';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
-webkit-transition: 0.25s;
transition: 0.25s;
}
.lightBtn:hover span {
padding-right: 25px;
}
.lightBtn:hover span:after {
opacity: 1;
right: 0;
}
<button class="lightBtn" ><span>Special effect</span></button>
<p>Hover over the div element above, to see the transition effect.</p>
In Mozilla font color transition works well changing from black to white and in Chrome it just changes to white after specified time. How can I fix it?
I checked basic transition and it works well, but while adding animation on hover, the transition of color itself doesn't work. This is animation I'm trying achieve. Originally it's without font color transition.
Both color transition and animation work in separate, but when combined, the font color transition isn't working (in Google Chrome). You can check on Mozilla what I'm trying to achieve.
I'm not thrilled with this answer, but a pared down version of your code (without losing any of the pseudo-elements or effects like other answers here) shows inconsistent results on mouseIn and mouseOut after many repeated attempts. Every 3rd or 4th hover, the pseudo-element content >> will start to appear immediately, and then slowly solidify. The rest of the times I hover, it has the lag you're experiencing.
In summation, this looks like a WebKit rendering bug. I've filed one here: https://bugs.webkit.org/show_bug.cgi?id=163078 so I will check back once some progress has been made on that.
This pared down version does remove the delay in your Special effect text from showing, though. I normalized the transition timings for that.
.lightBtn {
width: 500px;
height: 49px;
color: #000000;
background: white;
display: inline-block;
}
.lightBtn:hover {
background: black;
color: white;
}
.lightBtn span {
display: inline-block;
position: relative;
transition: 0.25s;
}
.lightBtn span::after {
content: '>>';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.25s;
}
.lightBtn:hover span {
padding-right: 25px;
}
.lightBtn:hover span::after {
opacity: 1;
right: 0;
}
<button class="lightBtn"><span>Special effect</span></button>
<p>Hover over the div element above, to see the transition effect.</p>
If you have
transition: all 0.25s;
There is no need for
transition-duration: 0.2s;
-webkit-transition-duration: 0.2s;
the 0.25s will be the duration, in your case, it might be your browser version, becasue it works for me, and i'm using chrome.
Try to add this and see if it helps, since you said the time works, but no animation, so I would think it's becasue you still need the webkit prefix.
-webkit-transition: all 0.25s;
Well, let's go over a few things:
First you go on to declare transition-duration: 0.2s; and -webkit-transition-duration: 0.2s;, then you declare a transition: all 0.25s;, which overrides the value declared on the two previous properties.
You have all as the value for transition, this is not desirable as it hits performance.
If you set transition: all .25s; for setting the initial transition, then override the properties with a transition-property: background-color, border, box-shadow, color;, the transition should work just fine.
Here is a JSFiddle with your functional code.
If nothing done here works for you, then it might be that your browser is outdated, as already pointed out by everybody else.
Looks like same ff and chrome.
.lightBtn {
color: #000000;
background: white;
height: 49px;
border: 2px solid white;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
transition-duration: 0.2s;
-webkit-transition-duration: 0.2s;
border-radius: 0px 8px 8px 0px;
font-size: 16px;
font-family: Audiowide;
display: inline-block;
transition: all 0.25s;
cursor: pointer;
}
.lightBtn:hover {
background: black;
color: white;
border: 2px solid rgba(12, 1, 29, 0.87);
box-shadow: 0 8px 16px 0 rgba(50, 116, 165, 0.2), 0 6px 20px 0 rgba(51, 93, 206, 0.19);
}
<a class="lightBtn">
Hi guys!
</a>
<button class="lightBtn">
Wassup
</button>
What happens if you strip out all the other stuff so that the code is as basic as possible? Does this work? If so then you probably need to sort through some specificity issues or something along those lines... or maybe your chrome version is out of date (though that seems rather unlikely).
This works for me in chrome and FF btw.
<!DOCTYPE html>
<html>
<head>
<style>
.lightBtn {
width: 100px;
height: 100px;
color: #000000;
background: white;
height: 49px;
border: 2px solid white;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
transition-duration: 0.2s;
-webkit-transition-duration: 0.2s;
border-radius: 0px 8px 8px 0px;
font-size: 16px;
font-family: Audiowide;
display: inline-block;
transition: all 0.25s;
cursor: pointer;
}
.lightBtn:hover {
background: black;
color: white;
border: 2px solid rgba(12, 1, 29, 0.87);
box-shadow: 0 8px 16px 0 rgba(50, 116, 165, 0.2), 0 6px 20px 0 rgba(51, 93, 206, 0.19);
}
</style>
</head>
<body>
<span class="lightBtn"></span>
<p>Hover over the div element above, to see the transition effect.</p>
</body>
</html>

CSS border won't animate

For some reason, when I hover over the div, the border animates properly, but mousing off of it produces no transition. What am I missing?
http://codepen.io/anon/pen/XbPbvr
HTML:
<div class="test">
Test
</div>
LESS:
.test {
background: #eee;
border-bottom: none;
width: 300px;
height: 300px;
transition: border 100ms ease-out;
&:hover {
border-bottom: 5px solid black;
transition: border 100ms ease-out;
}
}
If you truly want no border, you can animate the color to transparent and the length to 0:
.test {
background: #eee;
border-bottom: 0px solid transparent;
width: 300px;
height: 300px;
transition: border 100ms ease-out;
}
.test:hover {
border-bottom: 5px solid black;
}
<div class="test">
Test
</div>
You can't animate to border-bottom: none, change that to border-bottom: RGBA(0,0,0,0) (or perhaps border-bottom: transparent if that works).
You also don't need "transition: border 100ms ease-out" in the hover scope.
Border can't be none. Try this:
.test {
background: #eee;
border-bottom: 5px solid transparent;
width: 300px;
height: 300px;
transition: border 100ms ease-out;
&:hover {
border-bottom: 5px solid black;
transition: border 100ms ease-out;
}
}

Opacity on elements with background image such as input field in IE7-IE8

I can't seem to get this working, although it should be possible in theory, I'm trying this for over a week now, but it's just doesn't work in IE7 or IE8, works as intended in FF, Chrome, Safari...
Code on fiddle => http://jsfiddle.net/xqQ7r/4/
HTML :
<div style="margin: 50px 0px 0px 250px;">
<input type="button" class="button" value="test button" />
</div>
CSS :
.button {
position: relative;
background-image: url('http://i.imgur.com/mxCABKj.png');
background-repeat: repeat-x;
background-position: left top;
height: 33px;
line-height: 31px;
min-width: 100px;
color: #ffffff;
font-size: 12px;
padding-right: 9px;
padding-left: 9px;
padding-bottom: 4px;
font-weight: bold;
/* text shadow */
text-shadow: 0px 1px 0px #4f4f4f;
/* borders */
border-radius: 3px;
border: 1px solid #333333;
box-shadow: 0px 0px 4px 0px #4f4f4f;
opacity: .75;
/* Standards Compliant Browsers */
filter: alpha(opacity=75);
/* IE 7 and Earlier */
/* Next 2 lines IE8 */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=75);
}
.button:hover {
opacity: 1;
filter: alpha(opacity=100);
/* IE 7 and Earlier */
/* Next 2 lines IE8 */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
cursor: pointer;
}
Thanks for all thoughts and solutions in advance.
actually, it is working.
i fiddled a modified version of your code here http://jsfiddle.net/xqQ7r/8/
I just modified opacity of the button to 0.25 and background-color to red so you can see the effect.
.button {
background-color:red;
opacity: 0.275;
}
Here is cross-browser .css for opacity
.transparent_class {
/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
/* IE 5-7 */
filter: alpha(opacity=50);
/* Netscape */
-moz-opacity: 0.5;
/* Safari 1.x */
-khtml-opacity: 0.5;
/* Good browsers */
opacity: 0.5;
}
You can always use jQuery.
$('.button').css('opacity', 0.275);

Trying to flip a triangle css

Been trying to follow and play with this fiddle: http://jsfiddle.net/bossy_nova/wBUW7/1/
I've been looking for a way to get this kinda triangle to become a downward facing triangle. Played with the rotations, and that didn't prove useful. Am I missing something?
So how do I flip this arrow? Thanks for you help in advance.
.triangle-with-shadow {
width: 100px;
height: 50px;
position: relative;
overflow: hidden;
box-shadow: 0 0px 0px -2px rgba(0,0,0,0.5);
}
.triangle-with-shadow:after {
content: "";
position: absolute;
width: 50px;
height: 50px;
background: #999;
transform: rotate(45deg);
-ms-transform:rotate(45deg); /* IE 9 */
-moz-transform:rotate(45deg); /* Firefox */
-webkit-transform:rotate(45deg); /* Safari and Chrome */
-o-transform:rotate(45deg); /* Opera */
top: 25px;
left: 25px;
box-shadow: -1px -1px 10px 0px rgba(0,0,0,0.5);
}​
Your transformations need to be in your main CSS, not in the :after state:
.triangle-with-shadow {
width: 100px;
height: 50px;
position: relative;
overflow: hidden;
box-shadow: 0 16px 10px -15px rgba(0,0,0,0.5);
transform: rotate(180deg);
-ms-transform:rotate(180deg); /* IE 9 */
-moz-transform:rotate(180deg); /* Firefox */
-webkit-transform:rotate(180deg); /* Safari and Chrome */
-o-transform:rotate(180deg); /* Opera */
}
Rotate a triangle 360 degrees from
http://www.identifydesign.net/tutorials/css/triangles-circles/
<style type="text/css">
.triangle2{
width:0;
height:0;
border-top:20px solid #000;
border-left:20px solid transparent;
border-right:20px solid transparent;
-webkit-transform:rotate(360deg);
}
</style>
<div class="triangle"></div>
Just apply the rotate transform to the main element. You'll also want to apply some margin to bring the top edge back into JSFiddle's field of view.
.triangle-with-shadow {
width: 100px;
height: 50px;
position: relative;
overflow: hidden;
box-shadow: 0 0px 0px -2px rgba(0,0,0,0.5);
transform: rotate(180deg);
-ms-transform:rotate(180deg); /* IE 9 */
-moz-transform:rotate(180deg); /* Firefox */
-webkit-transform:rotate(180deg); /* Safari and Chrome */
-o-transform:rotate(180deg); /* Opera */
margin-top: 15px;
}
.triangle-with-shadow:after {
content: "";
position: absolute;
width: 50px;
height: 50px;
background: #999;
transform: rotate(45deg);
-ms-transform:rotate(45deg); /* IE 9 */
-moz-transform:rotate(45deg); /* Firefox */
-webkit-transform:rotate(45deg); /* Safari and Chrome */
-o-transform:rotate(45deg); /* Opera */
top: 25px;
left: 25px;
box-shadow: -1px -1px 10px 0px rgba(0,0,0,0.5);
}​
JSFiddle
You could use the above answers or you could change the positioning...
.triangle-with-shadow {
width: 100px;
height: 50px;
position: relative;
overflow: hidden;
box-shadow: 0 -16px 10px -15px rgba(0,0,0,0.5);
}
.triangle-with-shadow:after {
content: "";
position: absolute;
width: 50px;
height: 50px;
background: #999;
transform: rotate(45deg);
-ms-transform:rotate(45deg); /* IE 9 */
-moz-transform:rotate(45deg); /* Firefox */
-webkit-transform:rotate(45deg); /* Safari and Chrome */
-o-transform:rotate(45deg); /* Opera */
top: -25px;
left: 25px;
box-shadow: -1px -1px 10px 0px rgba(0,0,0,0.5);
}​

Why is my CSS transition ending abruptly on mouse-out?

I was just testing few CSS transitions( I am beginner in CSS ). All of the transitions are going smooth. But in one of the transition, when mouseover is done transition plays smoothly, and as soon as you do a mouse out it abruptly ends. In all other cases, mouseover and mouseout both are playing fine.
What is the reason why the transition is ending in such manner? How to fix it? ( Fixed: Thanks to #Edwin ). Now, please explain Why it is not working with no changes.
jsbin: http://jsbin.com/oposof , http://jsbin.com/oposof/5 ( I am concerned about the first transition 'Triangle' ).
#container1 > div.triangle {
border-bottom: 80px solid red;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
width: 0px;
height: 0px;
-webkit-transition: all 1.2s ease-in-out;
}
#container1 > div.triangle:hover {
border-top: 80px solid green;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
}
#container1 > div.triangle:active {
border-left: 80px solid blue;
border-right: 60px solid transparent;
}
#container2 > div.testt {
color: red;
-webkit-transition: all 1s ease-in-out;
}
#container2 > div.testt:hover {
color:yellow;
}
#container3 > div.circle {
border-radius: 70px;
width: 100px;
height: 100px;
background: red;
-webkit-border-radius: 50px;
-webkit-transition: all 1.2s ease-in-out;
}
#container3 > div.circle:hover {
-webkit-border-radius: 20px;
-webkit-transform: rotate(-45deg);
}
I have used -webkit- , so the above demo will work only on chrome and safari. Added -moz- Now, you can test it on Mozilla too ( hopefully in IE as well ). http://jsbin.com/oposof/5
It seems the abruptness is due to the fact that by default it does not have a border on top, then on hover it suddenly has border on top. So in mouseout, instead of transitioning, what its doing is hiding the top border because there was no initial value to reference for transition.
Try this:
#container1 > div.triangle {
border-bottom: 80px solid red;
border-top: 0 solid green;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
width: 0px;
height: 0px;
-webkit-transition: all 1.2s ease-in-out;
}

Resources