html - 你能把跨度放在css的中心吗?
问题描述
我想知道,有没有一种方法可以让跨度标签使用 css 移动到中心?
我需要问这个问题,因为每当我text-align
输入跨度时,它都不起作用。
html
<span>
This is span.
</span>`
CSS
span {
text-align:center;
}
解决方案
要使元素内的文本水平居中,请使用text-align: center;
. 对于两个文本:
<!DOCTYPE html>
<html>
<head>
<style>
.center {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
border: 3px solid green;
}
</style>
</head>
<body>
<div class="center">
<p>I am vertically and horizontally centered.</p>
</div>
</body>
</html>
推荐阅读
- neo4j - Neo4j 按查询性能排序不佳
- c++ - 找到数 n 小于 k 的除数的有效方法
- vnc - 如何在没有以太网端口的情况下将 jetson nano 与 vnc 查看器连接
- c++ - 如何修复此错误:未分配被释放的指针
- python - 用于创建掩码的数组的良好初始化方案
- r - R - 协变量多于观测值的贝叶斯树
- android - Android资源编译失败我构建时没有错误但是在运行程序时出现错误
- android - 当我更改应用名称时会发生什么?
- javascript - 为什么 Сhrome 显示 JavaScript setAttribute() 错误
- javascript - flexDirection 导致图像消失