dashed-border-generator icon indicating copy to clipboard operation
dashed-border-generator copied to clipboard

pro and cons of backgroud image vs border image

Open LifeIsStrange opened this issue 5 years ago • 5 comments
trafficstars

https://developer.mozilla.org/fr/docs/Web/CSS/border-image would the latter be more optimised by the browser ? Less pixel artifact ?

LifeIsStrange avatar Jun 05 '20 12:06 LifeIsStrange

Were you able to make it work as a border image? I tried copying the output and setting it as a border image but it didn't work.

Actually for my case I just want a border on one side of a div but I'm not sure how to make that work.

RheingoldRiver avatar Jun 15 '23 23:06 RheingoldRiver

Were you able to make it work as a border image? I tried copying the output and setting it as a border image but it didn't work.

No I've never used it but I believe it is a native alternative to background image, albeit the generative GUI of this library is still useful. I suppose the border image is a bit more performant and would also allow the simultaneous use of a background image for styling differently the interior of the element, but I'm not sure.

Actually for my case I just want a border on one side of a div but I'm not sure how to make that work.

Oh that has nothing to do with this library but if that's what you need you can simply use

.box {
  border-left: 1px solid red;
}

and padding Don't forget to use the autocompletion provided by your IDE ;) An alternative can sometimes be to use a ::before or after pseudo-element

LifeIsStrange avatar Jun 22 '23 17:06 LifeIsStrange

Well to be clear, I actually want a dashed border and control over the spaces between the dashes with my border-left. So I'm not sure how to do that.

RheingoldRiver avatar Jun 22 '23 20:06 RheingoldRiver

I don't think there is a css property for that but you can either handcraft it in SVG or use this library, the online demo expose the Dash Array to do something like that https://kovart.github.io/dashed-border-generator/#:~:text=It%27s%20a%20sequence%20of%20visible/invisible%20intervals. the bigger the number on the right, the bigger the spacing, it's a ratio

LifeIsStrange avatar Jun 23 '23 18:06 LifeIsStrange

what is all this scam going on ^ here? and tagging me

abhishekgahlot avatar Jan 24 '24 07:01 abhishekgahlot