Button side features an inverse curve shape

I've come up with a design for some "button tabs" where one side is curved, making it tricky to implement border radius. I'm wondering if this kind of curve is even possible without using images. Any tips on how to achieve this or any resources I can explore? My attempts so far have not been successful.

HTML

<div class="tab-row">
    <button>All Products<div class="tab-row__counter">20</div></button>
    <button>Hardware<div class="tab-row__counter">20</div></button>
    <button>Virtual<div class="tab-row__counter">20</div></button>
    <button>Bundles<div class="tab-row__counter">20</div></button>
</div>

CSS

.tab-row{
    button{
        background-color:$element-bg;
        border:0;
        color:$white;
        width:300px;
        height:90px;
        margin-right:20px;
        margin-top:40px;
        border-radius: 5px 100px 0 0;

        &:first-child{
            margin-left:40px;
        }
        .tab-row__counter{

        }
    }
}

This is the result I came up with, check it out here: https://codepen.io/andrelange91/pen/YzPqJXO

It's not perfectly curved but it's pretty close!

Answer №1

To create unique and visually appealing design elements, you can experiment with the border-radius, transform, and transform-origin properties in CSS. Here is an example of how you can achieve slanted tabs using these properties:

/**
 * Slanted tabs with CSS 3D transforms
 * See http://lea.verou.me/2013/10/slanted-tabs-with-css-3d-transforms/
 */

body { padding: 50px;background:#20273d }

nav {
position: relative;
z-index: 1;
white-space: nowrap;
}

nav a {
position: relative;
display: inline-block;
padding: 1.5em 2em 1em 1em;
color:#9a9a9a;
text-decoration: none;
margin: 0 -7px;
}



nav a::before {
content: ''; /* To generate the box */
position: absolute;
top: 0; right: 0; bottom: .5em; left: 0;
z-index: -1;
border-radius: 10px 10px 0 0;
background: #434f78;
box-shadow: 0 2px hsla(0,0%,100%,.5) inset;
transform: perspective(5px) rotateX(2deg);
transform-origin: bottom left;
}


nav a.selected {
z-index: 2;
  color:#FFF;
}
<nav class="left">
<a href="#" class="selected">All Products</a>
<a href="#">Hardware</a>
<a href="#">Virtual</a>
</nav>

In addition to this technique, you can also utilize radial gradients to enhance your design further:

body { padding: 50px;background:#20273d }

nav {
position: relative;
z-index: 1;
white-space: nowrap;
}

nav a {
position: relative;
display: inline-block;
padding: 1em 5em 1.2em 1em;
color:#9a9a9a;
text-decoration: none;
margin: 0 -20px;
border: 0px none;
}



nav a::before {
content: ''; /* To generate the box */
position: absolute;
top: 0;
right: 0;
bottom: .5em;
left: 0;
z-index: -1;
background: radial-gradient(circle at top right,transparent 5.8vw, #434f78 6.8vw);
transform: perspective(10px) rotateX(1deg);
transform-origin: bottom left;
border: 0px none;
}


nav a.selected {
z-index: 2;
  color:#FFF;
}
<nav class="left">
<a href="#" class="selected">All Products</a>
<a href="#">Hardware</a>
<a href="#">Virtual</a>
</nav>

Answer №2

While this may not perfectly match the specific shape you desire, it does offer a demonstration of the technique I outlined in the previous comments for achieving it. Simply adjust the values within ::before and ::after to achieve your desired result.

.curve {
  background: blue;
  width: 50px;
  height: 75px;
  position: relative;
}

.curve:before {
  content: '';
  background-image: radial-gradient(circle at 100% 100%, rgba(204, 0, 0, 0) 100px, blue 100px);
  position: absolute;
  top: 0;
  left: 100%;
  width: 100px;
  height: 75px;
}

.curve:after {
  content: '';
  position: absolute;
  width: 50px;
  height: 75px;
  background: blue;
  border-radius: 0 0 100% 0 / 0 0 100% 0;
  top: 100%;
  left: 0;
}

.container {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.tab {
  height: 150px;
  width: 300px;
  background: red
}
<div class="container">
  <div class="tab"></div>
  <div class="curve"></div>
</div>

For further guidance, refer to Creating s-shaped curve using css

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

When a child of a flex-item does not inherit the height of its parent in a flex container with a column direction and flex-basis set

Wow, that title was long! Let me try to clarify my confusion: So I have a flex-container with 2 flex items. <!-- HTML --> <div class="container"> <div class="item-1"> <div class="child-of-item-1"></div> < ...

Issue with Bootstrap 5 grid system, div falling down

I'm having some trouble with my HTML code here. <div style="height: 100px;" class="col-6 bg-success mt-40 d-inline-block">1</div> <div style="height: 100px;" class="col-6 bg-success mt-40 d-inline-bloc ...

Ways to specifically load a script for Firefox browsers

How can I load a script file specifically for FireFox? For example: <script src="js/script.js"></script> <script src="js/scriptFF.js"></script> - is this only for Firefox?? UPDATE This is how I did it: <script> if($. ...

Avoid the URL colon being converted to %3A

Is it possible to pass a colon from one form to another through a hyperlink without ending up as %3A? It seems like the link keeps converting it to %3A. For instance, currently: Attempting to achieve: current: ...

Generate a distinct identifier for the select element ID whenever a new row of data is inserted into a table

Although my title accurately describes my issue, I believe the solutions I have been attempting may not be on the right track. I am relatively new to javascript and web development in general, so please forgive me for any lack of technical terminology. Th ...

How to eliminate the validation icon from a select tag in Bootstrap 5?

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="23414c4c57505751425363160d110d11" ...

The functions domElement.getClientWidth() and domElement.getClientHeight() are returning a value of 0

When trying to extract the size of a GWT element with a specific CssClass using standard methods, I am faced with the issue that it returns 0; Canvas canvas = Canvas.createIfSupported(); if(canvas == null){ /*alert code*/ } Element ...

How about placing one element above another? What sets apart using the margin property versus the position property for achieving this effect?

As I pondered the concept of stacking context, a question arose in my mind. Through my readings, I learned that by not applying any CSS properties that create a stacking context (such as position), it is possible to stack elements on top of each other usin ...

Manipulating classes with JQuery through click events

$('.toggle-button').on('click', function() { $('body').addClass('changeCursor'); }); $('.toggle-button.toggle-active').on('click', function() { $('body').removeClass('c ...

Validating the Javascript on my report page

I am struggling to implement JavaScript validation for a report on my table. My JavaScript skills are not strong, and although I have server-side validation in place, I need client-side validation as well. The structure of my page is as follows: <tr> ...

creating a dictionary with headers and body using beautiful soup

I am currently in the process of scraping data from a website (example page) and my goal is to utilize headers as keys and the text below each header as the corresponding value. Here's a snippet of what I have implemented so far: import requests impor ...

Adjust the height of the rows in the column to match the height of the parent

I'm struggling to figure out how to make the child content fill the height of a column. I've tried using Bootstrap grid system and flex utilities. The only solution that somewhat worked was setting the row height to 50%, but the issue is, I don& ...

Turning off arrow key navigation for tabs in Material UI ReactJS

I'm currently utilizing ReactJS Material UI tabs navigation. My aim is to deactivate the arrow keys navigation of Tabs in Material UI. What I desire is to navigate using the Tab key, and upon pressing Enter, it should display the page beneath that ta ...

Is it necessary to include CDN @imports when optimizing CSS files in a Require.js/Backbone app using r.js?

In my CSS file, I've included an external font from Google Font using the @import rule. styles.css /* You can use @import. r.js will handle merging them during the build process */ @import "../vendor/bootstrap/css/bootstrap.css"; //this has been inc ...

transform the stationary drawing to the top and left position at coordinate (0,0)

Exploring canvas has led me to encounter a puzzling issue with the translate method. While working on this fiddle http://jsfiddle.net/claireC/ZJdus/4/, my goal was to have the drawing move and bounce off all four walls. However, I noticed that it would no ...

Incorporate a background image property using Jquery

Can anyone help me with adding the css background-image:url("xxxxx") property to my code? jQuery('#'+$trackID+' .sc_thumb').attr('src',$thumb_url); jQuery('#'+$trackID+' .sc_container').css('display& ...

Instructions on how to prompt users to register using a distinctive code

Currently in the process of constructing a website and I'm interested in setting restrictions on the number of users who can sign up for it. https://i.stack.imgur.com/JD2Ct.png In the image provided, there is a database in phpMyAdmin labeled as &apo ...

Enhancing the asp.net MVC link element with an ID property

I am currently working on a web application that contains the following link: <a href="@planUrl">@ResourceManager.GetResource("MemberLinkText")</a>. I need to add an ID to this link in order to incorporate a $(document).onClick() handler. Howev ...

Tips for vertically aligning table cells within Bootstrap

I am facing an issue with a bootstrap table that contains a form-inline in a specific column, which is causing the contents in other columns to not be vertically centered. (As shown in the 1st code snippet) How can I resolve this problem? If I remove the ...

Creating a Stylish ExtJS Container with CSS: A Step-By-Step

I've been experimenting with the ExtJS properties cls, bodyCls, and componentCls but unfortunately, I'm not achieving the desired outcome. As an illustration: Ext.create('Ext.form.Panel', { renderTo: document.body, title: &apo ...