Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 使文本在div正方形的中心对齐_Html_Css - Fatal编程技术网

Html 使文本在div正方形的中心对齐

Html 使文本在div正方形的中心对齐,html,css,Html,Css,我正在努力将文本添加到一个用HTML和CSS编写的消失/出现方块系统中。是否有一种简单的方法可以将段落标记添加到每个方块的中心?这是我的密码: jsiddle.net/busterroni/wBcWc/8/您最好不要使用标记,因为它们包含默认边距。您可以将普通的与更简单的类一起使用。使用行高:100px(与高度)和文本-对齐:居中将文本水平和垂直居中 HTML <span class="wrapper"> <div class="rowone" class="a"&g

我正在努力将文本添加到一个用HTML和CSS编写的消失/出现方块系统中。是否有一种简单的方法可以将段落标记添加到每个方块的中心?这是我的密码:
jsiddle.net/busterroni/wBcWc/8/

您最好不要使用
标记,因为它们包含默认边距。您可以将普通的
与更简单的类一起使用。使用
行高:100px
(与
高度
)和文本-
对齐:居中
将文本水平和垂直居中

HTML

<span class="wrapper">
    <div class="rowone" class="a"><span class="hoverable">test</span></div>
    ...
div {
    text-align:center;
    line-height:100px;
}
.hoverable{
   color:transparent;    
}
.hoverable:hover{
    color:red;
    text-align:center;
}