Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to control the width of SVG? #12

Open
jo-narae opened this issue Apr 13, 2018 · 3 comments
Open

How to control the width of SVG? #12

jo-narae opened this issue Apr 13, 2018 · 3 comments

Comments

@jo-narae
Copy link

Hello, lindell!
The width option of the current vue-barcode is the width option of the bar.
However, in addition to adjusting the barcode width, I need a way to control the width of the SVG.

I don't know how to control SVG width.
I would thank it if you could tell me.
Have a nice day. thank you.

@jamesriady
Copy link

have you solved it?

@tngmichael
Copy link

I try this to adjust the container's width, still not a neat solution

<vue-barcode ref="barcode" ... ></vue-barcode>
...
// in updated() or somewhere after jsbarcode rendered
const el = this.$refs.barcode.$el
const svg = el.getElementsByClassName('vue-barcode-element')[0]
const rect = svg.getElementsByTagName('rect')
const attr = rect[rect.length - 1].attributes
const width = Number(attr.x.value) + Number(attr.width.value)
el.style = `width: ${width}px;` // or max-width

@seaklengfc
Copy link

Css: transform: scale(.7);

It seems late but hope can help others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants