按钮上的倒椭圆边框带图标[复制]

问题描述 投票:2回答:2

这个问题在这里已有答案:

我有以下按钮,左侧缺少边框:

Add to cart button

如何在按钮左侧添加缺失的边框?

这是一个带有字体真棒图标和框阴影的按钮。 (在这个例子中,Icon被替换为'X'。)

有没有简单的方法来解决这个问题?

.button.addcart {
    position: relative;
    padding: 0 29px 0 55px;
    font: 700 16px/40px 'Quattrocento Sans',sans-serif;
    text-decoration: none;
    color: #555;
    border-radius: 20px 0 0 20px;
    border: 2px solid #222;
    line-height: 48px!important;
    text-transform: uppercase;
    cursor: pointer;
}
.button.addcart:before {
    position: absolute;
    box-sizing: border-box;
    content: "X";
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    color: #555;
    margin: 3px 0;
    box-shadow: 0 0 0 3px #555, 0 0 0 9px #fff;
    font: normal normal normal 14px/1 FontAwesome;
    font-size: 26px;
    padding: 7px 0 0;
}
<button class="button addcart" id="add_to_cart689427" type="submit" name="addtocart" value="" title="add to cart">add to cart</button>
html css border font-awesome box-shadow
2个回答
1
投票

您可以尝试使用radial-gradient创建一个圆圈作为背景颜色的背景,然后您可以调整其大小和位置以填充缺失的边框:

.button.addcart {
    position: relative;
    padding: 0 20px 0 65px;
    font: 700 16px/40px 'Quattrocento Sans',sans-serif;
    text-decoration: none;
    color: #555;
    border-radius: 20px 0 0 20px;
    border: 2px solid #222;
    line-height: 48px!important;
    text-transform: uppercase;
    cursor: pointer;
    background: radial-gradient(circle at left,transparent 22%,#222 23%, #222 25%,transparent 25%) 19px 0px/131px 48px no-repeat,#ddd;
}
.button.addcart:before {
    position: absolute;
    box-sizing: border-box;
    content: "X";
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    color: #555;
    margin: 3px 0;
    box-shadow: 0 0 0 3px #555, 0 0 0 9px #fff;
    font: normal normal normal 14px/1 FontAwesome;
    font-size: 26px;
    padding: 7px 0 0;
}
<button class="button addcart" id="add_to_cart689427" type="submit" name="addtocart" value="" title="add to cart">add to cart</button>

0
投票

基本上

  • 在按钮中添加插入box-shadow
  • 将第三个box-shadow添加到圆圈中

(+填充,边距等的以下更改:)

.button.addcart {
    font: 700 16px/48px 'Quattrocento Sans',sans-serif;
    text-transform: uppercase;
    cursor: pointer;
    
    position: relative;
    overflow: hidden;
    padding-right: 28px;
    color: #555;
    border-radius: 80px 0 0 80px;
    /*border: 2px solid #222; NO, we need an inset box-shadow instead */
    border: 0;
    box-shadow: inset 0 0 0 2px #222;

}
.button.addcart:before {
    box-sizing: border-box;
    display: inline-block;
    vertical-align: middle;
    content: "\2714";
    margin-left: -3px;
    width: 43px;
    height: 43px;
    border-radius: 50%; /* 50% */
    margin-right: 28px;
    box-shadow: 0 0 0 3px #555, 0 0 0 9px #fff, 0 0 0 12px #222; /* add 3rd shadow */
    font: 18px/42px FontAwesome;
}
<button class="button addcart" id="add_to_cart689427" type="submit" name="addtocart" value="" title="add to cart"><span></span>add to cart</button>
© www.soinside.com 2019 - 2024. All rights reserved.