Is it possible to have the < use > element display the rect tooltip, on mouse over, with modern browsers?
As specified by 15.2.1 The hint element.
<svg id="schematic" version="1.2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<symbol id="pnp-transistor">
<image xlink:href="transistor.png" height="32px" width="32px" />
<rect y="0" x="0" height="6px" width="32px">
<title>collector</title>
<hint>collector</hint>
</rect>
<rect y="27" x="0" height="6px" width="32px">
<title>emitter</title>
<hint>emitter</hint>
</rect>
<rect y="0" x="0" height="32px" width="6px">
<title>base</title>
<hint>base</hint>
</rect>
</symbol>
<use xlink:href="#pnp-transistor"></use>
</svg>
There appears to be no way to do this without JavaScript, using getBoundingClientRect() to location the position of the SVG in the DOM. Good stuff in here: How to add a tooltip to an svg graphic. Even then, I'm not sure how well supported and easy to style that direction would be.
However, a possible workaround is to add another wrapper around symbol and tie CSS into it when hovering on the pseudoclass. Using attr(data-tooltip) is not as nice as using content directly inherited by the symbol, but it's not a terrible second place.
For example:
<div class="wrapper" data-tooltip="SVG Tooltip (almost)">
<svg class="icon"><use xlink:href="#some-id"></use></svg>
</div>
...
.wrapper:after {
position: absolute;
left: 50%;
transition: 0.5s;
content: attr(data-tooltip);
white-space: nowrap;
opacity: 0;
font-size: 1.5rem;
transform: translate(-50%, 0);
}
.wrapper:hover:after {
position: absolute;
opacity: 1;
transform: translate(-50%, 0.5em);
}
Codepen: SVG With Pure CSS Tooltip
Related
I am trying to get an svg to follow a path. But the svg circle just stays in one place and does not follow the path.
.LineSvg {
fill: none;
stroke: $blue;
position: absolute;
margin-top: -2px;
left: 700px;
}
<svg xmlns="http://www.w3.org/2000/svg" width="1167.85" height="841.719" viewBox="0 0 1167.85 841.719" className={styles.LineSvg}>
<path fill="none" id="wire" d="M-4766.667-2093.939s292-358.061,476-223.394S-4269.333-1874.667-3952-2028s221.818-437.333,9.576-338.667-154.546,321.212,151.515,272.727,193.333-429.818,17.576-487.394S-4220-2402.667-4429.333-2432s-317.333-102.667-257.333-232,429.091-48.121,474.545-163.273" transform="translate(4767.054 2827.456)" />
<circle cx="123.2" cy="646" r="11.7" fill="#63c6be" >
<animateMotion
dur="2.2s"
/>
<mpath xlinkHref="#wire"></mpath>
<animateMotion />
</circle>
</svg>
It should start at the beginning of the path (line) and move to the top of the line.
There are a number of syntactical errors in the markup that prevent animation. When these are fixed the animation takes place off the screen because the path's transform is ignored by the mpath element.
The syntax is fixed below and I've adjusted the viewBox so the animation is visible.
I've removed the non-functional transform on the path element.
I've also added a fill="freeze" otherwise the circle disappears at the end as the path's displacement is so large.
Finally I've made the circle bigger so you can still see it in the larger viewBox.
.LineSvg{
fill: none;
stroke: $blue;
position: absolute;
margin-top: -2px;
left: 700px;
}
<svg xmlns="http://www.w3.org/2000/svg" width="1167.85" height="841.719" viewBox="-5000 -3000 5000 5000" className={styles.LineSvg} >
<path fill="none" id="wire" d="M-4766.667-2093.939s292-358.061,476-223.394S-4269.333-1874.667-3952-2028s221.818-437.333,9.576-338.667-154.546,321.212,151.515,272.727,193.333-429.818,17.576-487.394S-4220-2402.667-4429.333-2432s-317.333-102.667-257.333-232,429.091-48.121,474.545-163.273" />
<circle cx="123.2" cy="646" r="111.7" fill="#63c6be" >
<animateMotion
dur="2.2s" fill="freeze"
>
<mpath xlink:href="#wire"></mpath>
</animateMotion>
</circle>
</svg>
I want to move a svg element outside of it's container but is hiding. I enabled overflow: visible still can't figured out the problem.
I created the svg with figma. Clip content is disabled
Here you have the code & a photo to better see the problem.
This SVG code might be helpful... Open this Snippet in full view..
/** Animation Boxes (Moving on cursor move) **/
.showcase-animation-container {
position: absolute;
right: 350px;
width: 500px;
height: 500px;
svg {
position: absolute;
top: 0;
left: 0;
overflow: visible !important;
width: 100%;
height: 100%;
}
}
.left-triangle { transform-origin: center center }
.left-triangle {
transform: translate(-180px, -70px) rotate(-50deg);
fill: red;
}
<div class="showcase-animation-container">
<svg width="736" height="589" viewBox="-80 0 556 589" fill="none" xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_f)" style="
/* margin-left: 180px; */
">
<path class="left-triangle" d="M12.6269 323.5L130 82.9806L247.373 323.5H12.6269Z" stroke="black" stroke-width="7"></path>
<path d="M389.373 265.5L272 506.019L154.627 265.5H389.373Z" stroke="black" stroke-width="7"></path>
<path d="M308.627 323.5L426 82.9806L543.373 323.5H308.627Z" stroke="black" stroke-width="7"></path>
</g>
<defs>
<filter id="filter0_f" x="-180" y="-7" width="736" height="589" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood>
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend>
<feGaussianBlur stdDeviation="3.5" result="effect1_foregroundBlur"></feGaussianBlur>
</filter>
</defs>
</svg>
</div>
I updated the svg element, you can check it in the gist, i just increased the frame size in figma.
I need some help about svg's. There is a "background image". Another "image" is laid over it. The "image" has to have a hole cut out of it so that the background image is shining through. I achieved this by using svg:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
<style>
body{
background-repeat: no-repeat;
background-size: cover;
}
#svg-door {
background-image: url(http://pcdn.500px.net/15548893/7f3b7c411716b1fb29c5cffb3efcf8ce33eacd76/15.jpg);
background-size: cover;
box-sizing: border-box;
padding: 100px;
width: 100%;
height: 500px;
}
#wood {
border-radius: 50%;
}
</style>
</head>
<body background="https://www.w3schools.com/css/img_fjords.jpg" >
<svg xmlns="http://www.w3.org/2000/svg" id="svg-door">
<defs>
<pattern id="wood" patternUnits="userSpaceOnUse" width="1024" height="768">
<image xlink:href="http://i.imgur.com/Ljug3pp.jpg" x="0" y="0" width="1024" height="768"/>
</pattern>
</defs>
<path xmlns="http://www.w3.org/2000/svg" d=" M0,0 225,0 225,300 0,300 z M105,50, 180,50 180,80 105,80 z "
fill="url(#wood)" fill-rule="evenodd"/>
</svg>
</body>
I could not use mask filters of css cause of browser compatibility. I dont want to use a svg/js framework.
So far so good. Now i want to go a step further.
I want this hole to have a transparent gradient. So that the inner rects borders are not that hard as in current version. I dont know how to do it.
Furthermore i want to animate this hole to get bigger over time. I would do it by using js. Is there another way? Maybe by changing the whole structure of html?
Any help is appreciated.
Firstly, there should be no issue with masks applied to SVG elements. There are some browser compatibility related to SVG masks being applied to HTML elements, but not when they are applied to SVG elements.
In fact a mask is the obvious solution to your issue. To get the soft edges to the hole, we'll apply a blur filter to a rectangle, then use that as a mask to create the hole.
body{
background-repeat: no-repeat;
background-size: cover;
}
#svg-door {
background-image: url(http://pcdn.500px.net/15548893/7f3b7c411716b1fb29c5cffb3efcf8ce33eacd76/15.jpg);
background-size: cover;
box-sizing: border-box;
padding: 100px;
width: 100%;
height: 500px;
}
#wood {
border-radius: 50%;
}
<
<body background="https://www.w3schools.com/css/img_fjords.jpg" >
<svg xmlns="http://www.w3.org/2000/svg" id="svg-door">
<defs>
<pattern id="wood" patternUnits="userSpaceOnUse" width="1024" height="768">
<image xlink:href="http://i.imgur.com/Ljug3pp.jpg" x="0" y="0" width="1024" height="768"/>
</pattern>
<mask id="hole">
<rect width="100%" height="100%" fill="white"/>
<path d="M105,50, 180,50 180,80 105,80 z" filter="url(#hole-blur)"/>
</mask>
<filter id="hole-blur">
<feGaussianBlur stdDeviation="2"/>
</filter>
</defs>
<path d="M0,0 225,0 225,300 0,300 z" fill="url(#wood)" mask="url(#hole)"/>
</svg>
</body>
Alright, so I have an SVG sprite that I want to place in my HTML.
<svg class="icon-minus"><use xlink:href="#icon-minus"></use></svg>
It has this as CSS (stylus):
.icon-minus
display: inline-block
width: 1em
height: 1em
fill: black
Te SVG itself is in the HTML also (placed near the bottom of but not all the way, contained in a div):
<svg style="position: absolute; width: 0; height: 0;" width="0" height="0" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-minus" viewBox="0 0 24 24">
<title>minus</title>
<path class="path1" d="M3 11h18q0.414 0 0.707 0.293t0.293 0.707-0.293 0.707-0.707 0.293h-18q-0.414 0-0.707-0.293t-0.293-0.707 0.293-0.707 0.707-0.293z"></path>
</symbol>
</defs>
It may be important to know that the the entirety of this is injected using jQuery .load, so it's not there on initial page load. This includes both the SVG and the SVG markup. They are injected together.
The SVG is not visible onscreen.
I'm not sure if something like this is possible through CSS, but then again the talented folks in this community have proven me wrong numerous of times so here we go!
I was wondering if it is possible for certain horizontal parts of the letters O, U, and E can respond with with the window's width while maintaining its position? On the image below, I have drawn out how the responsive typography reacts to the window scale. Please note that the set type are placed within a page-wrap and placed vertically in the middle of the window.
How might I accomplish this? And should what format should I work with (svg, shapes, etc.)
Thank you in advance!
You can do it simply by just having overlaid elements inside a div with overflow:hidden: the extended letter shapes are created with SVG, and hidden underneath the left hand divs. When the user resizes the window, the right div slides out revealing the elongated parts. eg.
<div id="clipper">
<svg id="leftpart" x="0px" y="0px" width="30px" height="150px">
<rect x="0" y="0" width="30" height="150" fill="red"/>
</svg>
<svg id="rightpart" x="0px" y="0px" width="2000px" height="150px">
<rect x="0" y="0" width="2000" height="30" fill="black"/>
<rect x="0" y="60" width="2000" height="30" fill="black"/>
<rect x="0" y="120" width="2000" height="30" fill="black"/>
</svg>
</div>
#clipper{
position: absolute;
top:200px;
left:200px;
width:40%;
overflow: hidden;
}
#rightpart {
position: relative;
z-index:1;
}
#leftpart {
position: absolute;
z-index:2;
}
Here is an example of scaling SVG elements based on screen width. This would depend on having a way to select the character elements you're trying to modify (for instance, the bottom of the bowl of the U). In this example, the rectangle element has a unique ID.
HTML:
<svg version="1.1"
baseProfile="full"
width="200" height="200"
xmlns="http://www.w3.org/2000/svg">
<rect id="foo" height="100" width="100" />
</svg>
CSS:
#foo {
fill: #f00;
transform: scaleX(0.5);
}
#media only screen and (min-width: 500px) {
#foo {
transform: scaleX(2);
}
}
http://jsfiddle.net/bangarang/tgcw1fop/