修改代码:需要biaoge13内输入的文本自动换行且垂直,水平居中 .text{ top:0px !important; left:0px !important; width:100%; height:100%; position:absolute; resize: none; -webkit-box-sizing: border-box; /* <=iOS4, <= Android 2.3 */ -moz-box-sizing: border-box; /* FF1+ */ box-sizing: border-box; /* Chrome, IE10, Opera, Safari 5.1*/ border: solid; border-width: 4px; border-color: white; background-color: white; margin:0px; padding:0px; font-style: normal; text-align: center; } <td class="biaoge13"> <input class="text" type="text"> </td>
时间: 2024-02-14 21:28:10 浏览: 72
要实现文本自动换行且垂直水平居中,您可以使用CSS的一些属性和样式来修改代码。以下是修改后的代码:
```html
<style>
.text {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: absolute;
resize: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
border: solid;
border-width: 4px;
border-color: white;
background-color: white;
margin: 0;
padding: 0;
font-style: normal;
text-align: center;
overflow-wrap: break-word; /* 自动换行 */
text-align: center; /* 水平居中 */
display: flex;
align-items: center; /* 垂直居中 */
justify-content: center; /* 水平居中 */
}
</style>
<td class="biaoge13">
<div class="text">
<textarea class="text" rows="4"></textarea>
</div>
</td>
```
在上面的代码中,我们将输入框由`<input>`改为`<textarea>`,以便实现文本的自动换行。然后,我们为包裹输入框的`<div>`添加了一些CSS样式,使其垂直和水平居中。通过`display: flex`和相关属性,我们可以轻松实现这些效果。
请注意,您可能需要根据您的页面布局和需求进一步调整和修改CSS样式。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)