简体   繁体   English

设置Vuetify扩展面板组件的最大宽度

[英]Setting max-width of vuetify expansion panel component

在此处输入图片说明

I'm trying to build a webpage with vuetify and nuxt. 我正在尝试使用vuetify和nuxt构建网页。 I'm trying to set the max-width property of the expansion panel ui component ( https://vuetifyjs.com/en/components/expansion-panels ). 我正在尝试设置扩展面板ui组件( https://vuetifyjs.com/en/components/expansion-panels )的max-width属性。 I have: 我有:

<div id="app"     max-width="800">
  <v-app id="inspire"     max-width="1200"
>
    <v-expansion-panel     max-width="1200">
      <v-expansion-panel-content
        v-for="(item,i) in 5"
        :key="i"
                                     max-width="1200"

      >
        <div slot="header"     max-width="1200"
>Item</div>
        <v-card     max-width="1200">

          <v-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</v-card-text>
        </v-card>
      </v-expansion-panel-content>
    </v-expansion-panel>
  </v-app>
</div>

Heres a codepen link: 这里是一个代码笔链接:

https://codepen.io/anon/pen/YBKXeL?&editable=true&editors=101

Its having no effect , and the expansion panel is at full width. 其无效,并且扩展面板处于全宽。 How can I get this working? 我该如何工作?

A quick approach would be to apply styles directly to the expansion panel component as usual with in-line CSS, style="maxWidth: 700px; 一种快速的方法是像往常一样使用style="maxWidth: 700px; CSS将样式直接应用于扩展面板组件, style="maxWidth: 700px;

Here's that example in your codepen: https://codepen.io/anon/pen/exOpGy 这是您的Codepen中的示例: https ://codepen.io/anon/pen/exOpGy

Another approach would be to declare your styles on the JS side and reference them with v-bind:style , like so: 另一种方法是在JS端声明您的样式,并使用v-bind:style引用它们,如下所示:

https://codepen.io/anon/pen/mvbeXd https://codepen.io/anon/pen/mvbeXd

I generally dislike using the 'style' attribute. 我通常不喜欢使用'style'属性。

Know that you can apply custom css to vuetify components like so: 知道您可以应用自定义CSS来对组件进行验证,如下所示:

.v-expansion-panel {
    max-width: 500px
}

vuetify components are just html elements with some classes applied to them, so you just access their css by class. vuetify组件只是具有某些类的html元素,因此您只需按类访问它们的css。 Another example if you just wanna apply the css to one particular element being nested this way: (v-card inside a v-layout inside a v-container) 另一个示例,如果您只想将CSS应用于以这种方式嵌套的一个特定元素:(V卡位于V容器内的V布局内)

.v-container > .v-layout > .v-card {
    // insert css here
}

You can inspect the html elements and see the classes added to the elements by vuetify. 您可以检查html元素,并查看通过vuetify添加到元素的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM