我有以下按钮,左侧缺少边框:
如何在按钮左侧添加缺失的边框?
这是一个带有字体真棒图标和方框阴影的按钮。 (在这个例子中,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>
答案 0 :(得分: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;
}
&#13;
<button class="button addcart" id="add_to_cart689427" type="submit" name="addtocart" value="" title="add to cart">add to cart</button>
&#13;
答案 1 :(得分: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>