CSS Buttons with a rounded design on one edge

I need to create a button that looks like this:

https://i.sstatic.net/jWwHm.png

Although I thought it would be simple, I'm having difficulty with creating the rounded edges and adding additional color.

Currently, my attempt looks like this (but the colors aren't quite right):

.home_header_buttons {
  display: flex;
}

.home_header_buttons .btn_home {
  position: relative;
  text-transform: uppercase;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 2.4px;
  margin-right: -2.4px;
  line-height: 13px;
  background-color: rgba(8, 17, 23, .5);
  border: 1px solid #173c3d;
  padding: 30px 60px;
}

.home_header_buttons .btn_home:first-child {
  color: #16dcf3;
  border-right: none;
}
.home_header_buttons .btn_home:first-child::after {
  content: '';
  position: absolute;
  display: block;
  background: radial-gradient(circle at center, #007278 20%, #0b111a 100%);
  width: 1px;
  height: 90%;
  top: 50%;
  transform: translateY(-50%);
  right: 0;
  z-index: 1;
}

.home_header_buttons .btn_home:last-child {
  color: #64ffb1;
  border-left: none;
}
<div class="home_header_buttons">
    <a href="#" class="btn_home">Coaching</a>
    <a href="#" class="btn_home">Order now</a>
</div>

I've attempted using border-top-left-radius and border-bottom-left-radius, but the result is not aesthetically pleasing.

This is how it appears on my development side:

https://i.sstatic.net/Lj1QZ.png

Thank you for any assistance you can provide.

Answer №1

If you're searching for information on the border-radius properties, you'll find that they can be individually specified.

In particular, you should take note of border-top-left-radius and border-bottom-left-radius on

.home_header_buttons .btn_home:first-child
, as well as border-top-right-radius and border-bottom-right-radius on
.home_header_buttons .btn_home:last-child
.

I've used a value of 50px for each in my example. Take a look at the code snippet below to see it in action:

.home_header_buttons {
  display: flex;
}

.home_header_buttons .btn_home {
  position: relative;
  text-transform: uppercase;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 2.4px;
  margin-right: -2.4px;
  line-height: 13px;
  background-color: rgba(8, 17, 23, .5);
  border: 1px solid #173c3d;
  padding: 30px 60px;
}

.home_header_buttons .btn_home:first-child {
  color: #16dcf3;
  border-right: none;
  border-top-left-radius: 50px;
  border-bottom-left-radius: 50px;
}

.home_header_buttons .btn_home:first-child::after {
  content: '';
  position: absolute;
  display: block;
  background: radial-gradient(circle at center, #007278 20%, #0b111a 100%);
  width: 1px;
  height: 90%;
  top: 50%;
  transform: translateY(-50%);
  right: 0;
  z-index: 1;
}

.home_header_buttons .btn_home:last-child {
  color: #64ffb1;
  border-left: none;
  border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
}
<div class="home_header_buttons">
  <a href="#" class="btn_home">Coaching</a>
  <a href="#" class="btn_home">Order now</a>
</div>


When it comes to adding color, remember that you cannot directly color individual corners. Instead, utilize border-left-color and border-right-color to apply color to the border edges:

.home_header_buttons {
  display: flex;
}

.home_header_buttons .btn_home {
  position: relative;
  text-transform: uppercase;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 2.4px;
  margin-right: -2.4px;
  line-height: 13px;
  background-color: rgba(8, 17, 23, .5);
  border: 1px solid #173c3d;
  padding: 30px 60px;
}

.home_header_buttons .btn_home:first-child {
  color: #16dcf3;
  border-right: none;
  border-top-left-radius: 50px;
  border-bottom-left-radius: 50px;
  border-left-color: blue;
}

.home_header_buttons .btn_home:first-child::after {
  content: '';
  position: absolute;
  display: block;
  background: radial-gradient(circle at center, #007278 20%, #0b111a 100%);
  width: 1px;
  height: 90%;
  top: 50%;
  transform: translateY(-50%);
  right: 0;
  z-index: 1;
}

.home_header_buttons .btn_home:last-child {
  color: #64ffb1;
  border-left: none;
  border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
  border-right-color: green;
}
<div class="home_header_buttons">
  <a href="#" class="btn_home">Coaching</a>
  <a href="#" class="btn_home">Order now</a>
</div>

To expand these colors further, make use of border-top-color and border-bottom-color, but note that this will color the entire edge uniformly:

.home_header_buttons {
  display: flex;
}

.home_header_buttons .btn_home {
  position: relative;
  text-transform: uppercase;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 2.4px;
  margin-right: -2.4px;
  line-height: 13px;
  background-color: rgba(8, 17, 23, .5);
  border: 1px solid #173c3d;
  padding: 30px 60px;
}

.home_header_buttons .btn_home:first-child {
  color: #16dcf3;
  border-right: none;
  border-top-left-radius: 50px;
  border-bottom-left-radius: 50px;
  border-left-color: blue;
  border-top-color: blue;
  border-bottom-color: blue;
}

.home_header_buttons .btn_home:first-child::after {
  content: '';
  position: absolute;
  display: block;
  background: radial-gradient(circle at center, #007278 20%, #0b111a 100%);
  width: 1px;
  height: 90%;
  top: 50%;
  transform: translateY(-50%);
  right: 0;
  z-index: 1;
}

.home_header_buttons .btn_home:last-child {
  color: #64ffb1;
  border-left: none;
  border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
  border-right-color: green;
  border-top-color: green;
  border-bottom-color: green;
}
<div class="home_header_buttons">
  <a href="#" class="btn_home">Coaching</a>
  <a href="#" class="btn_home">Order now</a>
</div>

Answer №2

Try using pseudo elements along with border-radius for creating color effects.

.home_header_buttons {
  display: flex;
}

.home_header_buttons .btn_home {
  position: relative;
  text-transform: uppercase;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 2.4px;
  margin-right: -2.4px;
  line-height: 13px;
  background-color: rgba(8, 17, 23, .5);
  border: 2px solid #173c3d;
  padding: 30px 60px;
  box-sizing:border-box;
}

.home_header_buttons .btn_home:first-child {
  color: #16dcf3;
  border-right: none;
  border-radius:50px 0 0 50px;
}
.home_header_buttons .btn_home:first-child::before {
  content:"";
  position:absolute;
  top:-2px;
  bottom:-2px;
  left:-2px;
  width:70px;
  border: 3px solid red;
  border-radius:inherit;
  border-right:none;
}
.home_header_buttons .btn_home:first-child::after {
  content: '';
  position: absolute;
  display: block;
  background: radial-gradient(circle at center, #007278 20%, #0b111a 100%);
  width: 1px;
  height: 90%;
  top: 50%;
  transform: translateY(-50%);
  right: 0;
  z-index: 1;
}

.home_header_buttons .btn_home:last-child {
  color: #64ffb1;
  border-left: none;  
  border-radius:0 50px 50px 0;
}
.home_header_buttons .btn_home:last-child::before {
  content:"";
  position:absolute;
  top:-2px;
  bottom:-2px;
  right:-2px;
  width:70px;
  border: 3px solid blue;
  border-radius:inherit;
  border-left:none;
}
body {
 background:pink;
}
<div class="home_header_buttons">
    <a href="#" class="btn_home">Coaching</a>
    <a href="#" class="btn_home">Order now</a>
</div>

Answer №3

Adding color to the outer perimeter may seem tricky, but using border-radius can help achieve rounded edges on the left and right sides. The simplest method is to adjust the radius of the container:

.your-container {
  border-radius: 500px;
  -webkit-border-radius: 500px; 
}

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

Reordering div elements with JavaScript

Let's say we have the following structure: <div id="left"> <div id="1"></div> <div id="2"></div> <div id="3"></div> <div id="4"></div> <div ...

What is the process for including an SVG file in my JavaScript .textContent?

I've been struggling to add an exclamation SVG to this section, but for some reason I can't make it work. I've searched on Google for a solution, but haven't found one yet. The SVG file is already downloaded and stored in my project fo ...

Tips for getting the sidebar to move down on mobile devices

When viewing my website on a mobile device, the sidebar appears above my products. I would like it to be positioned below my products. The sidebar is currently on the left side with content on the right. Is there a more effective way to create a sidebar ...

Issues with Twitter Bootstrap Tabs not functioning correctly on Ruby on Rails with HAML

I am facing an issue with twitter bootstrap tabs in my (HAML) ruby on rails project. Although the tabs are appearing, the content does not change when I click on different tabs. Additionally, some unexpected statements are showing up at the bottom of the f ...

BS grid malfunctioning in a non-uniform manner

When a division in the advantage grid is clicked, the card body of another division collapses. However, this does not occur in the disadvantage grid. Clicking on one section in the disadvantage grid does not collapse another section as it does in the advan ...

An irritating bug causing a 1px difference in Chrome 21

Hey there, I've encountered a strange issue with the datepicker on this website. It works perfectly fine on IE8+, Firefox 14, Chrome 20, and Opera 12. However, as soon as Chrome updated to version 21, things went haywire! I'm baffled and can&apos ...

Avoid controlling the arrangement (parallel alignment)

Check out my fiddle here: http://jsfiddle.net/BFSH4/ In this fiddle, I'm facing two main issues: The h1 and h2 elements are not lining up vertically. The nav and content sections are not aligning horizontally. I've tried adjusting margins and ...

What is the reason that this particular JQuery code is malfunctioning in the IE browser once integrated into my website?

Currently, I am utilizing the DDCharts jQuery plugin from DDCharts JQuery to incorporate some charts into my website. After downloading the plugin and testing it in various browsers, I encountered an issue specifically with Internet Explorer 8+. Strangely, ...

The issue of assigning Ajax data to jQuery inputs with identical classes is not being resolved correctly

I am currently developing an Invoicing System where the Rate(Amount) value changes automatically when the Product(Item) is changed. The issue I am encountering is that when I change the first Product, all the other Product Rates change to the Rate of the ...

How to create horizontal spacing between divs using Bootstrap 3

I am struggling to create a small horizontal space between the "Away Team" and "Baseball Field" divs in my code. I have tried adjusting padding, margins, and even adding decimal column offsets without any success. The desired spacing effect can be seen in ...

What is the best way to create collapsible rows in AngularJS with ng-repeat?

In my current project, I am utilizing ng-repeat to display objects in rows. To achieve my desired functionality of only displaying elements present in the DOM, I decided to use a helpful plugin called angular-vs-repeat. However, I am facing an issue with u ...

Incorporating Twitter Bootstrap into your Zend Framework 2 Navigation Menu

I have successfully created a menu from my database and the code is functioning perfectly. Now, I'm looking to enhance the menu's style by incorporating Twitter Bootstrap, but I'm encountering some difficulties in doing so. Is there anyone k ...

Is there a way to perfectly center an SVG image and text within a linked button?

After creating a button that utilizes an SVG image icon on the left and text on the right, I encountered an issue where the text could not be perfectly centered in alignment with the icon. Here is how it currently appears: https://i.sstatic.net/FGGVi.png ...

Tips for deleting text on a webpage either prior to or following a certain character

Is there a way to remove everything after either 'am' or 'pm' in the date (the excerpt) on a WordPress site that has a list of headlines followed by a source attribution and a date? Example: NBA Finals: Warriors will face Cavaliers ye ...

What is the method for adjusting the border color of an ng-select component to red?

I am having an issue with the select component in my Angular HTML template. It is currently displaying in grey color, but I would like it to have a red border instead. I have tried using custom CSS, but I haven't been able to achieve the desired resul ...

What are the best practices for ensuring design responsiveness with the Bootstrap grid system across various screen resolutions?

<div class="row"> <div class="col-xl-4 col-md-12 col-sm-12 col-lg-4 data-one"> <one /> </div> <div class="col-xl-4 col-md-12 col-sm-12 col-lg-4 dashboard-two"> <two /> </div> <div ...

Develop a dynamic progress bar using jQuery

I am having trouble creating a percentage bar using jquery and css. The code I have written is not working as expected, particularly the use of jquery css({}). Here is the code snippet: *'width' : width - seems to be causing issues for me / ...

Fixing alignment and responsiveness problems with a hovering circle div

I have 3 circular divs that resize slightly when you hover over them, but this resizing also occurs if you hover near them. Additionally, I want them to be centered with some responsive spacing. Here is a live demo: demo Below is my code: <div id ...

Using CSS zoom to enhance JQuery/Javascript Smart Guides

Lately, I've been exploring the idea of incorporating 'smart guides' into one of my JQuery Draggable projects. This project involves a variable zoom level, and I've made adjustments in my code to accommodate it. However, I'm encoun ...

Bootstrap Modal for WooCommerce

I'm facing an issue while trying to create a modal window using woocommerce variables ($product). The problem lies in the placement of my modal and accessing the correct product id. Here is the code snippet I've been working on. Unfortunately, i ...