Fill SVG path element with a background-image

You can do it by making the background into a pattern: <defs> <pattern id=”img1″ patternUnits=”userSpaceOnUse” width=”100″ height=”100″> <image href=”wall.jpg” x=”0″ y=”0″ width=”100″ height=”100″ /> </pattern> </defs> Adjust the width and height according to your image, then reference it from the path like this: <path d=”M5,50 l0,100 l100,0 l0,-100 l-100,0 M215,100 a50,50 0 1 1 -100,0 … Read more

How do I combine a background-image and CSS3 gradient on the same element?

Multiple backgrounds! body { background: #eb01a5; background-image: url(“IMAGE_URL”); /* fallback */ background-image: url(“IMAGE_URL”), linear-gradient(#eb01a5, #d13531); /* W3C */ } These 2 lines are the fallback for any browser that doesn’t do gradients. See notes for stacking images only IE < 9 below. Line 1 sets a flat background color. Line 2 sets the background image … Read more

Java: maintaining aspect ratio of JPanel background image

Well, the quickest and easiest solution is to use Image.getScaledInstance g.drawImage(img.getScaledInstance(newWidth, -1, Image. SCALE_SMOOTH), x, y, this); If your wondering about the negative number, the java docs say: If either width or height is a negative number then a value is substituted to maintain the aspect ratio of the original image dimensions. If both width … Read more

Using percentage values with background-position on a linear-gradient

TL;DR All the percentage values used with background-position are equivalent when using a gradient as background, so you won’t see any difference. You need to specify a background-size different from the container size: body { display: flex; flex-direction: column; justify-content: space-around; align-items: center; min-height:90vh; } .button { text-decoration: none; color: white; font-weight: bold; width: 350px; … Read more

How to fade animate background images (full size) [closed]

This is how I would do it with a couple of jQ lines: var $bg = $(‘#bg’), $bgDIV = $(‘div’, $bg), // Cache your elements n = $bgDIV.length, // count them (used to loop with % reminder) c = 0; // counter (function loopBG(){ $bgDIV.eq(++c%n).hide().appendTo($bg).fadeTo(3000,1, loopBG); }()); // start fade animation *{margin:0; padding:0;} body{ width:100%; … Read more