Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.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 添加内联水平线_Html_Css - Fatal编程技术网

Html 添加内联水平线

Html 添加内联水平线,html,css,Html,Css,我有一个交通灯一样的仪表板视图,我必须拿出我的一页。但是我不能让水平线在多次调整的情况下工作 我想要的是: 摆弄我所拥有的: CSS: .bubble { height: 30px; width: 30px; color: white; display: inline-block; text-align: center; vertical-align: center; border-radius: 50%; margin-right: 50px; margin

我有一个交通灯一样的仪表板视图,我必须拿出我的一页。但是我不能让水平线在多次调整的情况下工作

我想要的是:

摆弄我所拥有的:

CSS:

.bubble {
  height: 30px;
  width: 30px;
  color: white;
  display: inline-block;
  text-align: center;
  vertical-align: center;
  border-radius: 50%;
  margin-right: 50px;
  margin-left: 50px;
  font-size: 90%;
}
.red-bg {
  background: red;
}
.green-bg {
  background: green;
}
.blue-bg {
  background: blue;
}

.inline-div {
  display: inline;
  font-size: 75%;
  font-family: verdana;
  margin-left: 50px;
  margin-right: 50px;
}

您可以使用一点
:before
魔术来实现这一点

将一个类添加到包装
气泡的div中,比如说
'outer-bubble'
,并添加以下CSS:

.outer-bubble {
  position: relative;
}

.outer-bubble:before {
  position: absolute;
  top: 50%;
  left: 50px;
  height: 1px;
  width: 290px;
  background: black;
  content: '';
  z-index: -1;
}

您可以在
魔术之前使用一点
:来完成此操作

将一个类添加到包装
气泡的div中,比如说
'outer-bubble'
,并添加以下CSS:

.outer-bubble {
  position: relative;
}

.outer-bubble:before {
  position: absolute;
  top: 50%;
  left: 50px;
  height: 1px;
  width: 290px;
  background: black;
  content: '';
  z-index: -1;
}

我为你做了这个:


我为你做了这个:


如果将
position:relative
添加到
.bubble
,则可以通过以下方式实现该行:

.bubble:not(:nth-last-of-type(1)):before {
    display: block;
    content: '';
    width: 140px;
    height: 2px;
    position: absolute;
    top: calc(50% - 1px);
    left: 50%;
    background-color: #000;
    z-index: -1;
}
因此,您将添加
:在每个
.bubble
伪元素之前,但最后一个


这种方法的好处是不必添加额外的标记。下面是。

如果您将
位置:相对
添加到
.bubble
,您可以通过以下方式实现该行:

.bubble:not(:nth-last-of-type(1)):before {
    display: block;
    content: '';
    width: 140px;
    height: 2px;
    position: absolute;
    top: calc(50% - 1px);
    left: 50%;
    background-color: #000;
    z-index: -1;
}
因此,您将添加
:在每个
.bubble
伪元素之前,但最后一个


这种方法的好处是不必添加额外的标记。下面是。

为什么不使用HTML画布? 但如果您真的想使用CSS,这是一条捷径:

.shape1 {
  height: 1px;
  width: 104px;
  border-bottom: 1px solid ;
  border-right: 1px solid ;
  margin-left: 80px;
  margin-right: 80px;
  margin-top: 15px;
  position:absolute;
}
.shape2 {
  height: 1px;
  width: 104px;
  border-bottom: 1px solid ;
  border-right: 1px solid ;
  margin-left: 214px;
  margin-right: 80px;
  margin-top: 15px;
  position:absolute;
}

<body>
    <div>
        <div class="inline-div">
          Title1
        </div>
        <div class="inline-div">
          Title2
        </div>
        <div class="inline-div">
          Title3
        </div>

    </div>
    <div>
  <div class="shape1"></div>
   <div class="shape2"></div>
        <div class="bubble red-bg">
        5
        </div>
        <div class="bubble green-bg">
        66
        </div>

        <div class="bubble blue-bg">
        777
        </div>

    </div>
</body>
.shape1{
高度:1px;
宽度:104px;
边框底部:1px实心;
右边框:1px实心;
左边距:80px;
右边距:80px;
边缘顶部:15px;
位置:绝对位置;
}
.shape2{
高度:1px;
宽度:104px;
边框底部:1px实心;
右边框:1px实心;
左边距:214px;
右边距:80px;
边缘顶部:15px;
位置:绝对位置;
}
标题1
标题2
标题3
5.
66
777

为什么不使用HTML画布? 但如果您真的想使用CSS,这是一条捷径:

.shape1 {
  height: 1px;
  width: 104px;
  border-bottom: 1px solid ;
  border-right: 1px solid ;
  margin-left: 80px;
  margin-right: 80px;
  margin-top: 15px;
  position:absolute;
}
.shape2 {
  height: 1px;
  width: 104px;
  border-bottom: 1px solid ;
  border-right: 1px solid ;
  margin-left: 214px;
  margin-right: 80px;
  margin-top: 15px;
  position:absolute;
}

<body>
    <div>
        <div class="inline-div">
          Title1
        </div>
        <div class="inline-div">
          Title2
        </div>
        <div class="inline-div">
          Title3
        </div>

    </div>
    <div>
  <div class="shape1"></div>
   <div class="shape2"></div>
        <div class="bubble red-bg">
        5
        </div>
        <div class="bubble green-bg">
        66
        </div>

        <div class="bubble blue-bg">
        777
        </div>

    </div>
</body>
.shape1{
高度:1px;
宽度:104px;
边框底部:1px实心;
右边框:1px实心;
左边距:80px;
右边距:80px;
边缘顶部:15px;
位置:绝对位置;
}
.shape2{
高度:1px;
宽度:104px;
边框底部:1px实心;
右边框:1px实心;
左边距:214px;
右边距:80px;
边缘顶部:15px;
位置:绝对位置;
}
标题1
标题2
标题3
5.
66
777

可能重复与您的问题无关的提示:使用
行高
等于
高度
使数字在圆圈中垂直居中。在您的情况下,所以:
行高:30px
谢谢@fremail,这是一个有用的提示。可能只是一个与您的问题无关的提示的重复:使用
行高
等于
高度
使您的数字在圆圈中垂直居中。在您的情况下,所以:
行高:30px谢谢@fremail,这是一个有用的提示。这对我也很有用,谢谢!接受了@debute的回答,因为这是第一次。这对我来说也非常有效,谢谢!接受@debute的答案,因为这是第一个。