我想通过 css 实现这个想法:
在 CSS 中实现这一点的最佳方法是什么? 非常感谢!!
更新
我以前用 Headings 做过这个技巧,更多信息在这里: Putting Heading within 2 horizontal lines in CSS
但是当我尝试编辑标题版本时也无法使用按钮。
最佳答案
body { background: #fff; }
h3 {
width: 500px;
font: 30px Arial;
font-weight: normal;
text-align: right;
position: relative;
}
h3 span {
background: #fff;
margin-right: 15%;
padding: 0 20px;
}
h3:before {
content: "";
width: 100%;
left: 0;
top: 50%;
position: absolute;
z-index: -1;
height: 0;
border-top: 8px solid grey;
opacity:.2
}
button{
background-color:green;
border:1px solid green;
border-radius:5px;
vertical-align:center;
}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<h3><span><button>Hello</button></span></h3>
</body>
</html>
关于css - 将按钮放在 css 中的分隔符中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17797668/