html - 在 React 中更改 html 字符串中文本框的大小
问题描述
我正在使用弹出库 sweetalert2-react-content 来生成一个弹出框,其中包含一个文本框和一个文本区域。在弹出框中,我正在生成一个 html 字符串来创建文本框和文本区域。它可以很好地生成这些元素,但是我无法更改文本区域的大小。这是一个代码片段:
import React, { Component } from 'react';
import Swal from 'sweetalert2';
import withReactContent from 'sweetalert2-react-content';
submitButton() {
const MySwal = withReactContent(Swal)
MySwal.fire({
confirmButtonText: 'Submit Post',
showCancelButton: true,
title: "Submit a new Post",
html:
'<br /><br />' +
'<h4>Enter the title</h4>' +
'<input type="text" id="theTitle">' +
'<h4>Enter the body</h4>' +
'<textarea rows="10" cols="50"></textarea>',
input: 'file',
focusConfirm: false,
}).then(result => this.getPostValues(result.value))
}
有什么想法可以让文本框显示得更大一点吗?谢谢!!
解决方案
很可能是通过库的 css 控制的<textarea>
,所以即使你设置了rows
and cols
,css 也会决定样式。如果是这样,您将不得不编辑库的 css,用您自己的 css 覆盖它,或者给它一个 inline style
。
MySwal.fire({
// Other settings...
html:
'...other html' +
'<textarea style="height: 200px; width: 400px"></textarea>'
});
推荐阅读
- ruby-on-rails - Rails-API 如何测试活动存储
- tensorflow - 使用 Keras 训练数据时遇到问题
- reactjs - 具有动态导入的 Splitchunk 插件
- google-cloud-platform - GCP Cloud SQL 代理超时:connectex
- pine-script - Pine-script 如何默认隐藏图表上的交易
- python - 如何使用合并元素制作嵌套列表?
- c++ - 从向量中的 json 文件值读取
- docker - docker-py/dockerpy 使用安全吗?
- c# - 使用 TemData.Keep() 时的 Asp.net 核心 HTTP 500 错误
- tableau-api - Einstein Analytics 中的自定义日期