Utilizing a pseudo-element to manipulate a clip-path

Attempting what should be a simple task, but hitting roadblocks. I have a basic button with a shimmer hover effect and now want to apply the same effect to a hexagon-shaped button. My initial idea was to overlay the button with a clip-path (ignoring browser support), but unfortunately, the pseudo-element interferes with the clip-path, rendering it useless. Is there something obvious that I'm missing here? Or is the combination of these two elements just not feasible?

.button {
outline:none;
border:none;
padding:20px;
display:block;
margin:0 auto;
cursor:pointer;
font-size:16px;
font-weight: bold;
background-color:#DBBD68;
text-transform: uppercase;
position:relative;
transition:all 0.5s ease;
overflow: hidden;
color:#fff;

&.hex{
   width: 280px;
   height: 280px;
   position:absolute;
   top: 0;
   left:0;
   -webkit-clip-path: polygon(20% 50%, 12% 60%, 20% 70%, 82% 70%, 89% 60%, 80% 50%);
   clip-path: polygon(20% 50%, 12% 60%, 20% 70%, 82% 70%, 89% 60%, 80% 50%);
 }
&:before {
    content: '';
    background-color: rgba(255,255,255,.5);
    width:100%;
    height:20px;
    position:absolute;
    left:-135px;
    transform: rotateZ(45deg)
}

I've created a Fiddle to demonstrate the issue: https://jsfiddle.net/0m5wmvu8/

Answer №1

Instead of complicating things with .hex, all you needed to do was add the clip-path. Just update it to:

&.hex{
    -webkit-clip-path: polygon(50% 0, 80% 0, 100% 50%, 80% 100%, 20% 100%, 0 50%, 20% 0);
    clip-path: polygon(50% 0, 80% 0, 100% 50%, 80% 100%, 20% 100%, 0 50%, 20% 0);
}

https://jsfiddle.net/8sfc3ott/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating distinct identifiers for table cells utilizing the map function

Is there a way to assign a unique id to each MenuItem using the map() function nested within another one? <table className={classes.table}> <thead> <tr> <td /> {sit.sit.map(sit => ( <td className={ ...

Angular 10: Understanding the Checked State of Checkboxes

Currently working with Angular 10 and have a checkbox element within my HTML. How can I determine in my TypeScript file whether the checkbox is checked or not, and then execute certain actions based on this state? Is there a method to retrieve the checke ...

Upon clicking the button, input numbers into multiple number type inputs

I recently implemented a button in my application that increments the value of input type='number' after it is clicked. While everything seems to be working fine, I noticed that the numbers start from 0 instead of 1. Is there a way for me to ens ...

dirpagination fails to display all rows in the dataset

I've been working on creating tables with 3 divs, as shown in the link below:- https://github.com/anirbanmishra/congress.php/blob/master/web_test Additionally, I have a javascript file available here:- https://github.com/anirbanmishra/congress.php/bl ...

Looking to design an interactive grid for generating dynamic thumbnails

I am a beginner in the field of web development and I have a desire to create a website for showcasing my portfolio. This website should feature project thumbnails along with brief descriptions, all of which should be displayed dynamically. Although I poss ...

Setting the height to 100% on the body and html tags can lead to scrolling problems

After implementing the CSS code below, I have encountered some unexpected behavior: body, html{height:100%; overflow-x:hidden} Despite vertical scrollbars appearing as intended when the page exceeds screen height, detecting the scroll event on the body e ...

Tips for submitting a form and retrieving session count without the need to refresh the page after submitting the form

I have set up a form that includes hidden input fields to send data to a PHP script. The script stores the values in an array of sessions by using AJAX to reload the page. Once the data is submitted successfully, an HTML alert message is displayed in <p ...

Combining Two Tables Using jQuery

I am currently attempting to combine two tables into one using jQuery in the following manner: var table = document.createElement("table"); table.id = "mergedTable"; $("#mergedTable > tbody:last") .append($("#csvInfoTable2 > tbody").html()) ...

Move the Bootstrap button to the right side of the div, extending beyond its boundaries

My bootstrap page seems to be experiencing an issue where the buttons within a div are shifted slightly to the right without any clear reason: https://i.sstatic.net/3xlMC.png https://i.sstatic.net/yFLFM.png https://i.sstatic.net/gh686.png The div in qu ...

Is there a way to delay loading 'div' until a few seconds after the 'body' has been fully loaded?

Is there a way to delay the appearance of the "text-container" div after the image is displayed? I have attempted to achieve this using JavaScript with the following code: <script> window.onload = function(){ var timer = setTimeout("showText()",700 ...

Trouble aligning Material UI data-table columns (table head) to center in React

I have a data table where I declare rows and columns as simple variables, making it difficult to style them using 'style={{textAlign: center}}'. I tried adding a CSS file, but it did not work with the Material UI table. I am unsure of how to proc ...

Is it true that calc() functions exclusively with width and not height?

Recently, I attempted to vertically center a div on a page with a height of 100vh. The div has a height of 84px, so I tried using the following CSS: margin-top: calc(50% - 42px); Unfortunately, it appears that the browser always considers the width of t ...

Adding ordered lists using innerHTML in Angular are a fabulous way to organize and

Currently, my Angular CLI version is 13.3.6 with Node v16.12.0 and I'm encountering an issue when trying to utilize the innerHTML property. Within my Typescript file, I have a variable containing an ordered list like the following: let myText = "< ...

Receiving array data in a Javascript function and storing it within a variable

Hello everyone, please take a look at my code below. I am attempting to pass PHP array values to a JavaScript function. When I run the script, I receive alerts for parameter0=1, parameter1=2, and parameter2=3 separately. What I am trying to achieve is to ...

Angular 4 application fails to occupy the entire screen height

Here is how my app.component looks: <div class="wrapper"> <app-header></app-header> <router-outlet></router-outlet> <footer> <section class="page group"> {{ 'COMPANY.address' | translate ...

Is it possible to validate numerous fields as though they were just one?

My input follows a unique format based on specifications: Users are required to enter an ID in 4 separate fields where the ID is structured as 460 000 005 001. Here, '46' represents a country code and the remaining digits represent the user&apos ...

Clicking outside the navigation container will not cause it to disappear completely

When the width of my navigation bar reaches a maximum of 560px, a hamburger menu appears for mobile devices. I want to implement a functionality where clicking on a navigation item (e.g., About) will close the nav-container instead of making it disappear c ...

Emphasize a passage by clicking on a different section of text

Seeking Assistance I am currently customizing this template which incorporates the MixItUp plugin. My query pertains to highlighting the "filter tab" upon clicking on the corresponding text when hovering over each image, a task I find challenging as a new ...

Strange gray gradient background suddenly showing up on mobile devices

Encountering an issue with a login form displayed on a sliding modal. The design looks correct on desktop and even in responsive mode with dev tools, but when accessed through mobile Chrome or Safari on an iPhone, an unusual gray rounded box or shadow appe ...

Is it considered improper to include non-input HTML elements within a form tag in Angular reactive forms?

When working with an angular reactive form to manage html inputs, is it acceptable to include non-input html elements within the form tags? NOTE: The previous example has been removed. A new one will be provided soon. ...