I'm trying to get an alert to disappear when the "x" button is clicked, but there seems to be something missing that's keeping it from working, not sure what it is.
<div class="alert alert-success alert-dismissible">
<button type = "button" class="close" data-dismiss = "alert">x</button>
You've done it!
</div>
for dismissible to work, you need to include jQuery and bootstrap.js in your document.
<!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">
<title>Bootstrap 101 Template</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="alert alert-success alert-dismissible">
<button type = "button" class="close" data-dismiss = "alert">x</button>
You've done it!
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div style="margin-top: 50px" class="alert alert-success alert-dismissible">
<button type = "button" class="close" data-dismiss = "alert">x</button>
You've done it!
</div>
Related
What my dir looks like:
I've doubled checked the name, the location everything, but it just shows the default no image found icon image. My code for the picture is <img src="img.png">. I tried changing the image, still no fix. When I hover over the img.png is says
[Follow link](file:///c:/Users/mathe/OneDrive/Documents/Data analysis/Python/CHAT-BOT/templates/img.png) (ctrl + click), so surely it should work?
Full html code:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MJChat Bot</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>
<body>
<img src="img.png" alt="Italian Trulli">
<div class="container">
<h1>Welcome to MJ Chatbot</h1>
<hr>
<br>
<div class="row">
<div class="col-lg-9">
<input class="form-control" type="text" name="question" id="question">
</div>
<div class="col-lg-3">
<button class="btn btn-primary btn-block" id="submit-button">Send</button>
</div>
</div>
<br>
<div class="row">
<div class="col">
<p id="response"></p>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script>
jQuery(document).ready(function() {
$("#submit-button").click(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: "/chatbot",
data: {
question: $("#question").val()
},
success: function(result) {
$("#response").append("<br><br><img src='picture.jpg'/> You: "+$("#question").val()+ "<br><br><img src='picture.jpg'/> MJBot: "+result.response);
$("#question").val("")
},
error: function(result) {
alert('error');
}
});
});
});
</script>
</body>
</html>
I am quite new to the web app development. I have a web-map application based on OpenLayers 6.5. I want to add Bootstrap Modal that will be auto displayed whenever the web map is loaded. I tried to follow Bootstrap documentation but my Modal is not showing. I use Bootstrap v.3.4. Here is the snippet of my code:
<!doctype html>
<meta charset="utf-8"/>
<html lang="en">
<head>
<!-- Ol CSS -->
<link rel="stylesheet" href="libs/v6.5.0/css/ol.css" type="text/css">
<link rel="stylesheet" href="libs/v6.5.0/examples/resources/layout.css" type="text/css">
<link rel="stylesheet" href="libs/ol-layerswitcher-master/dist/ol-layerswitcher.css" />
<!-- Ol JS -->
<script src="libs/v6.5.0/build/ol.js"></script>
<script src="libs/ol-layerswitcher-master/dist/ol-layerswitcher.js"></script>
<script src="libs/jquery.min.js"></script>
<!-- Ol-ext extension -->
<link rel="stylesheet" href="libs/ol-ext-master/dist/ol-ext.css" />
<script type="text/javascript" src="https://viglino.github.io/ol-ext/dist/ol-ext.js"></script>
<!-- J-Query -->
<link rel="stylesheet" href="libs/jquery-ui-1.12.1/jquery-ui.css">
<script src="libs/jquery-ui-1.12.1/external/jquery/jquery.js"></script>
<script src="http://158.194.94.29:8081/webgis/libs/jquery-ui-1.12.1/jquery-ui.js"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="libs/bootstrap.min.css">
<script type="text/javascript" src="libs/bootstrap.min.js"></script>
<body>
<div id="title"> <marquee behavior="scroll" direction="right"><h5><b>Title goes here</b></h5>
</marquee></div>
<!-- MODAL WINDOW -->
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Welcome to web-map app!</h5>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<img class="capimg" src="https://sss.jpg" width="300" height="100" />
<p style="text-align:justify">Text here</p>
</div>
</div>
</div>
</div>
<div id="map">
etc.
Any idea why the modal is not showing?
here is the code. Run Snippet. The modal popup is opening on load.
$(window).on('load', function() {
$('#myModal').modal('show');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="libs/v6.5.0/css/ol.css" type="text/css">
<link rel="stylesheet" href="libs/v6.5.0/examples/resources/layout.css" type="text/css">
<link rel="stylesheet" href="libs/ol-ext-master/dist/ol-ext.css" />
<link rel="stylesheet" href="libs/jquery-ui-1.12.1/jquery-ui.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
</head>
<body>
<div id="title"> <marquee behavior="scroll" direction="right"><h5><b>Title goes here</b></h5>
</marquee></div>
<!-- MODAL WINDOW -->
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Welcome to web-map app!</h5>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<img class="capimg" src="https://sss.jpg" width="300" height="100" />
<p style="text-align:justify">Text here</p>
</div>
</div>
</div>
</div>
<div id="map">
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
<script src="libs/v6.5.0/build/ol.js"></script>
<script src="libs/ol-layerswitcher-master/dist/ol-layerswitcher.js"></script>
</body>
</html>
Do you want the modal to be shown on page load?
In the above case, you haven't called the modal yet and thus it is hidden. A modal by itself will remain hidden until or unless it is called using an event. If you want the modal to be shown on page load, use the below code.
<script type="text/javascript">
$(window).on('load', function() {
$('#myModal').modal('show');
});
</script>
Your head tag is not closed.
I tried with external css and js files. It is working....
JSFIDDLE
<head>
</head> // This is closing tag
If you want to open modal on page load....
$(window).on('load', function() {
$('#myModal').modal('show');
});
I have a simple bootstrap tooltip button that should show a tooltip when I hover.However it does not work. I have followed many suggestions online about initialize tooltips on document load and it still won't work.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="../style.css">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"
integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<title>Parent View</title>
</head>
<body>
<div class="container mt-5">
<button type="button" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="">
Tooltip on top
</button>
<script type="text/javascript">
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
});
</script>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
</body>
</html>
When you put the script inside the HTML BODY it's execute before jQuery has loaded at the end of the body, so jQuery $ is undefined.
Move the script after jQuery, Bootstrap and Popper, or to the HTML HEAD tag.
And, make sure the Tooltip has a title.
<button type="button" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="My title">
Tooltip on top
</button>
Demo: http://codeply.com/go/2huMTgy7Q9
I have an alert div and a row inside a container, when I close the alert the row content moves up. I want to make the alert appear over the row content so that when I close it nothing happens.
<div class="container">
<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong>TEXT</strong>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="row align-items-center">
CONTENT
</div>
</div>
thanks in advance
Muhammad's suggestion could be made to work if you set the container to position: relative;
.container {position: relative;}
.alert {position: absolute; top: 0;}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar">
<div class="navbar-brand">Brand</div>
</nav>
<div class="container">
<h2>Alerts</h2>
<div class="alert alert-success alert-dismissable">
×
<strong>Success!</strong> This alert box could indicate a successful or positive action.
</div>
</div>
</body>
</html>
You could try using jQuery to change the visibility of the alert rather than it's display:
$('.alert').on('close.bs.alert', function (e) {
e.preventDefault()
$(this).css('visibility', 'hidden')
})
Here is a demo:
https://www.bootply.com/TazOvYZQyC
One way of doing this is to add the following CSS:
position:absolute !important;
top:0px;
to the alert div.
Here is a sample code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Alerts</h2>
<div class="alert alert-success alert-dismissable" style="position: absolute; top:0px;">
×
<strong>Success!</strong> This alert box could indicate a successful or positive action.
</div>
</div>
</body>
</html>
I have the following code and I am not sure why bg-info doesn't work for the whole body as I am new to bootstrap.
<!--http://v4-alpha.getbootstrap.com/getting-started/introduction/-->
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags always come first -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
</head>
<body class="bg-info">
<div class="container text-xs-center">
<h1 class="display-1">Fullstack Conference</h1>
<p class="lead">Coming soon!! A one day conference about all things Javascript!!</p>
</div>
<div class="col-lg-6 col-lg-offset-3">
<div class="input-group">
<input type="text" class="form-control" placeholder="Enter your Email for info...">
<span class="input-group-btn">
<button class="btn btn-secondary" type="button">Sign Up!</button>
</span>
</div>
</div>
</div>
<!-- jQuery first, then Bootstrap JS. -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>
</body>
</html>
Here's what I see:
Note: According to this video it should work though https://teamtreehouse.com/library/bootstrap-4-basics/getting-to-know-bootstrap-4/enhancing-the-page
You are using the alpha 4 of bootstrap(js), use bootstrap 3.x.
Also you have an extra </div> in the code.
This works:
<!--http://v4-alpha.getbootstrap.com/getting-started/introduction/-->
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags always come first -->
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous" />
</head>
<body class="bg-info">
<div class="container text-xs-center">
<h1 class="display-1">Fullstack Conference</h1>
<p class="lead">Coming soon!! A one day conference about all things Javascript!!</p>
</div>
<div class="col-lg-6 col-lg-offset-3">
<div class="input-group">
<input type="text" class="form-control" placeholder="Enter your Email for info...">
<span class="input-group-btn">
<button class="btn btn-secondary" type="button">Sign Up!</button>
</span>
</div>
</div>
</body>
<!-- jQuery first, then Bootstrap JS. -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</html>
What do you mean by doesn't work for the whole body? Try to add this CSS property to your custom CSS:
.bg-info {background: #5bc0de!important;
}