0

I have html element:

<div style="grid-column: span 1">

I would like to use function to determine span size: I try something like this, but it doesn't render.

:style="{ 'grid-column: span': getColumnSize('string') }"

what is correct syntax?

3 Answers 3

1

use computed method. in computed method you can write a function that return your style as an object. then use it in your html.

<div :style="getColumnSize"></div>
computed: {
  getColumnSize() {
    return {
      gridColumn: 'span 1'
    }
  }
}

note: you should use camel case.

Sign up to request clarification or add additional context in comments.

Comments

0

i would store the value of span in data then place the value in style like this

<div :style="`grid-column : span ${spanValue}`"> new div with grid</div>

Comments

0

you can do like this


<div :style="{ 'grid-column': `span ${getColumnSize('string')}` }"></div>


Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.