Why is bootstrap not working all of a sudden? - css

I am running bootstrap on React, and then using Storybook to view it.
This is the code that I ran on Friday, and it was working without any problems. Today, I run it, and it's no longer working! I ran it on Jsfiddle and onecompiler, and still not working. I copied the carousel component from the bootstrap website, pasted it in my vscode, ran it, and it's not working! I pasted it in jsfiddle and onecompiler, and still not working! What is happening here? Why is it not working all of a sudden? Am I doing something wrong? By 'not working' I mean clicking on the left/right indicators does not move the slider!
Here's the code that I'm running:
<div id="carouselExampleIndicators" className="carousel slide" data-bs-ride="true">
<div className="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" className="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div className="carousel-inner">
<div className="carousel-item active">
<img src="https://hatrabbits.com/wp-content/uploads/2017/01/random.jpg" className="d-block w-100" alt="..." />
</div>
<div className="carousel-item">
<img src="https://hatrabbits.com/wp-content/uploads/2017/01/random.jpg" className="d-block w-100" alt="..." />
</div>
</div>
<button className="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
<span className="carousel-control-prev-icon" aria-hidden="true"></span>
<span className="visually-hidden">Previous</span>
</button>
<button className="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
<span className="carousel-control-next-icon" aria-hidden="true"></span>
<span className="visually-hidden">Next</span>
</button>
</div>
I just copied it from bootstrap, and just replaced class with className to make it work on React, but it's not working. Everywhere is where it's supposed to be with the exception that indicators and controls do not work.
I feel like the issue has to do with me using normal bootstrap for React, rather than React Bootstrap, which does work! But normal bootstrap also worked on Friday, why is it not working now? And why is it not working in any online compiler either? Does it work for you? Am I missing something?

Try checking the following to find a possible resolution :
Check if you have provided link to bootstrap in index.html or alternatively have you correctly installed bootstrap using npm.
Have you installed or linked to the correct version of bootstrap for which you have taken the carousel.
In my opinion, rule of thumb to get through the styles in frontend is to inspect the elements and the console. Try checking if bootstrap styles are applied to the divs in the inspect element styles.

Related

Bootstrap Modal Closing Behavior

I have a button Sign Up that loads in content from another file in the form of a Modal. When I click the button for the first time, the script works normally with no errors/warnings. However after the first time, if I dismiss the modal by clicking off of the element, clicking the Sign Up button again STILL WORKS, however it now throws a console error, stating $(...).modal(...).find(...).load(...) is not a function. In another one of my posts trying to solve this issue, I discovered the .load() method wouldn't work because I had the wrong version of jquery sourced in the file. But since then I have fixed that issue and the Modal now works, so I don't understand where this error is coming from.
Secondly, when the modal appears, it darkens the rest of the page (normal behaviour of the modal), if I try to dismiss the modal using the close button in the header, the modal disappears however the rest of my page is left darkened?/left out of focus? and the page becomes un-interactable...
Thirdly, I posted this as a seperate question due to the difference in nature: Bootstrap Modal messes up Carousel CSS
How do I fix these issues?
HTML file
<!-- NavBar -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Land Power</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home<span class="sr-only"></span></a>
</li>
<!-- <li class="nav-item ">
<a class="nav-link" href="contact.html">Contact Us<span class="sr-only"></span></a>
</li> -->
</ul>
</div>
<div class="d-flex justify-content-end">
<button class="signup btn btn-outline-success my-2 my-sm-0" type="button" linkFile="contact.html" data-toggle="modal" data-target="#theModal">Sign Up</button>
</div>
</div>
</nav>
<!-- Modal -->
<div class="modal fade" id="theModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Sign Up</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
Modal content load script
<script>
$('.signup').on('click', function(e){
e.preventDefault();
$('.modal').modal('show').find('.modal-body').load($(this).attr('linkFile'));
});
</script>
I think the issue here is likely that you are including bootstrap from two sources. Check your code to make sure you are including bootstrap from only one source. I had a similar issue not too long ago, solved when I realized bootstrap was being automatically included from another CDN.
Here is a jsfiddle containing your code inside a bootstrap template. It works as you have described it to.
https://jsfiddle.net/fatchild/b04r7Ljo/3/
It is a good idea to take your code out of context into a tool like JSfiddle in order to isolate the bug. As you can see there is nothing wrong with the code you have supplied.

how to move the buttons on the navbar to the right edge of the page

enter image description here
I want to move the bottons on the navbar to the right edge of the page. So I used the class " navbar-right" but the buttons stay at the center. what can i do?
here is what i wrote.
<nav class="navbar navbar-fixed-top navbar-inverse">
<div class="container-flulid">
<div class="navbar-header navbar-left ">
<a style="font-family:Serif;font-size:50px" class="navbar-brand" href="#">KHS</a>
</div>
<div id="barbuttons" class="navbar-right navbar-btn" >
<button style="width:150px;" type="button" class="btn btn-primary ">Home</button>
<button style="width:150px" type="button" class="btn btn-primary " >Portofolio</button>
<button style="width:150px" type="button" class="btn btn-primary ">Contact</button>
</div>
</div>
</nav>
navbar-right should do the trick.
You better investigate with browser dev tools.
For Chrome, hit F12 and select Elements then using the select elements tool (top left button), inspect the element styles.
More info: Inspect and Edit Pages and Styles
Explorer is similar; hit F12 and select DOM Explorer then using the select elements tool (top left button), inspect the element styles.
More info: Diagnose and fix layout problems
Other browsers have similar features.

Can't override Twitter Bootstrap btn class default font size

So here's the code:
<button class="btn btn-default btn-test" style="width:200px; white-space:normal;" id="up-arrow-div" >
<div class="col-xs-2 arrow-up-div" style="font-size:30 !important">
<span class="glyphicon glyphicon-collapse-up arrow-up" style="font-size:30 !important"></span>
</div>
<div class="col-xs-10">
Contribute more to support Last Minute Gear!
</div>
</button>
I've tried in 2 different places to make the glyphicon size bigger but to no avail. Output still looks like this:
Any thoughts?
change this:
<span class="glyphicon glyphicon-collapse-up arrow-up" style="font-size:30 !important"></span>
to this:
<span class="glyphicon glyphicon-collapse-up arrow-up" style="font-size:40px; !important"></span>
It appears you forgot to define a measurement type so I added px for you.
Let me know if that works
You are using style="font-size:30 !important"
You should use instead style="font-size:30px!important"

Bootstrap - css layout messed up after embedding external HTML as an object

Bootstrap newbie here. I'm trying to break down my bootstrap template into multiple segments (i.e. title, footer, left nav, and main content) for re-usability and ease of updating.
The problem I have is when I try to import the external HTML file using the object tag, it messes up the CSS layout.
<object name="foo" type="text/html" data="title.html"/>
When I don't use the object tag, it displays fine. However, if I strip out the "container" div into "title.html" and link it back in using the object tag, it fails. Is there a way to prevent that?
Here's a sample and the screenshots on what I'm trying to do:
<body>
<!-- start: Header -->
<header class="navbar">
<div class="container">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".sidebar-nav.nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a id="main-menu-toggle" class="hidden-xs open">
<i class="fa fa-bars"></i></a>
<a class="navbar-brand col-lg-2 col-sm-1 col-xs-12" href="index.html">
<span>Home Portal Link</span></a>
</div>
</header>
</body>
Screenshot 1: Failed page when use object tag
Screenshot 2: Working page - not using the object tag
Any advice is appreciated!

Cannot get bootstrap button to align center when working with href

If I remove the tag the button aligns perfectly but it doesn't link. I've tried multiple combinations with the anchors and no success. Please help.
NOT ALIGNING MIDDLE:
<div class="span12" style="text-align:center">
<a href="mailto:partnerships#medicaldoctorapps.com">
<button class="btn btn-large btn-primary">Contact us to get started</button>
</a>
</div>
ALIGNS MIDDLE FINE BUT NO LINK OUT:
<div class="span12" style="text-align:center">
<button class="btn btn-large btn-primary">Contact us to get started</button>
</div>
You must have some other CSS conflicting, take a look here with no CSS they both look fine (http://jsfiddle.net/4kZ3p/). Have you used inspect element (https://developers.google.com/chrome-developer-tools/docs/elements)? its a handy tool when debugging CSS.
Look in the css for the A tag.
-Ken
Needed to add this code to get the jsfiddle to submit but its just your code from above:
<div class="span12" style="text-align:center">
<a href="mailto:partnerships#medicaldoctorapps.com">
<button class="btn btn-large btn-primary">Contact us to get started</button>
</a>
</div>
<div class="span12" style="text-align:center">
<button class="btn btn-large btn-primary">Contact us to get started</button>
</div>
Insead of Span use the default col classes of Bootstrap.
<div class="col-lg-12" style="text-align:center">
<button class="btn btn-large btn-primary">Contact us to get started</button>
</div>
In Bootstrap 4:
<div class="col-12 text-center">
<a class="btn btn-outline-primary" href="mailto:partnerships#medicaldoctorapps.com">Contact us to get started</a>
</div>
as Ken Koch said, you may have conflict. If you test with Google chrome right click the button, inspect element and select the "a" tag to see how it's affected by css
If you're using bootstrap just use <a class = "btn btn-large btn-primary">
And here's a fiddle that works for me.
http://jsfiddle.net/HAsPV/
To bring center the text, you can use col-md-offset-3 (number can be used according to the need it helps).
<button type="button" class="btn btn-default center-block">Centered Button</button>

Resources