How to remove rounded corners of select box in Bootstrap?

I have written this code for creating a select box in bootstrap but the corners are coming rounded which i want to remove. How to do so? I tried a lot but could not find any solution for this. Please help me.

Here is the link of jsfiddle.net also

https://jsfiddle.net/ankitshri774/2redLfnc/7/

body {
  background-color: #E8E8E8;
}

label {
  float: left;
}

#main_container {
  background-color: white;
  margin-left: 10px;
  padding-left: 13px;
  margin-right: 10px;
  padding-right: 13px;
  padding-top: 13px;
  margin-top: 10px;
  box-sizing: border-box;
}

#container {
  background-color: aqua;
}

.select-wrapper {
  border: 1px solid black;
  border-radius: 0px;
}
<!doctype html>

<html lang="en">

<head>
  <title>Master Page</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" href="masterpage1.css">


  <!-- jQuery library -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

  <!-- Latest compiled JavaScript -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>


<body>



  <div id="main_container">

    <form>


      <div id="partymaster">
        <h3>Party Master</h3>
        <hr/>
      </div>

      <div class="row">

        <div class="col-md-4">
          <div class="form-group">
            <label>Category
                        <span style="color:red">*</span>
                    </label>
            <span class="select-wrapper"><select name="category" class="form-control no-radius">
                <option>A</option>      
                </select>
</span>
          </div>


        </div>


      </div>


    </form>


  </div>
</body>




</html>

5 answers

  • answered 2018-07-12 06:46 Khyati Agola Chandak

    Add the below line to your CSS file:

    .no-radius{
        border-radius:0px !important;
    }
    

  • answered 2018-07-12 06:46 לבני מלכה

    Use code below(set !important to prevent override)

    The border-radius is 4px because you set to select form-control class and it is bootstrap definition by default

    .no-radius{
      border-radius: unset!important;
    }
    

    See fiddle:https://jsfiddle.net/2redLfnc/29/

    body{
        background-color:#E8E8E8;
           
        }
        
        
            label{
                float: left;
            }
            
            #main_container{
                background-color: white;
                margin-left: 10px;
                padding-left:13px;
                margin-right: 10px;
                padding-right:13px;
                padding-top: 13px;
                margin-top: 10px;
                box-sizing: border-box;
            }
        
            #container
            {
                background-color: aqua;
            }
        
           
    
    
           .select-wrapper{
            border: 1px solid black;
            border-radius: 0px;
        }
    
    .no-radius{
      border-radius: unset!important;
    }
    <!doctype html>
    
    <html lang="en">
        
    <head>
    <title>Master Page</title>                  
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">        
    <link rel="stylesheet" href="masterpage1.css">
    
    
    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        </head>
        
    
        <body >
    
                
    
                <div id="main_container">
    
        <form>
        
       
       <div id="partymaster">
           <h3>Party Master</h3>
           <hr/>
       </div>
    
       <div class="row">
          
                <div class="col-md-4">
                    <div class="form-group">
                        <label>Category
                            <span style="color:red">*</span>
                        </label>
                        <span class="select-wrapper"><select name="category" class="form-control no-radius">
                    <option>A</option>      
                    </select>
    </span>
                    </div>
               
                
    </div>
    
    
    </div>
    
    
    </form>
    
    
    </div>
    </body>
    
    
    
    
        </html>

  • answered 2018-07-12 06:48 zubair khanzada

    Use select tag in styling select{border-radius: 0 !important;}

    body{
        background-color:#E8E8E8;
    
    }
    
    
    label{
        float: left;
    }
    
    #main_container{
        background-color: white;
        margin-left: 10px;
        padding-left:13px;
        margin-right: 10px;
        padding-right:13px;
        padding-top: 13px;
        margin-top: 10px;
        box-sizing: border-box;
    }
    
    #container
    {
        background-color: aqua;
    }
    
    
    
    
    .select-wrapper{
        border: 1px solid black;
        border-radius: 0px;
    }
    select{
        border-radius: 0 !important;
    }
    <html lang="en">
    
    <head>
        <title>Master Page</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <link rel="stylesheet" href="masterpage1.css">
    
    
        <!-- jQuery library -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
        <!-- Latest compiled JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    
    
    <body >
    
    
    
    <div id="main_container">
    
        <form>
    
    
            <div id="partymaster">
                <h3>Party Master</h3>
                <hr/>
            </div>
    
            <div class="row">
    
                <div class="col-md-4">
                    <div class="form-group">
                        <label>Category
                            <span style="color:red">*</span>
                        </label>
                        <span class="select-wrapper"><select name="category" class="form-control no-radius">
                            <option>A</option>
                        </select>
    </span>
                    </div>
    
    
                </div>
    
    
            </div>
    
    
        </form>
    
    
    </div>
    </body>
    
    
    
    
    </html>

  • answered 2018-07-12 06:56 MBaas

    The problem is that the form-control-class sets a radius of 4px. So you can't overwrite it with a different class on the same element (at least I would not know how to that). So as a quick fix, I have defined a different class form-control-without-radiusand am using that in my updated fiddle.

    .form-control-without-radius {
      display: block;
    width: 100%;
    height: 34px;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.42857143;
    color: #555;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc;
    } 
    

    However, this is a fundamental change of the entire layout, and I guess it would collide with many other UI-Components. So you may have to build your own custom Bootstrap. Some people find it easy to do with sass, I had more fun using the Bootstrap Theme Builder. And there are others as well. If you're not familiar enough with BT, this may sound like a scary idea - but my experience doing so has been only positive, so I'd go for it ;-)

    Update: I saw the unset !important-idea in other posts, neat idea! That make the whole thing simpler, of course. Have updated my fiddle accordingly.

  • answered 2018-07-12 07:37 mahan

    Use rounded-0 but in Bootstrap-4 only.

    body {
      background-color: #E8E8E8;
    }
    
    label {
      float: left;
    }
    
    #main_container {
      background-color: white;
      margin-left: 10px;
      padding-left: 13px;
      margin-right: 10px;
      padding-right: 13px;
      padding-top: 13px;
      margin-top: 10px;
      box-sizing: border-box;
    }
    
    #container {
      background-color: aqua;
    }
    
    .select-wrapper {
      border: 1px solid black;
      border-radius: 0px;
    }
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" />
    <div id="main_container">
      <form>
        <div id="partymaster">
          <h3>Party Master</h3>
          <hr/>
        </div>
        <div class="row">
          <div class="col-md-4">
            <div class="form-group">
              <label>Category
                <span style="color:red">*</span>
              </label>
              <span class="select-wrapper">
                <select name="category" class="form-control rounded-0">
                  <option>A</option>      
                </select>
              </span>
            </div>
          </div>
        </div>
      </form>
    </div>