2017-09-04 3 views
1

Wie mache ich einen Button mit reinem CSS?wie man eckigen Knopf mit CSS machen?

enter image description here

das ist alles, was ich in der Lage bin:

.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>

aber es ist nicht richtig

+0

wo funktioniert es nicht? –

+0

Sie machen ziemlich gute Fortschritte. Ich würde mit SVG-Hintergrund, Grenzstilen (Einfügung, Anfang usw.) spielen oder a auch vorher hinzufügen. Viel Glück - sieht nach Spaß aus. – Ruskin

+0

sollte es auch eine Grenze sein, wie auf dem Bild, und ich kann es einfach nicht – Kirill

Antwort

3

einfach einen kurzen Versuch arbeiten. Ich hoffe, das könnte dir helfen. Sie können Text durch das Textattribut der Schaltfläche hinzufügen.

.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>