Here is a new, easy method that works across most browsers that I'd like to share.
'dotted' doesn't work consistently across all browsers! The 'dotted' border style appears round in Firefox and square in Chrome, with strange behavior during resizing.
- Create a simple SVG file with two colors represented as square elements:
<?xml version="1.0" encoding="utf-8"?>
<svg class="it-dotted-line" xmlns="http://www.w3.org/2000/svg" width="8" height="8">
<rect width="4" height="4" style="fill:#F4EDF4"></rect>
<rect x="4" width="4" height="4" style="fill:#B489B4"></rect>
</svg>
The height is also 8 so the image is squared, making it easier to manipulate.
- Save the file as an .svg and upload it to your hosting server to be used with
border-image
.
Simply paste the code into your editor and save it as an .svg file.
- The CSS styling:
.dots {
-o-border-image: url(/svg-dotted.svg) 25% repeat; /* Opera 11-12.1 */
-webkit-border-image: url(/svg-dotted.svg) 25% repeat ; /* Safari 3.1-5 */
border-image: url(/svg-dotted.svg) 25% repeat;
border-width: 0px; // Only applies to top border - remove for others
border-top-width: 10px;
border-style: solid;
}
Result (top of a footer):
https://i.sstatic.net/E4dxv.jpg
Note: Internet Explorer 10 and earlier do not support the border-image property.