【问题标题】:How to do a partial border for a button in css? [duplicate]如何为css中的按钮做部分边框? [复制]
【发布时间】:2020-06-13 10:03:29
【问题描述】:

我想在 css 中构建这个按钮:

我们建议我使用 ::after,我成功地完成了这个按钮的一部分。但是只有一行,我不能在同一个组件上使用 manybalises ::after。我该怎么办?

这是我的 CSS:

.special_button{
    position: relative;
    background-color: white;
    height: 60px;
    font-size: 32px;
    width: 192px;
    font-family: dosis_light;
}

.special_button::after{
    position: absolute;
    content: '';
    width: 33px;
    height: 2px;
    background: black;
    margin-top: 48px;
    margin-left: 20px;
}

我的结果:

【问题讨论】:

标签: html css


【解决方案1】:

也可以使用:before,但不是创建单行,而是使用每个元素创建角。

.special_button{
    position: relative;
    background-color: white;
    height: 60px;
    line-height:60px;
    font-size: 32px;
    font-family: dosis_light;
    border:none;
    padding:0 15px;
}

.special_button::before,
.special_button::after{
    position: absolute;
    content: '';
    width: 33px;
    height: 20px;
}

.special_button::before{
    left:0;
    top:0;
    border-left:3px solid black;
    border-top:3px solid black;
}
.special_button::after{
    right:0;
    bottom:0;
    border-right:3px solid black;
    border-bottom:3px solid black;
}
<button class="special_button">ME CONTACTER</button>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-02
    • 2021-06-09
    • 2023-03-29
    • 2020-04-17
    • 1970-01-01
    • 2021-11-22
    • 1970-01-01
    • 2021-01-16
    相关资源
    最近更新 更多