I'm trying to use SVG to create a dotted border around an HTML block with a fixed width but flexible height. I'm tantalisingly close but can't get the bottom to display.
Here is a fiddle (the fiddle has the SVG image included, so it can be inline there URL encoded elements, specifically #
is %23
)
The SVG code looks like this:
<svg width="300px" height="100%" xmlns="http://www.w3.org/2000/svg">
<rect x="5" y="5" width="290" height="100%"
style="fill: yellow; fill-opacity: 0.5; stroke: #009fe3; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1 7"/>
</svg>
The CSS like this:
div.block {
box-sizing: border-box;
padding: 10px;
width: 300px;
background-image: url("dotted-border.svg");
}
I guess what I want is to offset the rectangle from the bottom, but it needs to be a pixel value (5px
). It looks like what I want will be trivial with wider SVG 2 adoption (http://www.w3.org/Graphics/SVG/WG/wiki/Proposals/Stroke_position) as then the stroke could be positioned inside the shape.
I know I could just add another image and use CSS :after
, but I'm curious!
preserveAspectRatio
attribute but the dotted lines will look stretched or squeezed according to the content height : jsfiddle.net/eoLppgty/1 – web-tiki