HELP with a button

hello guys, i would like to know who i do a button like this in html css!
No description
30 Replies
Zoë
Zoë14mo ago
I have text and a background applied to the same place using grid, then I apply a skew to the background. This background could have a solid colour or a border. Apply a larger padding to the text to change the size of the button I initially did thicker borders thinking that thin wouldn't look good but it looks fine You can click buttons outside of what is visible, however buttons next to each other act predictably in the middle. You'd need a slightly more complicated method to get the button clickable area to line up
snxxwyy
snxxwyy14mo ago
@z- ::theProblemSolver:: @Do Contra you can simply just do this https://codepen.io/deerCabin/pen/YzddJLe
Zoë
Zoë14mo ago
Of course, also fixes buttons being clickable where it looks clickable
snxxwyy
snxxwyy14mo ago
yeah, i believe it also simplifies your example a little too?
Zoë
Zoë14mo ago
Yeah They both feel like bodges but in different ways
snxxwyy
snxxwyy14mo ago
yeah, if you take a look at mine, i recommend using a custom property for the skew value so it's easier to maintain.
Zoë
Zoë14mo ago
Of course
snxxwyy
snxxwyy14mo ago
hopefully they find use out of both good methods and things to take note of in both
DoContra
DoContraOP14mo ago
thanks soo muchh guys it was so helpful my code doesnt work
DoContra
DoContraOP14mo ago
No description
DoContra
DoContraOP14mo ago
the text
DoContra
DoContraOP14mo ago
No description
snxxwyy
snxxwyy14mo ago
what does the html look like?
DoContra
DoContraOP14mo ago
No description
snxxwyy
snxxwyy14mo ago
you've got to use another element inside of the button tag, in the css the button > * is selecting everything within the button tag, that's what the wildcard selector does (*), you'll have to do this-
<button>
<p>Text here</p>
</button>
<button>
<p>Text here</p>
</button>
DoContra
DoContraOP14mo ago
hmmm make sense sorry im a rooky xD
snxxwyy
snxxwyy14mo ago
no worries, i was in your position once haha @Do Contra does it work for you now?
DoContra
DoContraOP14mo ago
yheyhe
DoContra
DoContraOP14mo ago
No description
snxxwyy
snxxwyy14mo ago
👍
capt_uhu
capt_uhu14mo ago
another option here is to use a skewed pseudo element as a background panel. That way you don't need the extra p tag or to un-skew the text.
snxxwyy
snxxwyy14mo ago
i feel that'd be harder to keep a track of and maintain on a large scale you'd have to create a utility class for buttons for something like that
snxxwyy
snxxwyy14mo ago
i updated the codepen with an example of that if any of ya'll would like to look- https://codepen.io/deerCabin/pen/YzddJLe/
capt_uhu
capt_uhu14mo ago
it's also worth pointing out here that these are not semantically buttons. These should be links that are styled to look like buttons.
snxxwyy
snxxwyy14mo ago
i believe links that take you outside of the site, to another page, need to be anchor tags? if it's not that, it should be a button right?
MarkBoots
MarkBoots14mo ago
btw, little tip, now you are not skewing the button anymore, but the ::before psuedo element, you don't need the <p> tags anymore also, instead of setting top/left and width/height. you can just use inset: 0 for those 4 lines
capt_uhu
capt_uhu14mo ago
yep that's pretty much it. Here's the best explanation i could find on a quick google: https://css-tricks.com/a-complete-guide-to-links-and-buttons/ although i'd imagine Kevin probably has a video on this too
snxxwyy
snxxwyy14mo ago
Awesome I’ll check it out, with my example they weren’t meant to be links, that’s why they’re buttons Oh cool, I didn’t know that, and I forgot to remove the p tags haha
Zoë
Zoë14mo ago
I just assumed that OP wanted buttons and so I gave them buttons. Could have been to open a modal
Want results from more Discord servers?
Add your server