SVG background in firefox - css

Working on my friend's website and I can't figure out how to display the SVG right in Firefox. In Edge it also disappears while I'm resizing the browser.
http://lene.isreborn.com/
CSS - (I have to use important because it's Wordpress):
header::after {
content:"";
display: block;
background: url(/svg-filer/header-background.svg);
background-size: contain;
background-repeat: no-repeat;
top: 0;
left:-1%;
width: 102% !important;
height: 90px !important;
position: absolute;
z-index: -1;
-ms-transition: top ease .5s;
-moz-transition: top ease .5s;
-webkit-transition: top ease .5s;
transition: top ease .5s;
}
header.sticky-active::after {
top: -20px;
}
SVG File:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="100%" height="90px" viewBox="0 0 1920 90" preserveAspectRatio="none">
<polygon id="XMLID_3_" fill="#FFFF00" points="1,99.7 1399.2,130 1921,99.7 1921,0 1,0 "/>
</svg>

I've got it right now:
The background-size does not work with 'contain' but with 100% 100%,
See
Mozilla Background rules
Link to developer site: See here
header::after {
content:"";
display: block;
background: url(/svg-filer/header-background.svg);
background-size: 100% 100% !important;
background-repeat: no-repeat;
top: 0;
left:-1%;
width: 102% !important;
height: 90px !important;
position: absolute;
z-index: -1;
-ms-transition: top ease .5s;
-moz-transition: top ease .5s;
-webkit-transition: top ease .5s;
transition: top ease .5s;
}
header.sticky-active::after {
top: -20px;
}

The image actually is white, right? If you change the fill-color to #000, you will see an image:
<polygon id="XMLID_3_" fill="#000" points="1,99.7 1399.2,130 1921,99.7 1921,0 1,0 "/>
https://jsfiddle.net/fbwsh1pf/

Related

Why does Google Chrome round all svg icons during animation with mix-blend-mode: multiply?

On hover, only the green svg icon (first) should smoothly change its opacity to 1.
But instead, in Google Chrome (tested on 97 and 99 version), all other svg icons inherit border-radius: 25px; for the duration of the animation, although this is not provided by anything.
.wrapper {
display: flex;
will-change: opacity;
overflow: hidden;
border-radius: 25px;
background: #ccc;
}
.wrapper:hover .first {
opacity: 1;
}
.first {
opacity: 0.5;
background: green;
transition: 0.5s color ease-in-out, 0.5s opacity ease-in-out;
}
.second {
mix-blend-mode: multiply;
background: red;
}
.third {
mix-blend-mode: multiply;
background: blue;
}
<div class="wrapper">
<svg width="50" height="50" xmlns="http://www.w3.org/2000/svg" class="first"/>
<svg width="50" height="50" xmlns="http://www.w3.org/2000/svg" class="second"/>
<svg width="50" height="50" xmlns="http://www.w3.org/2000/svg" class="third"/>
</div>
Example on gif:
Deleting will-change: opacity; makes this bug more strange:
Only deleting mix-blend-mode: multiply; resolve this bug:
Why it happend? How to fix it?
This bug does not reproduce on FireFox and Safari.
UPD: Created issue here: https://bugs.chromium.org/p/chromium/issues/detail?id=1304627

css data:image won't show in Firefox 58

I have trouble showing the data:image svg.
On my website I use this css snippet:
#menu > .close:before, #menu > .close:after {
-moz-transition: opacity 0.2s ease;
-webkit-transition: opacity 0.2s ease;
-ms-transition: opacity 0.2s ease;
transition: opacity 0.2s ease;
content: '';
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: 2em 2em;
}
#header nav ul li a[href="#menu"]:before {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cstyle%3Eline %7B stroke-width: 8px%3B stroke: %23f2849e%3B %7D%3C/style%3E%3Cline x1='0' y1='25' x2='100' y2='25' /%3E%3Cline x1='0' y1='50' x2='100' y2='50' /%3E%3Cline x1='0' y1='75' x2='100' y2='75' /%3E%3C/svg%3E");
opacity: 0;
}
#header nav ul li a[href="#menu"]:after {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cstyle%3Eline %7B stroke-width: 8px%3B stroke: %23585858%3B %7D%3C/style%3E%3Cline x1='0' y1='25' x2='100' y2='25' /%3E%3Cline x1='0' y1='50' x2='100' y2='50' /%3E%3Cline x1='0' y1='75' x2='100' y2='75' /%3E%3C/svg%3E");
opacity: 1;
}
It shows correctly in Chrome and used to show correctly in Firefox 57. But with the new update to Firefox 58 no svg file is shown anymore. So I looked into it and while inspecting the layout files in Firefox I saw that the above lines get Base64 encoded to e.g.
background-image: url("data:image/svg+xml;charset=utf8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+PHN0eWxlPmxpbmV7c3Ryb2tlLXdpZHRoOjhweDtzdHJva2U6IzU4NTg1OH08L3N0eWxlPjxwYXRoIGQ9Ik0wIDI1SDFlMnoiIC8+PHBhdGggZD0iTTAgNTBIMWUyeiIgLz48cGF0aCBkPSJNMCA3NUgxZTJ6IiAvPjwvc3ZnPg==");
Which won't display a svg file. I have no clue how to solve this problem. Maybe someone has an idea. Thanks.
Looks like your base64 data is incorrect. The below code worked for me (Pen)
Also you are missing the content property. Please take care of it, as its a mandatory property for the :before and :after pesudo elements.
.b:before {
content: "";
height: 100px;
width: 100px;
display: block;
background-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNi4wLjQsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkNhcGFfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHdpZHRoPSIxNnB4IiBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMTYgMTYiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPHBhdGggZD0iTTgsMEMzLjU4MiwwLDAsMy41ODIsMCw4czMuNTgyLDgsOCw4czgtMy41ODIsOC04UzEyLjQxOCwwLDgsMHogTTksMTJjMCwwLjU1Mi0wLjQ0OCwxLTEsMXMtMS0wLjQ0OC0xLTFWNw0KCWMwLTAuNTUyLDAuNDQ4LTEsMS0xczEsMC40NDgsMSwxVjEyeiBNOCw1LjAxNmMtMC41NTIsMC0xLTAuNDQ4LTEtMWMwLTAuNTUyLDAuNDQ4LTEsMS0xczEsMC40NDgsMSwxQzksNC41NjgsOC41NTIsNS4wMTYsOCw1LjAxNnoNCgkiLz4NCjwvc3ZnPg==");
}

I'm having trouble controlling an animated svg border using CSS

I've been trying to animate a svg border, I've gotten as far as this
html {
background: white;
}
div {
position: fixed;
height: 200px;
width: 605px;
position: fixed;
left: 30%
}
.mainNav {
position: fixed;
top: 6;
}
[class="navBorder"] .outline {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
stroke: #7272f8;
stroke-width: 11px;
fill: none;
}
.navBorder .outline {
stroke-dasharray: 2000;
stroke-dashoffset: 1900;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-o-transition: 0.5s;
transition: 0.5s;
}
.navBorder:hover .outline {
stroke-dasharray: 1100 0;
stroke-dashoffset: 0;
}
<div>
<a class="navBorder" target="_blank">
<svg height="100%" width="100%" xmlns="http://www.w3.org/2000/svg">
<rect class="outline" height="100%" width="100%" />
</svg>
</a>
</div>
http://codepen.io/lorehill/pen/pEPXar
The problem is I can't seem to get the starting position of the border to be on the top center and then close center bottom.
I'm very confused trying to figure out how to calculate the values I need to set stroke-dasharray and stroke-dashoffset for the starting position in order to get the effect I'm after.
If anyone could explain it like I'm 5 that would be fantastic.
Thank you!
AFAIK, the starting position of the stroke is always the starting point of the rect which is top left for a rect element.
I can't seem to get the starting position of the border to be on the top center and then close center bottom.
I think you'll need two polyline elements for that, although you can use the same class on both.
svg {
height: 100px;
margin: 1em;
}
.outline {
fill: lightblue;
stroke-dasharray: 200;
stroke-dashoffset: 190;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-o-transition: 0.5s;
transition: 0.5s;
}
svg:hover .outline {
stroke-dasharray: 200 0;
stroke-dashoffset: 0;
}
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 100 100">
<polyline class="outline" points="50,0 100,0, 100,100 50,100" style="stroke:#660000; stroke-width: 3;" />
<polyline class="outline" points="50,0 0,0 0,100 50,100" style="stroke:#660000; stroke-width: 3;" />
</svg>
Codepen Demo

Fill image/button with colour on hover

I'm completely new to CSS & Wordpress, I've spent all night trying and looking for a solution to this - so hopefully you can help me.
I have this image, and when someone hovers over it I want the white/see-through portion in the middle to fill with the colour #f7ca18 from the bottom to the top
http://wp.tek-monkey.com/wp-content/uploads/2015/06/circle1_test_seethrough.png
I've tried the following just to try and get a simple transition from the white/see-through inner to my desired colour, however none of them have worked. I'm not sure if I'm doing something wrong in wordpress; under appearance>editor I paste the css code at the bottom, and then on the page with the image I edit the image and type into the box (Image CSS Class) .circle-testfor example.
.circle-test {
background: #ffffff;
transition-property: background;
transition-duration: 1s;
transition-timing-function: linear;
}
.circle-test:hover {
background: #f7ca18;
}
.circle-test:hover{
background-color: #f7ca18;
}
.circle-test{
background:none;
}
.circle-test:hover{
background:#f7ca18;
}
Totally doable. The trick to this is adding a border-radius of 100% to create a circle around the image. Here are three ways you can do this.
Codepen
I also cropped & re-exported your image so that it's a perfect 275px square (If you ever need to do bg transitions on an irregularly-shaped image, you could look into SVG). You're more than welcome to download that image and use it instead!
I did this kind of quickly, so let me know if you have any questions!
/* Option 1: Image only */
.circle-test {
display: block;
margin: 0 auto;
border-radius: 100%;
background-image: url('http://www.heavilyedited.com/hands-temp.png');
background-repeat: no-repeat;
-webkit-transition: background 1s linear;
-moz-transition: background 1s linear;
transition: background 1s linear;
}
.circle-test:hover {
background-color: #f7ca18;
}
/* Option 2: Div with background image*/
.circle-test2 {
display: block;
width: 275px;
height: 275px;
margin: 0 auto;
border-radius: 100%;
background-image: url('http://www.heavilyedited.com/hands-temp.png');
background-repeat: no-repeat;
transition: background 1s linear;
}
.circle-test2:hover {
background-color: #1D9B8D;
}
/* Option 3: Image is inside div*/
.circle-test3 {
display: block;
width: 275px;
height: 275px;
margin: 0 auto;
border-radius: 100%;
background-image: url('http://www.heavilyedited.com/hands-temp.png');
background-repeat: no-repeat;
-webkit-transition: background 1s linear;
-moz-transition: background 1s linear;
transition: background 1s linear;
}
.circle-test3:hover {
background-color: #00aeef;
}
<!-- Option 1: Image only -->
<img src="http://www.heavilyedited.com/hands-temp.png" class="circle-test"/>
<!-- Option 2: Div with background image -->
<div class="circle-test2">
</div>
<!-- Option 3: Image is inside div-->
<div class="circle-test3">
<img src="http://www.heavilyedited.com/hands-temp.png" />
</div>

CSS transition acting weird

I have page with a SVG in it and I want to use transition to change the color slow when hovering over the image. But I can't get it to work. Can anyone please see what I'm doing wrong?
fiddle:
http://jsfiddle.net/67vG4/1/
Html:
<svg height="67px" id="insta" style="enable-background:new 0 0 67 67;" version="1.1" viewBox="0 0 67 67" width="67px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path id="path" d="M42.271,26.578v-0.006c0.502,0,1.005,0.01,1.508-0.002 c0.646-0.016,1.172-0.57,1.172-1.217c0-0.963,0-1.927,0-2.89c0-0.691-0.547-1.24-1.236-1.241c-0.961,0-1.922-0.001-2.883,0 c-0.688,0.001-1.236,0.552-1.236,1.243c-0.001,0.955-0.004,1.91,0.003,2.865c0.001,0.143,0.028,0.291,0.073,0.426 c0.173,0.508,0.639,0.82,1.209,0.823C41.344,26.579,41.808,26.578,42.271,26.578z M33,27.817c-3.384-0.002-6.135,2.721-6.182,6.089 c-0.049,3.46,2.72,6.201,6.04,6.272c3.454,0.074,6.248-2.686,6.321-6.043C39.254,30.675,36.462,27.815,33,27.817z M21.046,31.116 v0.082c0,4.515-0.001,9.03,0,13.545c0,0.649,0.562,1.208,1.212,1.208c7.16,0.001,14.319,0.001,21.479,0 c0.656,0,1.215-0.557,1.215-1.212c0.001-4.509,0-9.02,0-13.528v-0.094h-2.912c0.411,1.314,0.537,2.651,0.376,4.014 c-0.161,1.363-0.601,2.631-1.316,3.803s-1.644,2.145-2.779,2.918c-2.944,2.006-6.821,2.182-9.946,0.428 c-1.579-0.885-2.819-2.12-3.685-3.713c-1.289-2.373-1.495-4.865-0.739-7.451C22.983,31.116,22.021,31.116,21.046,31.116z M45.205,49.255c0.159-0.026,0.318-0.049,0.475-0.083c1.246-0.265,2.264-1.304,2.508-2.557c0.025-0.137,0.045-0.273,0.067-0.409 V21.794c-0.021-0.133-0.04-0.268-0.065-0.401c-0.268-1.367-1.396-2.428-2.78-2.618c-0.058-0.007-0.113-0.02-0.17-0.03H20.761 c-0.147,0.027-0.296,0.047-0.441,0.08c-1.352,0.308-2.352,1.396-2.545,2.766c-0.008,0.057-0.02,0.114-0.029,0.171V46.24 c0.028,0.154,0.05,0.311,0.085,0.465c0.299,1.322,1.427,2.347,2.77,2.52c0.064,0.008,0.13,0.021,0.195,0.03H45.205z M33,64 C16.432,64,3,50.568,3,34C3,17.431,16.432,4,33,4s30,13.431,30,30C63,50.568,49.568,64,33,64z" />
</svg>
Css:
#insta {
display: block;
float: right;
margin-bottom: 10px;
height: 40px;
margin-right: -12px;
-webkit-transition: fill 2s;
-moz-transition: fill 2s;
-o-transition: fill 2s;
transition: fill 2s;
}
#insta:hover {
fill: #ff0000;
}
Ok, I've tried a couple of different things and the only thing that seems to work for me (except changing browser) is when I remove everything but the svg from my body section. Does that mean that I have coded anything wrong you think?
I think your syntax isn't right for the transition.
Try:
-webkit-transition: fill 2s ease-out;
transition: fill 2s ease-out;
Also if you set the transition on #insta:hover it will transition back.
#insta:hover {
fill: #ff0000;
-webkit-transition: fill 2s ease-out;
transition: fill 2s ease-out;
}
Its working fine for me (Using Chrome 34), just edited the CSS to show the full image.
The HTML:
<!DOCTYPE html>
<body>
<svg id="insta" style="enable-background:new 0 0 67 67;" width="100" height="100">
<path id="path" d="M42.271,26.578v-0.006c0.502,0,1.005,0.01,1.508-0.002 c0.646-0.016,1.172-0.57,1.172-1.217c0-0.963,0-1.927,0-2.89c0-0.691-0.547-1.24-1.236-1.241c-0.961,0-1.922-0.001-2.883,0 c-0.688,0.001-1.236,0.552-1.236,1.243c-0.001,0.955-0.004,1.91,0.003,2.865c0.001,0.143,0.028,0.291,0.073,0.426 c0.173,0.508,0.639,0.82,1.209,0.823C41.344,26.579,41.808,26.578,42.271,26.578z M33,27.817c-3.384-0.002-6.135,2.721-6.182,6.089 c-0.049,3.46,2.72,6.201,6.04,6.272c3.454,0.074,6.248-2.686,6.321-6.043C39.254,30.675,36.462,27.815,33,27.817z M21.046,31.116 v0.082c0,4.515-0.001,9.03,0,13.545c0,0.649,0.562,1.208,1.212,1.208c7.16,0.001,14.319,0.001,21.479,0 c0.656,0,1.215-0.557,1.215-1.212c0.001-4.509,0-9.02,0-13.528v-0.094h-2.912c0.411,1.314,0.537,2.651,0.376,4.014 c-0.161,1.363-0.601,2.631-1.316,3.803s-1.644,2.145-2.779,2.918c-2.944,2.006-6.821,2.182-9.946,0.428 c-1.579-0.885-2.819-2.12-3.685-3.713c-1.289-2.373-1.495-4.865-0.739-7.451C22.983,31.116,22.021,31.116,21.046,31.116z M45.205,49.255c0.159-0.026,0.318-0.049,0.475-0.083c1.246-0.265,2.264-1.304,2.508-2.557c0.025-0.137,0.045-0.273,0.067-0.409 V21.794c-0.021-0.133-0.04-0.268-0.065-0.401c-0.268-1.367-1.396-2.428-2.78-2.618c-0.058-0.007-0.113-0.02-0.17-0.03H20.761 c-0.147,0.027-0.296,0.047-0.441,0.08c-1.352,0.308-2.352,1.396-2.545,2.766c-0.008,0.057-0.02,0.114-0.029,0.171V46.24 c0.028,0.154,0.05,0.311,0.085,0.465c0.299,1.322,1.427,2.347,2.77,2.52c0.064,0.008,0.13,0.021,0.195,0.03H45.205z M33,64 C16.432,64,3,50.568,3,34C3,17.431,16.432,4,33,4s30,13.431,30,30C63,50.568,49.568,64,33,64z" />
</svg>
</body>
The CSS:
#insta {
display: block;
float: right;
margin-bottom: 10px;
margin-right: -12px;
-webkit-transition: fill 2s;
-moz-transition: fill 2s;
-o-transition: fill 2s;
transition: fill 2s;
}
#insta:hover {
fill: #ff0000;
}
Here is the fiddle:
http://jsfiddle.net/kBM9U/1/

Resources