Ways to add a circular radius to a button along with a select dropdown

I am trying to enhance the visibility of the drop-down caret, but currently it is not showing up as desired. My goal is to give both the <select> and <button> elements a circular radius similar to what is shown in the image.

.top-select{
   width: 70%;
   padding-left: 10px;
   border-top-left-radius: 50px !important;
   border-bottom-left-radius: 50px !important;
   border-top-right-radius: 50px;
   border-bottom-right-radius: 50px;
  
}
.find-btn{
   border: 1px solid;
   border-top-left-radius: 50px !important;
   border-bottom-left-radius: 50px !important;
   border-top-right-radius: 50px;
   border-bottom-right-radius: 50px;
}
.margin-appen{
   margin-left: -43px !important;
}
.btn-tutor:focus{
   box-shadow: none;
   outline: none;
}
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css">
   <!-- jQuery library -->
   <script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.slim.min.js"></script>
   <!-- Popper JS -->
   <script src="https://cdn.jsdelivr.net/npm/popper/dist/umd/popper.min.js"></script>
   <!-- Latest compiled JavaScript -->
   <script src="https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div>
                <div class="input-group mb-3">
                  <select class="select top-select" id="select02" >
                    <option selected>What do you want to learn</option>
                    <option value="1">One</option>
                    <option value="2">Two</option>
                    <option value="3">Three</option>
                  </select>
                  <div class="input-group-append margin-appen">
                    <label class="input-group-text find-btn" for="select02">
                      <button class="btn btn-tutor">Find tutor</button>
                    </label>
                  </div>
                </div>  

              </div>
</body>
</html>

Answer №1

.input-group{
border-radius: 50px;
border:1px solid red;
overflow:hidden;
width:400px !important;
flex-wrap: nowrap !important;
}

.top-select,
.top-select:focus-visible{
border:none;
outline:none;
width:70%;
padding-left:15px;
}
.find-btn{
  width:100%;
   border: 1px solid red !important;
   border-radius: 50px !important;
   justify-content: center;
}
.margin-appen{
  flex:1; 
}
.btn-tutor:focus{
   box-shadow: none;
   outline: none;
}
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e5c51514a4d4a4c5f4e7e0a1008100f">[email protected]</a>/dist/css/bootstrap.min.css">
   <!-- jQuery library -->
   <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5238232737202b12617c677c63">[email protected]</a>/dist/jquery.slim.min.js"></script>
   <!-- Popper JS -->
   <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e4e514e4e5b4c10544d7e0f100f08100f">[email protected]</a>/dist/umd/popper.min.js"></script>
   <!-- Latest compiled JavaScript -->
   <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2a4845455e595e584b5a6a1e041c041b">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div>
                <div class="input-group mb-3">
                  <select class="select top-select" id="select02" >
                    <option selected>What do you want to learn</option>
                    <option value="1">One</option>
                    <option value="2">Two</option>
                    <option value="3">Three</option>
                  </select>
                  <div class="input-group-append margin-appen">
                    <label class="input-group-text find-btn" for="select02">
                      <button class="btn btn-tutor">Find tutor</button>
                    </label>
                  </div>
                </div>  

              </div>
</body>
</html>

Answer №2

Your CSS is being overridden by your Bootstrap styling. One solution that is commonly used is to add !important to your radius values. However, relying on !important is not ideal as it may cause issues when trying to override styles in the future. This is where CSS priorities come into play.


In short:

To tackle this issue, consider assigning an additional ID to one of the main elements in your HTML code, for example:

<body id="bootstrap-overrides">

This way, you can simply prepend your CSS selectors with this ID, giving them extra weight and allowing them to take precedence over Bootstrap styles.


Essentially, each selector has its own level of specificity:

Inline styles > IDs > Classes/pseudo-classes > Tags/pseudo-elements

When two styles conflict, browsers will prioritize the one with higher specificity. The order of your stylesheets only matters when priorities are equal - making it tricky to override Bootstrap.

One approach is to delve into Bootstrap's source code, identify how a specific style is set, and replicate that selector in your own stylesheet to match its priority. However, this method may result in losing some of Bootstrap's benefits.

Alternatively, you can simplify the process by assigning an extra ID to a root element like so:

<body id="bootstrap-overrides">

(By the way, you can simply use border-radius:50px; instead of specifying each corner individually. For multiple radii, you can use border-radius: 50px 10px 2px 0px (clockwise))

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

Incorporating an HTML/Javascript game into a reactJS website: A step-by-step

After developing a game using plain javascript and HTML along with a few JS libraries, I find myself inquiring about the process of integrating this game into my ReactJS website. Typically, the game is initiated by opening the index.html file located with ...

Generate a nested array structure from an existing array using JavaScript

Currently, I have an array of numbers: [12345,345653,456356]. However, I need to convert this to a format like [[1232131],[234324],[67657]] in order to use a CSV react component tool that reads data in this specific structure. Does anyone have any ideas ...

What could be causing the double invocation of render() in ReactNative?

I'm currently working on an app with a single screen displaying a map centered on the user's current coordinates. In my code below, I've set the latitude and longitude to null in the state of the App component. Using the componentDidMount() ...

Arranging items in a vertical column using Bootstrap styling

I am facing a particular issue: The initial design is displayed in Picture 1: I am using Bootstrap 5 as my CSS framework. I attempted to utilize the pre-built columns feature, but so far, I have not been able to find a solution and am currently strugglin ...

When the month changes in the React AntDesign Calendar Component, it automatically selects the last chosen day

My goal is to store the selected day in the state when a user clicks on a specific date. However, I am encountering an issue where the previously selected day remains saved in the state even after changing the month. Upon logging the onSelect event to the ...

How can I ensure that my navbar-right remains fixed to the right side of the screen and is always visible at the top of the page as I

When the page first loads: After scrolling down: I am attempting to create a fixed navigation bar at the top of the screen, so that it remains visible as the user scrolls down the page. However, I am facing an issue where my navbar brand is positioned to ...

How to toggle classes on anchor tags using jQuery for Twitter Bootstrap buttons?

I built a single-page website. The navigation is made up of buttons styled with bootstrap 3. Since it's a single page, the buttons are anchor tags. I'm trying to figure out how to apply an .active class to the last clicked anchor tag. Here is t ...

Upon submission, the select input in Vue.js and PHP fails to persist

My situation revolves around a lack of knowledge. I have an HTML form where I am using Vue.js to populate a v-select input with PHP data: <div id="app"> <form> <v-select name="user2_id" placeholder="Select User" :options="[{!! $ ...

Developers can leverage Node4 and Gulp to seamlessly integrate TypeScript with EcmaScript2015 in their

When converting TypeScript to ES2015, I encounter the need for async/await functionality. However, I must then convert the ES2015 code to be compatible with Node4, which does not fully support ES2015 features. The issue arises when using TypeScript defini ...

Angular-CLI now has a feature where 'ng serve' will include Bootstrap multiple times in the project

Using Angular CLI in conjunction with Bootstrap 4 has been quite the endeavor. After finally getting everything set up, I noticed a peculiar issue when inspecting elements in my app. It seems that the bootstrap classes are being duplicated multiple times. ...

Discovering ways to monitor Service Providers

What Currently in my AngularJS project, I am attempting to monitor certain internal functions such as angular.module and serviceProvider. How Fortunately, I have managed to keep track of calls to angular.module successfully. var moduleCalls = spyOn(an ...

Why does my POST request result in [object Object] being returned?

I am just starting to learn AngularJS and I am unsure if my POST request is functioning correctly. After making the request, I am receiving an [object Object] response. What does this error indicate? Could it be related to an issue with the form? //Acti ...

What is the best way to transfer information between different pages in an HTML document?

I am facing a specific requirement where I must transfer form data from one HTML page to another HTML page. The process involves a total of 5 pages, with the user entering data in the following order: 1st page: Name 2nd page: Weight 3rd page: Height 4t ...

Is there a way to access the values that have been dynamically updated by JavaScript

Is it possible to parse an HTML page using the org.w3c.dom package? For example, let's take a look at . This webpage contains a counter that is updated by JavaScript. However, when trying to retrieve a value from: <div class='counter_field&ap ...

implementing jquery typewriter plug-in for a responsive bootstrap image

I am using Bootstrap and my image response dynamically, but I am having trouble adding text to it. I would like to use a jQuery typewriter plugin for the text on the image, which should resize according to screen size. Here is my HTML code and I have used ...

Having difficulty setting up multiple buttons to share the same function in jQuery using HTML

After clicking a button, my code dynamically adds content to a div and inserts buttons with names like "teamReq_"+index+"_AddYear" into the document (where index is a number retrieved from a hidden input field). If these buttons are spammed, multiple divs ...

What is the purpose of having the same function for onPress in React Native components?

As a beginner in learning react-native, I like to search random projects on GitHub and analyze what seems weird or hard to understand. Today, I came across some code from an unknown individual that looked like this: {isTrue && ( <Touch ...

Removing the border from a button in CSS and HTML

Looking to build a sleek and stunning website, but struggling with removing button borders. Any help would be greatly appreciated! If you'd like to check out the issue, visit this link: https://i.sstatic.net/daaec.jpg. I'm aiming for no button o ...

The document does not contain any serialized JavaScript files

Hey there, I'm facing an issue with my Codeigniter and JavaScript file upload and insertion into the database. I'm not getting any response, so could you please take a look at my code and share some valuable ideas? Below are the codes for the vie ...

Troubleshooting: Why the TableTools basic usage example is not functioning as

After replicating the code from http://datatables.net/release-datatables/extensions/TableTools/examples/simple.html in my Visual Studio project, I organized the files by saving two css files as style1.css and style2.css, along with three js files named sc ...