创建一个双边框按钮?

时间:2014-01-12 11:42:33

标签: css css3

我想要的按钮:

http://i.stack.imgur.com/A2Qv4.png (I don't have enough reputation to post images)

我试过这个,但它不起作用:

button {
    font-family: 'Ubuntu', sans-serif;
    font-size: 1em;
    font-weight: bold;
    color: white;
    border: 3px double #f26700;
    background: #f26700;
}

如何使用CSS显示此白线?

4 个答案:

答案 0 :(得分:6)

写:

button{
    border: 3px double white;
}

DEMO here.

OR:

button{
    border: 1px double white;
    outline: 1px solid #f26700;
}

DEMO here.

OR:

button{
    border: 2px solid white;
    box-shadow:0 0 0 0px white, 0 0 0 2px #F26700;
}

DEMO here.

答案 1 :(得分:0)

使用outline属性:

CSS

.button {
    font-family:'Ubuntu', sans-serif;
    font-size: 1em;
    font-weight: bold;
    color: white;
    line-height: 1.8em;
    border: 1px solid white;
    background: #f26700;
    width: 100px;
    height: 30px;
    text-align: center;
    outline: 1px solid #f26700;
}

这是JSFiddle:http://jsfiddle.net/2kgGF/

答案 2 :(得分:0)

你可以用大纲来做到这一点。

button {
    width: 8rem;
    font-size: 1rem;
    line-height: 2.4rem;
    color: white;
    background: darkorange;
    border: none;
    outline: .1rem solid white;
    outline-offset: -.3rem;
}

http://jsfiddle.net/lrsbck/7Zp6X/

答案 3 :(得分:0)

评论,2个简单的选择: 盒子阴影和轮廓:

button {
  font-family: 'Ubuntu', sans-serif;
  font-size: 1em;
  font-weight: bold;
  color: white;
  border: 1px solid white;
  background: #f26700;
  outline:solid #f26700 1px;
  padding:0.25em 1em;
}
button + button {
  box-shadow: 0 0 0 1px #f26700;
  outline:none;
}

演示:http://codepen.io/anon/pen/InDqa