1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-10-23 10:46:13 +02:00
Files
csslayout/contents/triangle-buttons.md
2022-09-21 14:31:37 +07:00

1.8 KiB

layout, title, description, keywords
layout title description keywords
layouts/post.njk Triangle buttons Create triangle buttons with CSS css triangle buttons

HTML

<!-- Up triangle button -->
<button class="triangle-buttons">
    <!-- Triangle -->
    <div class="triangle-buttons__triangle triangle-buttons__triangle--t"></div>

    <!-- Content -->
    ...
</button>

<!-- Right triangle button -->
<button class="triangle-buttons">
    <!-- Content -->
    ...

    <!-- Triangle -->
    <div class="triangle-buttons__triangle triangle-buttons__triangle--r"></div>
</button>

<!-- Down triangle button -->
<button class="triangle-buttons">
    <!-- Triangle -->
    <div class="triangle-buttons__triangle triangle-buttons__triangle--b"></div>

    <!-- Content -->
    ...
</button>

<!-- Left triangle button -->
<button class="triangle-buttons">
    <!-- Triangle -->
    <div class="triangle-buttons__triangle triangle-buttons__triangle--l"></div>

    <!-- Content -->
    ...
</button>

CSS

.triangle-buttons {
    /* Center the content */
    align-items: center;
    display: flex;
    justify-content: center;

    /* Spacing */
    padding: 0.5rem;
}

.triangle-buttons__triangle {
    border-style: solid;

    /* Size */
    height: 0px;
    width: 0px;
}

.triangle-buttons__triangle--t {
    border-color: transparent transparent #d1d5db;
    border-width: 0 0.5rem 0.5rem;
}

.triangle-buttons__triangle--r {
    border-color: transparent transparent transparent #d1d5db;
    border-width: 0.5rem 0 0.5rem 0.5rem;
}

.triangle-buttons__triangle--b {
    border-color: #d1d5db transparent transparent;
    border-width: 0.5rem 0.5rem 0;
}

.triangle-buttons__triangle--l {
    border-color: transparent #d1d5db transparent transparent;
    border-width: 0.5rem 0.5rem 0.5rem 0;
}

{% demo %} {% include "covers/triangle-buttons.njk" %} {% enddemo %}