Fix the style of the CSS for the Bootstrap button

I am currently testing two social media buttons, one using an Anchor Tag and the other using a Button Tag for experimental purposes.

The problem I am facing is that when I click on the button, its color and border change to the default bootstrap .btn styling (black color, blue border) instead of the desired #33CAFF color and border.

It should be noted that the color changes back to #33CAFF once I click elsewhere on the screen.

However, my objective is to have the styling return to its pre-click state after clicking the button.

For visual reference, here are images illustrating the current behavior:

Current State: https://i.sstatic.net/7M82Q.jpg

Desired State: https://i.sstatic.net/e9lE4.jpg

Answer №1

Kindly insert your preferred color code in CSS as demonstrated below:

.btn or button class / Id name: focus{
color:#33CAFF; (your color code)
}

Answer №2

To implement this design, simply insert the following code:

.myBtn:focus {
    background-color:#fff;
    color:#33CAFF;
    outline:none;
}

You can view a live demo of this code on JSFiddle.

Answer №3

You opted to use <a> for facebook and <button> for twitter

@import url(https://fonts.googleapis.com/css?family=Nunito);
body{
  background-color:#33CAFF;
  font-family:'Nunito',sans-serif;
}
#myDiv{
  background-color:#fff;
  color:#33CAFF;
  margin-top:20px;
  padding:20px;
  line-spacing:1.5px;
}
.myBtn{
  background-color:#fff;
  color:#33CAFF;
  border:1px solid #33CAFF;
  border-radius:0;
  padding:10px;
  margin:5px;
}
a:visited{
  background-color:#fff;
  color:#33CAFF;
}
.myBtn:hover{
  background-color:#33CAFF;
  color:#fff;
  text-decoration:none;
}
a:active{
  background-color:#fff;
  color:#33CAFF;
}
button:focus{
}
<div class="container">
  <div class="row">
    <div id="myDiv" class="col-sm-6 col-sm-offset-3 text-center">
      <h2>Some Text goes here</h2>
      <p>Lorem ipsum dolor sit amet, te eam option discere saperet, quo porro libris te, quo ea eirmod gloriatur. Qui et mutat numquam consetetur, mei blandit delectus no, eam at adipisci senserit. Cibo error at mei. At pri nullam altera, pri diam noster scripta eu. Eu quot iudicabit sadipscing vix.       </p>
      <a type="button" class="btn myBtn">
        <i class="fa fa-facebook"></i> Facebook
      </a>
      <a type="button" class="btn myBtn">
        <i class="fa fa-twitter"></i> Twitter
      </a>
    </div>
  </div>
</div>

Access the JSFiddle link for more information

Answer №4

To implement this style change using CSS, you can use the following code:

.myBtn:focus
    {
    background-color:#fff;
    color:#33CAFF;
    border:1px solid #33CAFF;
    }

However, I fail to understand why one element needs to be styled as a button while the other as a link.

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

Utilizing the power of JavaScript, CSS, and HTML to seamlessly transfer selected items from one webpage to the shopping cart displayed on another page

Due to limitations on using back-end code, I'm seeking advice on how to implement this function. Most tutorials I've come across show the items and shopping cart on the same page. I've heard suggestions about using Jquery.load(), but I&apos ...

Using JQuery to manipulate `this`, its children, its siblings, and more

Can anyone help me determine the most effective way to send data from a get request to a specific div? My challenge is to send it only to a div that is related to the one triggering the action. For example, when I click on the message_tab, I want to send t ...

Switching effortlessly between Fixed and Relative positioning

As I work on creating a unique scrolling experience, I aim to have elements stop at specific points and animate before returning to normal scroll behavior once the user reaches the final point of the page. Essentially, when div X reaches the middle of the ...

Is there a way to ensure uniform font display across all browsers?

Is there a way to ensure consistent font display across all browsers? I am facing an issue with font consistency on my webpage. While browsers like Internet Explorer Edge and 11, Chrome, and Firefox display the desired font correctly, Internet Explorer 8 ...

What could be causing the appearance of a mysterious grey box hovering in the upper left portion of my image and why is the code only adjusting the size of the grey box instead of the entire

I've been working on embedding some JavaScript into my Showit website to create a drag-and-drop feature that displays a collage/mood board effect. Everything is functioning correctly, but I'm running into issues with resizing the images. There&a ...

What is the best way to add CSS to email addresses that are hidden by the WordPress antispambot feature?

My current method involves utilizing the WordPress antispambot code from their Code Reference: https://developer.wordpress.org/reference/functions/antispambot/ While the code is functional, I am interested in customizing the appearance of the email addre ...

How to toggle the visibility of checkboxes in JavaScript based on their checked status

I am facing an issue with some checkboxes as I am unable to filter them based on whether they are checked or not. The concept is simple. When I click on "All", all the checkboxes should be displayed. However, when I click on "Selected", only the selected ...

Initiate the React application with the given external parameters

I have created a React app that is embedded within a webpage and needs to start with specific parameters obtained from the page. Currently, I am passing these parameters in the index.HTML file within a div element. The issue arises when these parameters ar ...

Here's a unique rewrite: "Learn how to manipulate the CSS class of a textarea element (specifically in NicEdit) by utilizing the addClass

I am currently validating a textarea using the NicEdit plugin. var getContent = nicEditors.findEditor("SubSliderDescription").getContent(); bValid = bValid && checkBlankTextArea(getContent, "SubSliderDescription") function checkBlankTextArea(o, ...

The peculiar effect of a CSS element's border on surrounding elements is quite unusual

I'm experiencing a strange issue that I can't quite figure out. To demonstrate the problem, I've created a fiddle. What's puzzling me is why applying a border to one of the three canvases causes my other two .headerMainDiv elements to ...

Creating a visual that when clicked, reveals an enlarged version at a different location

Is there a way to make an image appear in a different location on the page when it's hovered over? I've searched online but couldn't find a solution using just HTML and CSS. Does anyone know how to achieve this effect? Image not hovered: ht ...

Displaying information on a table using data from three separate JSON arrays within AngularJS

I have some JSON data: { tableList:["a","b"], dbList:["c","d"], score:[2 , 5] } I would like to display this data in a table using AngularJS like so: DB Table Score c a 2 d b 5 Can we utiliz ...

Updating information on a website

My goal is to allow users to provide input text that will dynamically replace existing text on the webpage. For example, if there is a name displayed in an HTML element, I have created a form where the user can type their own name and submit it. Once sub ...

Ways to evaluate the amount of traffic on a webpage?

Recently, I encountered an issue while creating a page to showcase blog posts. Each post had the typical social media share buttons like "Facebook like," "tweet this post," and "+1." Additionally, there were some extra JavaScript functions added for variou ...

What methods do publications use to manage HTML5 banner advertisements?

We are working on creating animated ads with 4 distinct frames for online magazines. The magazines have strict size limits - one is 40k and the other is 50k. However, when I made an animated GIF in Photoshop under the size limit, the image quality suffered ...

Merge two separate arrays to create a new associative array

I'm faced with the challenge of merging two arrays of data obtained from an HTML form. The first array (payment_descriptions) is structured as follows: ["1st Desc","2nd Desc","3rd Desc"] While the second array (payment_ ...

The alignment of an image within a bootstrap table cell may not appear centered

I am struggling to center an image in a table cell that is wider than the image itself. I have tried using the text-center and align-middle classes in Bootstrap, but the image remains on the left side of the cell. Since I am new to Bootstrap, I am not fa ...

Manage image placement using CSS object-position

I have the following code snippet: img{ width: 100%; height: 1000px; object-fit: cover; object-position: left; } <!DOCTYPE html> <html lang="en"> <head> <meta charset ...

Combining different HTML table borders

Here is some example code: <!DOCTYPE html> <html> <body> <h4>Creating a table with nested tables:</h4> <table border="1"> <tr> <td>100</td> <td>200</td> <td> </td> < ...

Header with Sticky Behavior and Smooth Slide Down Animation

I am trying to achieve a scroll effect on my page where the header will move up when scrolling up, but at position 150 it should smoothly slide down and stay fixed at the top. I have tried various methods but haven't been able to get it right. Can som ...