css – 如何在中间创建一个带有文本的垂直线

前端之家收集整理的这篇文章主要介绍了css – 如何在中间创建一个带有文本的垂直线前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在尝试创建一个中间带有文本的垂直线.我不知道如何在CSS中实现这一点.

见图

最佳答案
实际上,有很多方法.

其中之一:

HTML

CSS

.wrapper {
    position: relative;
    width: 250px;
    height: 300px;
    border: 1px dashed #ccc;
    margin: 10px;
}

.line {
    position: absolute;
    left: 49%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #ccc;
    z-index: 1;
}

.wordwrapper {
    text-align: center;
    height: 12px;
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    margin-top: -12px;
    z-index: 2;
}

.word {
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 3px;
    font: bold 12px arial,sans-serif;
    background: #fff;
}

见例:http://jsfiddle.net/zmBrR/22/

猜你在找的CSS相关文章