当前位置: 首页 > 知识库问答 >
问题:

一个css样式的实现?

张宣
2023-08-01

image.png

红框内的效果应该怎么实现? 文字两边中间的线条

共有3个答案

丁俊爽
2023-08-01

一个:after或者:before + 定位就可以搞定了,也可以参考一下这样的布局(>_<虽然已被采纳):

.endBox{  display: flex;  justify-content: center;  width:100%;  padding:20px;  box-sizing: border-box;  position: relative;  }.endBox p{  width:100%  text-align: center;  padding:0 20px;  background:#fff;   z-index: 2;}.endBox:after{  content: "";  position: absolute;  top:50%;  left:0;  width:100%;  border:1px solid #ccc;  z-index: 1}

舒浩邈
2023-08-01
<!DOCTYPE html><html><head>  <meta charset="utf-8">  <meta name="viewport" content="width=device-width">  <title>demo</title>  <style>    .text-box {       height: 60px;       display: flex;      justify-content: center;      align-items: center;      position: relative;    }    .line {       height: 2px;       width: 100%;       background-color: #dedede;       position: absolute;    }    .text {       background-color: #fff;      padding: 4px 14px;      display: inline-flex;      letter-spacing: 2px;      z-index: 2;    }  </style></head><body>    <div class="text-box">       <div class="line"></div>       <div class="text">连接商业与科技&nbsp;&nbsp;培养知行合一的经营人才</div>    </div></body></html>
陈瀚玥
2023-08-01
<!DOCTYPE html><html lang="en">    <head>        <meta charset="UTF-8" />        <meta name="viewport" content="width=device-width, initial-scale=1.0" />        <title>Document</title>        <style>            * {                margin: 0;                padding: 0;            }            .text {                display: flex;                align-items: center;                justify-content: center;            }            .text::before {                content: "";                flex: 1;                background-color: red;                height: 1px;                margin-right: 10px;            }            .text::after {                content: "";                flex: 1;                background-color: red;                height: 1px;                margin-left: 10px;            }        </style>    </head>    <body>        <div class="text">一段文字</div>    </body></html>
 类似资料: