2017-09-04 48 views
1

如何用純CSS製作這樣的按鈕?如何用css製作角色的按鈕?

enter image description here

這一切,我已經能夠:

.sideMenuButton { 
 
    width: 100px; 
 
    height: 100px; 
 
    background: #6d1a3e; 
 
    position: relative; 
 
    transform: rotate(-90deg); 
 
    border: none; 
 
} 
 

 
.sideMenuButton:after { 
 
    content: ''; 
 
    position: absolute; 
 
    bottom: 0; 
 
    left: 0; 
 
    border-top: 29px solid #6d1a3e; 
 
    border-left: 29px solid #fff; 
 
    width: 42px; 
 
    height: 0; 
 
}
<button type="button" class="sideMenuButton">X</button>

,但它不工作正確的方式

+0

其中它不工作? –

+0

你正在取得不錯的進展。我會玩SVG背景,邊框樣式(插圖,開始等)或添加::之前。祝你好運 - 看起來很有趣。 – Ruskin

+0

還應該有一個邊框,就像在圖像上,我只是不能使它 – Kirill

回答

3

只是快速的嘗試。我希望這可以幫助你。 您可以通過按鈕的文本屬性添加文本。

.button-container{ 
 
    width: 100px; 
 
    height: 100px; 
 
    overflow: hidden; 
 
    position:relative; 
 
    margin: 5px; 
 
} 
 
.button { 
 
    width: 148px; 
 
    height: 200px; 
 
    transform: rotateZ(45deg); 
 
    overflow: hidden; 
 
    position: absolute; 
 
    top: -68px; 
 
    left: -43px; 
 
} 
 

 
.button::before{ 
 
    content: attr(text); 
 
    background: #6d1a3e; 
 
    display: block; 
 
    width: 100px; 
 
    height: 100px; 
 
    transform: rotateZ(-45deg); 
 
    position: absolute; 
 
    top: 50px; 
 
    left: 50px; 
 
    border: 5px solid #a5285e; 
 
    cursor: pointer; 
 
    box-sizing: border-box; 
 
    text-align: center; 
 
    vertical-align: middle; 
 
    line-height: 69px; 
 
    font-size: 2.5em; 
 
    color: white; 
 
} 
 
.button::after{ 
 
    content: ''; 
 
    display: block; 
 
    position: absolute; 
 
    border-bottom: 7px solid #a5285e; 
 
    border-left: 5px solid transparent; 
 
    border-right: 5px solid transparent; 
 
    height: 0; 
 
    width: 41px; 
 
    transform: rotateZ(90deg); 
 
    top: 99px; 
 
    left: 120px; 
 
    cursor: pointer; 
 
} 
 

 

 
.other.button::before{ 
 
    border-left: none; 
 
    border-top: none; 
 
    line-height: 80px; 
 
    font-size: 3em; 
 
}
<div class="button-container"> 
 
    <div class="button" text="PDF"></div> 
 
</div> 
 

 
<div class="button-container"> 
 
    <div class="button other" text="&#9776;"></div> 
 
</div>