Visual feedback on Bootstrap button outlines when clicked

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

Hello, I'm currently working on styling the border around the primary button (btn-primary) and I'm facing an issue where a light blue border appears after clicking which seems to be unaffected by adjusting the outline property to 0. Can someone guide me on how to remove this border from the button?

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e5878a8a919691978495a5d0cbd5cbd5c887809184d6">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous"gt;
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c5a7aaaab1b6b1b7a4b585f0ebf5ebf5e8a7a0b1a4f6">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
  <title>Document</title>

  <style>
    * {
      box-sizing: border-box;
    }
    
    .container {
      max-width: 520px;
      max-height: 180px;
      background-color: antiquewhite;
    }
    
    fieldset {
      max-width: 518px;
      max-height: 178px;
      padding-right: 15px;
      padding-left: 15px;
    }
    .btn{
        font-weight:600;
        color:#fff;
        text-align:center;
        vertical-align:middle;
        border:1px solid transparent;
        font-size:1.2rem;
        line-height:1.5;
    }
    .btn-primary {
  color: #fff;
  background-color: #1172f4;
  border-color: #000000;
}
.btn-primary:hover {
  color: #fff;
  background-color:#1172f4;
  border-color: black;
}
.btn-primary:focus, .btn-primary:focus {
  color: #fff;
  background-color:#1172f4;
  border-color: #1875f6;
  box-shadow: 0 0 0 0.2rem rgba(38, 38, 38, 0.5);
}

.btn:focus, .btn:focus {
  outline: 0;

}
button:focus{
    outline:0;
}



    /*.form-group{
        max-width:518px;
        
    }*/
  </style>

</head>

<body>
  <div class="container">
    <div class="row">

      <div class="col-sm-6 col-sm-offset-3 form-box">

        <form role="form" action method="post" class="registration-form" style="width:482px;height:175px;background-color:aqua;margin-left:5px;margin-right:5px;padding-left: 20px;padding-right: 20px;">

          <fieldset>
            <!--Start 2nd form field set-->
            <div class="form-bottom">
              <div class="form-group" style="margin-top:20px;width:100%;">

                <input type="text" name="form-email" placeholder="Enter Your email" class="form-email form-control" id="form-email">
              </div>
              <!--End of 2nd form groupdiv-->

              <button type="button" class="btn btn-primary btn-next" style="margin-top:20px;margin-bottom:20px;padding-right:15px;width:100%;">Get Started</button>
            </div>
            <!--End of bottom div-->

          </fieldset>
          <!--End of second form fieldset-->
        </form>

</body>

</html>

Also, my container and elements are not displaying responsive behavior as expected. Any help in fixing these issues would be greatly appreciated. Which property within the bootstrap btn-primary button is responsible for handling both border concerns?

Answer №1

Why are you declaring styling for buttons twice here?

.btn: focus, .btn. Focus {
  outline: 0;

}
button: focus{
    outline:0;
}

It is not recommended to style HTML components directly in web design. Using classes is a better practice than styling elements directly. For specific styling, consider using IDs.

In response to your inquiry, it appears to be similar to this query on removing the box-shadow property from a Bootstrap button when clicked: Bootstrap button - remove outline on Chrome OS X. The correct approach is to update your button styles with the following code:

.btn:focus{
  box-shadow: none!important;

}

This modification will eliminate the shadow effect after clicking the button.

Furthermore, it seems that you are already utilizing Bootstrap 5 and inheriting its styles. It is unnecessary to manually redefine the primary button styles. Your imported CSS file should automatically apply the updates to the primary button style. Remember not to include a space between "focus" and ":".

To address your responsiveness concerns, consider making your form responsive using the Bootstrap library since you are already leveraging its capabilities. https://getbootstrap.com/docs/4.0/components/forms/

Answer №2

The visual effect surrounding a button after being clicked is not controlled by the outline property but rather the box-shadow property.

To address this issue, simply include the following in the button's CSS: box-shadow: none !important.

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

Retrieving data from a dynamic identifier

When testing the sort order of search results, I encountered an issue with one specific search. The problem lies in the auto-generated ID for each row, which changes every time the search is performed. For example, I can use the following code snippet: s ...

Executing Jquery code inside a PHP function

I am facing an issue with a form on my website where the form entries are not clearing when the submission message is displayed. I believe using Jquery to hide the form entries upon submission would solve this problem. The form in question has the ID of ...

Transforming a Joomla template into a standard HTML template

I have a question about Joomla. Although I already have a Joomla template that was not originally intended for use with Joomla, I would like to utilize it as an HTML template so I can easily modify and edit it without using Joomla. Therefore, I am looki ...

Using Jquery to select the parent element and then adding a CSS selector to it

I am currently exploring the most effective approach to accomplish this task. My goal is to expand/collapse all hidden divs on a given page. While this is usually not an issue, I have four distinct sections that necessitate independent expand/collapse func ...

Display a message in jQuery when the same option is chosen more than once

I need help with my form that has an input text field and a select dropdown. Here is the markup: <div id="form-wrap" style="width:500px; margin: 0 auto;"> <table> <tr> <th width="55%">Service Name</th> ...

Incorporating photos within the layout of a Twitter Bootstrap grid

Looking to showcase images like the ones found here: https://i.stack.imgur.com/eD4GD.jpg These images are original and come in various sizes. I want a hover effect that includes blur, fogging effects, and text placed in the middle of the picture. Check ou ...

What is the best way to use CSS to hyphenate a capitalized word?

I have a single word that needs to be hyphenated, but the lang=en hyphenate: auto property does not work on capitalized words. To address this, I utilized the slice function in JavaScript to split the word in half so that the second half, which requires h ...

What is the best way to save Arabic text in a MySQL database from an HTML form using PHP?

I've been searching extensively, but have had no luck! >> Following the PHP connection I included: mysql_set_charset('utf8', $conn); >> The form input tag has the attribute: accept-charset="utf-8" >> I confirmed that the d ...

Can the limit value of an SQL query be replaced with input from an HTML form?

Here is my question: SELECT * FROM learning_assessment.tbl_qna order by rand() limit 10; The table tbl_qna contains questions. My goal is to replace the static limit value of "10" with a number entered by an administrator in an input field. <html> ...

Tips for creating animated card designs with HTML, CSS, and JavaScript

As I delve into the realm of CSS animation, my primary focus is on replicating the captivating card shuffling animation showcased at Here's a glimpse of the progress I've made so far: https://youtu.be/GDIJ2K22cnY While I've successfully im ...

Adding text on top of images for optimal mobile viewing

I'm struggling to ensure that the text stays contained next to the image. It's working fine on desktop and tablet, but I'm facing challenges with mobile. While I have managed to improve it slightly, I can't figure out what exactly I am ...

Is there a way to exclusively show the browser name and version while excluding any supplementary details with 'HTTP_USER_AGENT'?

I am trying to modify my script to only display the browser version and name using 'HTTP_USER_AGENT'. I want to ensure that my script still covers all modern browsers in case someone helps me and specifies the code only for the Safari browser. C ...

Angular 2 Form Error: Control Not Found

I'm facing an issue with Angular 2 Forms where adding more than one control seems to be getting ignored. Despite following numerous guides on how to properly implement this, none of the suggested methods seem to work in my case. In my template, I hav ...

Ensure the server is reachable

I have been developing a web tool using PHP, HTML, and MySQL. I am looking for a way to periodically check the server's reachability. Currently, I am using a simple query sent through a JQuery-Ajax function to display an OK message if successful or an ...

Issue in Less.js: the 'min' function encountered an error due to incompatible types

In my _main.less file, I have the following styling: #mapid { width: 100%; min-height: min(65vh, 500px); max-height: 500px; } However, when using the Less compiler with grunt, it throws an error: >> File "public/less/_main.less" chan ...

Finding and implementing the page URL in JavaScript

Basically, I only want a certain script to be called if the URL is not "blogs.html". Here are some examples where the script should NOT be called: mydomains.com/blogs mydomains.com/blogs.html And here are some examples where the script should be called: ...

What is the best way to ensure that a Flex div and its child images stay confined within the boundaries of its parent container?

I'm struggling to create a responsive grid of images. I can't get the images to be both responsive with max-height and max-width, while also making sure the parent div takes up their full width. On the other hand, if I make the parent div the cor ...

I'm puzzled as to why my JavaScript code only functions correctly when I place it after the HTML, despite having a window.onload event handler in place

Just beginning my journey in a CS class and seeking guidance for my lack of basic knowledge. I've noticed that this JS code only works if placed after the HTML, not within the head tag. Shouldn't window.onload handle that? Can someone clarify wha ...

jquery has a strange behavior where the dialog window will cover up the scrollbar when the main

Currently, I am utilizing jQuery dialog to display a dialog window. I have managed to position it at the bottom left corner as desired. However, when the main window contains a scrollbar, the dialog ends up overlapping with the scrollbar instead of alignin ...

What is the process for designing a navigation bar with both text and icons?

Does anyone know how to replicate the navigation bar similar to Stack Overflow's navbar with a search form and icon? I have tried using it but cannot figure out a way. <div class="form-group"> <input type="text& ...