css - 将按钮放在 css 中的分隔符中

标签 css button divider

我想通过 css 实现这个想法: enter image description here

在 CSS 中实现这一点的最佳方法是什么? 非常感谢!!

更新

我以前用 Headings 做过这个技巧,更多信息在这里: Putting Heading within 2 horizontal lines in CSS

但是当我尝试编辑标题版本时也无法使用按钮。

最佳答案

http://jsfiddle.net/pB9MY/

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/

相关文章:

android - 以编程方式在 TabLayout 的选项卡之间分隔线 LinearLayout.SHOW_DIVIDER_MIDDLE

javascript - 清除按钮清空文本区域,但我无法重新填充它

javascript - 通过 javascript 使 HTML 按钮在点击时消失

android - 如何从 android 的 ListView 中删除分隔符?

android - 如何在我的自定义选项卡上做一些最后的润色(圆边和水平分隔线)

kotlin - 点击后传递参数

python - 在静态文件夹中加载 css 时出现错误 404

css - JavaFX 自定义字体

css - Zurb Foundation Block Grid 导致水平滚动条

jquery - 如何根据其他元素更改 css 元素