css中BORDER-BOTTOM是下划线,怎么实现垂直居中的线?

css中BORDER-BOTTOM是下划线,怎么实现垂直居中的线?,第1张

代码如下:

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>无标题文档</title>

<style>

.my-para{

height:30px

line-height:30px

width:400px

display:flex

text-align:center

}

.my-para span{

height:1px

width:200px

border-bottom:1px solid #333

margin:auto

display:inline-block

}

</style>

</head>

<body>

<p class="my-para">新闻标题文字<span></span>2017.12.12</p>

</body>

</html>

如图所示:

解释:垂直居中的直线可以设置为<span></span>,span标签的父元素p标签的css属性设置为:display:flextext-align:center 设置span为块级元素,给它宽、高、下边框。  span标签的属性设置为:margin:auto 这样就可以使span的下边框垂直居中与父级元素p

你可以设置一个层的右边框啊,在css样式里面写{border-right:1px #cccccc solid}

"#cccccc"代表颜色;“solid”代表是实线也可以改成虚线。

表格的线都是border属性控制的。

有横线,可以用border-bottom: 1px

没有竖线,可以用border-right: none

上下左右根据你自己需要调整就行了。

还有在html里,表格的rules属性会影响表格在firefox里的显示,要设置成none。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11918161.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存