gpt4 book ai didi

css - 如何让文件上传Buefy组件x%宽高?

转载 作者:行者123 更新时间:2023-11-27 23:22:53 26 4
gpt4 key购买 nike

我正在尝试使用 Buefy 组件创建一个文件放置区域,但希望放置区域的大小为宽度和高度的 100%。这是基本页面,但我不知道我需要在哪里放置宽度和高度样式。

如果我在 Chrome 中加载并手动更新内联添加样式,我最终会得到所需的效果(见屏幕截图)。请在实际的 Buefy 组件中的什么位置添加样式?

DOM screenshot

代码如下,Codepen为here .

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/buefy/dist/buefy.min.css">
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.5.94/css/materialdesignicons.min.css">
</head>

<body>
<div id="app">
<!-- Buefy components goes here -->

<section>
<b-field>
<b-upload v-model="dropFiles"
multiple
drag-drop
>
<section class="section">
<div class="content has-text-centered">
<p>
<b-icon
icon="upload"
size="is-large">
</b-icon>
</p>
<p>Drop your files here or click to upload</p>
</div>
</section>
</b-upload>
</b-field>

<div class="tags">
<span v-for="(file, index) in dropFiles"
:key="index"
class="tag is-primary" >
{{file.name}}
<button class="delete is-small"
type="button"
@click="deleteDropFile(index)">
</button>
</span>
</div>
</section>

</div>

<script src="https://unpkg.com/vue"></script>
<!-- Full bundle -->
<script src="https://unpkg.com/buefy/dist/buefy.min.js"></script>

<!-- Individual components -->
<script src="https://unpkg.com/buefy/dist/components/table"></script>
<script src="https://unpkg.com/buefy/dist/components/input"></script>

<script>
new Vue({
el: '#app',
data: {
dropFiles: []
},
methods: {
deleteDropFile(index) {
this.dropFiles.splice(index, 1)
}
}
})
</script>
</body>
</html>

最佳答案

这是一个css问题,或者buefy问题。您必须将 css 添加到您的页面,您可以将其添加到头部,但您应该使用外部 css 文件并将其导入您的页面。

所以要解决你的问题,只需在你的脑海中添加:

.upload {
width: 100%;
}
.upload-draggable {
width:100%;
height: 100vh;
}

使用您的代码完成示例:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/buefy/dist/buefy.min.css">
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.5.94/css/materialdesignicons.min.css">
<style>
.upload {
width: 100%;
}
.upload-draggable {
width:100%;
height: 100vh;
}
</style>
</head>

<body>
<div id="app">
<!-- Buefy components goes here -->

<section>
<b-field>
<b-upload v-model="dropFiles"
multiple
drag-drop
>
<section class="section" style="width:100%">
<div class="content has-text-centered">
<p>
<b-icon
icon="upload"
size="is-large">
</b-icon>
</p>
<p>Drop your files here or click to upload</p>
</div>
</section>
</b-upload>
</b-field>

<div class="tags">
<span v-for="(file, index) in dropFiles"
:key="index"
class="tag is-primary" >
{{file.name}}
<button class="delete is-small"
type="button"
@click="deleteDropFile(index)">
</button>
</span>
</div>
</section>

</div>

<script src="https://unpkg.com/vue"></script>
<!-- Full bundle -->
<script src="https://unpkg.com/buefy/dist/buefy.min.js"></script>

<!-- Individual components -->
<script src="https://unpkg.com/buefy/dist/components/table"></script>
<script src="https://unpkg.com/buefy/dist/components/input"></script>

<script>
new Vue({
el: '#app',
data: {
dropFiles: []
},
methods: {
deleteDropFile(index) {
this.dropFiles.splice(index, 1)
}
}
})
</script>
</body>
</html>

关于css - 如何让文件上传Buefy组件x%宽高?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57919160/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com