Troubination of Bootstrap CSS is causing issues on Floating Action Menu

I've implemented a Floating Action Menu using JQuery and CSS:

HTML:

<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<div id="hamburger" class="waves-effect waves-light">
    <div id="wrapper">
      <span class="icon-bar" id="one"></span>
      <span class="icon-bar" id="two"></span>
      <span class="icon-bar" id="thr"></span>
    </div>
  </div>

  (...) // Rest of the HTML code

Javascript / JQuery:

$('#hamburger').click(function() {
    $('#hamburger').toggleClass('show');
    $('.hamburger-nav').toggleClass('show');
});

CSS:

(...) // CSS properties defined for different elements

This implementation was functioning well until I added Bootstrap CSS, causing issues.

<link rel="stylesheet" href="https://getbootstrap.com/dist/css/bootstrap.min.css" type="text/css">

You can see the buggy behavior when Bootstrap is included in this Fiddle. Is there a way to resolve conflicts between my code and Bootstrap while still utilizing Bootstrap's CSS?

Thank you for any assistance!

Screenshots of Working and Not Working States: https://i.sstatic.net/e82FS.png https://i.sstatic.net/1ETK6.png

UPDATE: Identifying the issue - bootstrap.css contains a conflicting class:

.show {
  display: block !important;
}

This class was overriding my custom styles. Renaming my class resolved the conflict. For debugging in Chrome, inspecting elements reveals all affecting classes in the Styles tab.

Answer №1

In my opinion, it's best to prioritize writing custom CSS before including Bootstrap CSS in your projects.

If you're facing issues, there are various methods to resolve them - whether using CSS alone or incorporating additional HTML wrappers along with CSS. I will demonstrate the solution using only CSS.

To center a child element inside its parent element, you can utilize the following code:

position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

By applying this code to elements like .hamburger-menu > img and #hamburger > #wrapper, you will achieve the desired outcome.

Edit: The same principle applies to text labels, except in this case, you would only need to transform along the Y-axis and not the X-axis.

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

Why is my jstree create_node event not being triggered even though the node is successfully created?

Even though I am able to successfully create the node, the event is not firing as expected. There are no reported errors in Firefox. What could be causing this issue... $("#treeFile1").jstree("create", null, "outside", { "attr" : { "rel" : "folder" } ...

Is it possible to utilize jQuery to insert a chosen form into a table?

Here is the code example I am working with: <label for="">Select Ticker: </label> <select class="form-control" style="display: inline" id='selected'> {% for p in tickers %} <option value="{{ p.tick ...

A textarea with a height of zero is still visible

My goal is to create collapsible widgets within a side panel on my webpage. Overall, the functionality works smoothly. I am able to adjust the height of child divs to 0px with a transition, causing them to disappear. However, I have run into an issue wher ...

PHP function fails to retrieve AJAX post data

I'm struggling with some code in my javascript. Here's what I have: data = {}; data.token = '880a505d0a86b2sfwe434fdg43gwsf'; url = '/test/ajax/'; $.ajax({ url: url, type: "POST", d ...

Steps to make a unique custom tooltip without using jQuery by utilizing the title attribute

I am looking to implement a tooltip similar to the one shown in the image. The value in the title tag is dynamic and fetched from the controller. https://i.sstatic.net/C2v3D.png Below is the code snippet of my table: <table border="1" cellpadding="10" ...

Utilizing jQuery to modify the text output from an input form

Check out the preview site at . It's a test version before launching on a separate domain. Hello, I need to customize the error response for a CRM contact form integrated into Wordpress with the help of StackOverflow. The form is connected via JavaSc ...

Duplicate an HTML document while excluding specific class div elements

If you want to duplicate your HTML file using jQuery, it can be done like this: alert($("html").clone().html()); My objective is to replicate the entire program while excluding divs with the class '.ignore', but so far I am only able to display ...

Event trigger malfunction or potential issue with index activation

.full-arrow is a unique arrow that allows selection of the next page. The .full-navigation serves as a navigation bar, consisting of boxes in a line that change color upon selection. Although the full function may not be displayed here, you can grasp the b ...

Unable to place a div below another div

I am in the process of creating a website for my mother, using my limited knowledge. Despite numerous attempts, I have not been able to achieve the desired outcome. Currently, the website looks like this: https://i.stack.imgur.com/ItOcp.jpg However, I e ...

Issue with the Flexigrid jQuery plugin displaying "processing, please wait" indefinitely

I've been working on implementing flexigrid on my website, and everything seems to be going smoothly except for one issue - the data just won't load! It's continuously stuck at "processing, please wait." Take a look at my HTML file: <!D ...

Options for Printing HTML - Explore Different Techniques for Creating HTML Printouts and Weigh the Advantages and Disadvantages

As I work on maintaining an application, I am faced with the task of printing out a report. However, my curiosity extends beyond this assignment as I wonder about the various ways to format an HTML page for optimal printing results and the advantages and d ...

Having trouble triggering a modal on dropdown selection in Laravel blade?

I have a Laravel application where I need to implement a dropdown menu with three options inside a form. The options are loaded dynamically from the database through my controller. {{ Form::select('roles', $roles , $userRole,array('class&ap ...

Difficulty locating XML nested tags using Jquery

After querying an rss feed, I am receiving back some XML data. Here is a snippet of what it looks like: <channel> <item> <description><![CDATA[<h5>18 Jun 2013: Zambia 2013</h5> <p>Welcome Home! <br /&g ...

Place a button in relation to the top of its parent element

I am trying to display control buttons at the top of a table cell when hovering over an image within the cell. Here is the HTML structure I have: <table id="pridat_fotky"> <tbody> <tr> <td class=" ...

Utilize ajax to round the floating point number

When working with JSON data, I extract the values and attempt to round them using the script below: function onLoad(){ var output = $('#product'); var id = getUrlVars()["cPath"]; $.ajax({ ...

Steps to create a thumbnail image following the insertion of an image into an input type="file" within a form, and subsequently submitting both elements on the form together

Currently, I am working on a form that enables users to upload images. Once the user submits the form, my goal is to create thumbnails for each image on the front-end and save them on the server afterwards. Due to security restrictions, changing the value ...

Guide on transferring href parameter from the parent Vue component to the child component

Hey there! I've been working on creating a Vue page, breaking it down into components, and populating it with content from json. It all seems pretty straightforward, but I've hit a snag. Why is the href parameter not showing up in the right place ...

Deactivate the child division by the nth parent division

At the end of my question, I have included a dynamically created div structure with the id "forth-three-one". Now, I need to find a way to disable or hide the input inside this specific div. Directly using the id "forth-three-one" is not an option as it w ...

What is the best way to adjust the height of the second column downwards?

I am trying to achieve a 2-column layout with both columns at the same height. This is how it currently appears: And this is how I want it to be: Here is my code snippet: html { background-color: lightblue; font-family: Tahoma, Geneva, sans-serif ...

"Troubleshooting problems with jQuery accordion collapse and styling using CSS

I'm currently dealing with an issue regarding my accordion design. I have customized the stylesheet using themeroller, but when I collapse one of the sections, the header changes to black instead of reverting back to its original red color. I've ...