Html 添加内联水平线
我有一个交通灯一样的仪表板视图,我必须拿出我的一页。但是我不能让水平线在多次调整的情况下工作 我想要的是: 摆弄我所拥有的: CSS: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
.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的答案,因为这是第一个。