2015-10-27 49 views
0

我有一個半圓形的按鈕。但我不知道如何將它彎曲以便在邊框處使用我的半圓形按鈕。如何使用線性漸變顏色創建按鈕邊框和文本?

enter image description here

.semi-circle { 
    display:  inline-block; 
    padding:  9px 16px; 
    border-radius: 999px !important; 
    text-align: center; 

    /*border: 10px solid transparent;*/ 
    /* -moz-border-image: -moz-linear-gradient(right, #FC913A 0%, #FF4E50 100%); 
    -webkit-border-image: -webkit-linear-gradient(right, #FC913A 0%, #FF4E50 100%); 
    border-image: linear-gradient(to left, #FC913A 0%, #FF4E50 100%);*/ 
    /*border-image-slice: 1;*/ 
border: linear-gradient(to right, green 0%, blue 100%); 

/*background-image: linear-gradient(to left, #FC913A 0%, #FF4E50 100%);*/ 
background-image: -o-linear-gradient(to left, #FC913A 0%, #FF4E50 100%);*/ 
background-image: -moz-linear-gradient(to left, #FC913A 0%, #FF4E50 100%);*/ 
background-image: -webkit-linear-gradient(to left, #FC913A 0%, #FF4E50 100%);*/ 
background-image: -ms-linear-gradient(to left, #FC913A 0%, #FF4E50 100%);*/ 
*/ 
} 

請原諒,我不能夠嵌入由於缺乏信譽的形象。 Thx爲堆棧溢出社區提供了卓越的服務。

+0

夥計們,這是自舉3 –

回答

0

可能有更好的方法來做到這一點,但沒有進一步的思考我想嘗試這樣的:

<style type="text/css"> 
.semi_outer { 
    padding: 2px; 
    text-align: center; 
    border-radius: 11px; 
    background: linear-gradient(to right, #0f0, #00f); 
} 

.semi_inner { 
    margin: 2px; 
    border-radius: 7px; 
    background-color: #000; 
    color: #0f0; 
} 

.semi_outer:hover { 
    background: linear-gradient(to right, #c00, #0c0); 
} 

.semi_outer:active { 
    background: linear-gradient(to right, #f00, #0f0); 
} 
</style> 

<div class="semi_outer"> 
    <div class="semi_inner"> 
    semi_inner 
    </div> 
</div> 
+0

這是自舉3 –

+0

沒有標題,也沒有標籤表明比CSS和梯度其他任何。 – 2015-10-28 23:35:22

1

這是你的半圓形按鈕。可能會對你有幫助。

.outer { 
 
    padding: 2px; 
 
    text-align: center; 
 
    border-radius: 11px; 
 
    background: linear-gradient(to right, #0f0, #00f); 
 
    width: 200px; 
 
    height:30px; 
 
} 
 

 
.inner { 
 
    margin: 3px; 
 
    border-radius: 7px; 
 
    background-color: #000; 
 
    color: #0f0; 
 
    height:25px; 
 
} 
 

 
.outer:hover { 
 
    background: linear-gradient(to right, #c00, #0c0); 
 
} 
 

 
.outer:active { 
 
    background: linear-gradient(to right, #f00, #0f0); 
 
}
<div class="outer"> 
 
    <div class="inner"> 
 
     BUTTON 
 
    </div> 
 
</div>

0

這裏是溶液。它在webkit中運行良好。在其他瀏覽器中,文本顏色是穩定的。

HTML

<button data-text="Round button"></button> 
<button class="active" data-text="Active round button"></button> 

CSS

body { 
    background: #384041; 
} 
*, 
*:before, 
*:after { 
    box-sizing: border-box; 
} 
button { 
    display: inline-block; 
    border: none; 
    outline: none; 
    appearance: none; 
    background: red; 
    position: relative; 
    z-index: 3; 
    height: 60px; 
    border-radius: 30px; 
    padding: 0 21px; 
    font-size: 21px; 
    box-shadow: -1px -1px 1px 0 black; 
    background: #4f4f4f; 
} 
button:before { 
    content: attr(data-text); 
    min-width: 144px; 
    z-index: -1; 
    border-radius: 27px; 
    color: #4f4f4f; 
} 
@media screen and (-webkit-min-device-pixel-ratio:0) { button:before { 
    background: #4f4f4f; 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent; 
}} 
button:after { 
    content: ''; 
    position: absolute; 
    left: 3px; 
    right: 3px; 
    top: 3px; 
    bottom: 3px; 
    z-index: -2; 
    border-radius: 30px; 
    background: #151515; 
} 
button:hover { 
    cursor: pointer; 
    background: linear-gradient(to right, #2084c3 0%, #00caa0 100%); 
} 
.active { 
    background: linear-gradient(to right, #2084c3 0%, #00caa0 100%); 
} 
.active:before{ 
    color: #2084c3; 
} 

@media screen and (-webkit-min-device-pixel-ratio:0) { .active:before { 
    background: linear-gradient(to right, #2084c3 0%, #00caa0 100%); 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent; 
}} 

Demo

+0

這是用於引導3 –