Bootstrap carousel chevron button and slides are not working - bootstrap-carousel

I've pasted my code for a bootstrap carousel below. It doesn't work, but I'm not sure why.
<div id="carouseldiv" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouseldiv" data-slide-to="0" class="active"></li>
<li data-target="#carouseldiv" data-slide-to="1"></li>
<li data-target="#carouseldiv" data-slide-to="2"></li>
<li data-target="#carouseldiv" data-slide-to="3"></li>
<li data-target="#carouseldiv" data-slide-to="4"></li>
<li data-target="#carouseldiv" data-slide-to="5"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="img/1.jpg" alt="1">
<div class="carousel-caption">
<p>PUBG : King of all games</p>
</div>
</div>
<div class="item">
<img src="img/2.jpg" alt="1">
<div class="carousel-caption">
<p>PUBG : King of all games</p>
</div>
</div>
<div class="item">
<img src="img/3.jpg" alt="1">
<div class="carousel-caption">
<p>PUBG : King of all games</p>
</div>
</div>
<div class="item">
<img src="img/4.jpg" alt="1">
<div class="carousel-caption">
<p>PUBG : King of all games</p>
</div>
</div>
<div class="item">
<img src="img/5.jpg" alt="1">
<div class="carousel-caption">
<p>PUBG : King of all games</p>
</div>
</div>
<div class="item">
<img src="img/6.jpg" alt="1">
<div class="carousel-caption">
<p>PUBG : King of all games</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#carouseldiv" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carouseldiv" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>

I compared your code snippet to the one on bootstrap's website.
It looks like you're not using the classes on your div's and spans that Bootstrap needs.
For example you have <div class="item"> when the Boostrap documentation shows <div class="carousel-item">. I also noticed you using glyphicon chevron's when you should be using <span class="carousel-control-prev-icon" aria-hidden="true"></span> and <span class="carousel-control-next-icon" aria-hidden="true"></span>.
Basically, after verifying that Bootstrap is correctly imported, you're going to need to go through the Bootstrap documentation code snippet and your own line-by-line to make sure the CSS classes used are the same. You'll probably find it helpful to start with a 2-slide carousel, rather than a 6-slide carousel.
You didn't post what version of Bootstrap you're using, so I assumed version 4.1 (the latest stable version as I'm writing this).

Related

Put a link on the right of a card - bootstap

I have a page (show route) that looks like this:
and i would like to position the link to "All Camgrounds" to the right of the card. I tried several things like adding classes like "text-right" or "justify-content-end", but it did not work.
I am using the framework Boostrap-5.
Any help would be much appreciated. Here is the code for the SHOW page :
<% layout('layouts/boilerplate') %>
<div class="row">
<div class="col-6 offset-3">
<div class="card">
<div class="card-header">
<h2>
<%= campground.title %>
</h2>
</div>
<img src="<%= campground.image %>" class="card-img-top" alt="...">
<div class="card-body">
<p class="card-text">
<%= campground.description %>
</p>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item text-muted">
<%= campground.location %>
</li>
<li class="list-group-item">
$ <%= campground.price %> /night
</li>
</ul>
<div class="card-body">
<a class="card-link btn btn-warning" href="/campgrounds/<%= campground._id %>/edit">Edit</a>
<form class="d-inline" action="/campgrounds/<%= campground._id %>?_method=DELETE" method="post">
<button class="btn btn-danger">Delete</button>
</form>
<a class="card-link d-inline text-right" href="/campgrounds">All
campgrounds</a>
</div>
</div>
</div>
</div>
There are many different ways to align right in Bootstrap 5.
In your case it's probably easiest to use float-end.
<div class="row">
<div class="col-6 offset-3">
<div class="card">
<div class="card-header">
<h2> Title </h2>
</div>
<img src="//via.placeholder.com/500" class="card-img-top" alt="...">
<div class="card-body">
<p class="card-text"> campground.description </p>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item text-muted"> campground.location </li>
<li class="list-group-item"> $ 39/night </li>
</ul>
<div class="card-body">
<a class="card-link btn btn-warning" href="/campgrounds/<%= campground._id %>/edit">Edit</a>
<form class="d-inline" action="/campgrounds/<%= campground._id %>?_method=DELETE" method="post">
<button class="btn btn-danger">Delete</button>
</form>
<a class="card-link float-end" href="/campgrounds">All campgrounds</a>
</div>
</div>
</div>
</div>
https://codeply.com/p/S9PyKHZC9y
Also note, left and right have been replaced with start and end in Bootstrap 5.

OpenLayers map not showing on Bootstrap Carousel

I have a search results screen showing 10 results (locations in the world) per page. If a result has an image available, the image will show, otherwise it shows the location on an OpenLayers map.
I'm just trying to upgrade this page using Bootstrap carousel to allow users to cycle between the map and the image (if available).
I got carousel working fine using 2 test images. However when I swap in the OL map, although the image/photo shows OK, when you cycle to the next item (the map), the map just shows a white screen / nothing shows.
Code is below. (FYI the map works fine when I pull it out of the carousel code.
Any ideas?
Happy to share the Ol.map code, although as mentioned it runs OK outside of carousel, so I assume it might be some sort of formatting/CSS issue.
<div class="carousel-inner">
<div class="carousel-item active">
<%= image_tag(#phototouse, class:"map img-responsive", style:"display:block;height: 100%;max-height:350px") %>
</div>
<div class="carousel-item">
<div id="<%= location.location_id %>" class="map" style="display:block;height: 100%;max-height:350px"></div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls<%= location.location_id %>" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls<%= location.location_id %>" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Update:
I thought I had got this working by adding in the updateSize event (below) but weirdly the map only shows when I resize the window. If I don't touch the window, the map doesn't show and I get the following java error: 'map1.updateSize is not a function'.
Any ideas?
<div class="container-fluid normaltextblack" style="background-color: #F3F3F3;">
<div class="row" style="height:350px">
<div id="sidel" class="col-0 col-sm-0 col-md-0 col-lg-5 col-xl-5">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="/assets/image1.jpg" alt="First slide" style="height:350px">
</div>
<div class="carousel-item">
<div id="testmap" class="map img-responsive" style="height:350px"></div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev" onclick="resizemap();">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next" onclick="resizemap();">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
<script>
function resizemap() {
setTimeout(function(){
var map1 = document.getElementById("testmap");
map1.updateSize();
}, 1000);
}
</script>

Bootstrap carousel in rails 6

I'm trying to create a bootstrap carousel for the homepage of a blog that scrolls through the last three articles from the database. I got it working for a carousel that advances automatically but I wanted to have the next and previous buttons but when I try in that one it does not work. I can get the first which is the last article in the table to display but it will not advance.
I couldn't figure out out a better way to get the last three articles so here is ow I did it. I am definitely open to suggestions to make this better. My home action for the pages_controller is:
def home
#articles = Article.last(3).reverse
#art1 = #articles.pop
#art2 = #articles.pop
#art3 = #articles.pop
end
Now the carousel:
<div id="carouselExampleCaptions" class="carousel slide" data-bs-ride="carousel">
<ol class="carousel-indicators">
<li data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" class="active"></li>
<li data-bs-target="#carouselExampleCaptions" data-bs-slide-to="1"></li>
<li data-bs-target="#carouselExampleCaptions" data-bs-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<%= image_tag(#art3.image.url, width: '100%') %>
<div class="carousel-caption d-none d-md-block">
<h5><%= #art3.title %></h5>
</div>
</div>
<div class="carousel-item">
<%= image_tag(#art2.image.url, width: '100%') %>
<div class="carousel-caption d-none d-md-block">
<h5><%= #art2.title %></h5>
</div>
</div>
<div class="carousel-item">
<%= image_tag(#art1.image.url, width: '100%') %>
<div class="carousel-caption d-none d-md-block">
<h5><%= #art1.title %></h5>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleCaptions" role="button" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleCaptions" role="button" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</a>
</div>
This works in the works in a version of the carousel that does not have buttons but advances automatically.

Changing a Dashboard from bootstrap 3 to bootstrap 4, how to fit the partialViews inside

I changed all the elements of my dashboard, for an example of the boostrap site itself, but after I made the change, all my partial views opening below the components of the admin screen
ScreenShot:
<nav class="navbar navbar-dark fixed-top bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-sm-3 col-md-2 mr-0" href="#">Company name</a>
<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">
<ul class="navbar-nav px-lg-5">
<li class="nav-item">
</li>
</ul>
#Html.Partial("_LoginPartial")
</nav>
<div class="container-fluid">
<div class="row">
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#Url.Action("Index", "Barcos")">
<span data-feather="home"></span>
Dashboard <span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="file"></span>
Orders
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
#RenderBody()
</main>
My Partial Example:
<div style="margin-top:40px" class="jumbotron">
<h1>EXAMPLE</h1>
</div>
Resolved, the renderbody was in the wrong place.
<div class="container-fluid">
<div class="row">
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#Url.Action("Index", "Barcos")">
<span data-feather="home"></span>
Dashboard <span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span data-feather="file"></span>
Orders
</a>
</li>
</ul>
</div>
</nav>
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
#RenderBody()
</main>
</div>
</div>

Add a "Split button" in collapsible-set (JQuery Mobile)

Is there are any way to add the split button (that comes with ListView) to the collapsible; I have tried/tested the below code, but doesn't work!
<div data-role="collapsible-set" data-theme="a" data-content-theme="e" data-split-icon="gear" data-split-theme="e">
<div data-role="collapsible">
<h3> Breakfast </h3>
<p>
<a href="somthing.html"> the contents comes here.
</a>
</p>
<a href="#purchase" data-rel="popup" data-position-to="window" data-transition="pop">
split button 2
</a>
</div>
<div data-role="collapsible">
<h3> Lunch</h3>
<p>
<a href="somthingElse.html"> the contents comes here.
</a>
</p>
<a href="#purchase" data-rel="popup" data-position-to="window" data-transition="pop">
split button 2
</a>
</div>
</div>
Any Idea or any other solution (workaround) is highly welcome.
Well it needs a little work but here is what I have
Live Example:
http://jsfiddle.net/yPhJp/5/
http://jsfiddle.net/yPhJp/6/ ( Adding verbiage to the collapsible )
JS
$(".splitButtonClicked").on("click", function (event, ui) {
alert('Hello');
return false; // stop collapsible event
});
HTML
<div data-role="page" id="home">
<div data-role="content">
<div data-role="collapsible-set" data-theme="b" data-content-theme="d">
<div data-role="collapsible">
<h2>
<ul data-role="listview" data-split-icon="gear" data-split-theme="d">
<li><a href="#">
<h3>Breakfast</h3>
</a>View Menu
</li>
</ul>
</h2>
</div>
<div data-role="collapsible">
<h2>
<ul data-role="listview" data-split-icon="gear" data-split-theme="d">
<li><a href="#">
<h3>Lunch</h3>
</a>View Menu
</li>
</ul>
</h2>
</div>
</div>
</div>
</div>
Hope this helps you

Resources