How to show the arrow in popper-js

The name of the picture


How to show the arrow in popper-js



I'm trying to use popper-js, but I have a hard time reading the documentation and to get things working. I can't seem to get the arrow to show (the triangle thingy pointing to the referenceElement).



The code below is narrowed down to what I'm trying to do. The popper is shown and positioned on content load. But how to configure the popper? (And also things like the offset to the subject).


<!DOCTYPE html>
<html>
<head>
<style>
h1 { text-align:center;}
#info_box { border:1px solid black; background:ivory; padding: 2px 6px; }
</style>
</head>
<body>
<h1><span id="info_title">Lorem Ipsum passage</span></h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div id="info_box">
<div class="arrow"></div>
The standard Lorem Ipsum passage, used since the 1500s.
</div>
<script src="https://unpkg.com/popper.js/dist/umd/popper.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded',function(){
var info_title = document.getElementById('info_title');
var info_box = document.getElementById('info_box');
var popper = new Popper(info_title, info_box, {placement:"bottom", modifiers:{arrow:{element:'.arrow'}}});
});
</script>
</body>
</html>



An image says more than a thousand words. I actually get this:



Actual



And I want this (forgive my drawing skills, I actually want the arrow to have a matching color):



enter image description here





you should declare popper. In your code is not. var popper = new Popper()
– Aliaksandr Pitkevich
2 hours ago







OK, but how? There is only class-level documentation...
– doekman
2 hours ago





how? I had already show you :) if u go to documentation u will see declaration of popper joxi.ru/D2P5eNLSp6YQPA . So, do the same in your code
– Aliaksandr Pitkevich
2 hours ago





Ah right, I didn't understand. However, no change in behaviour...
– doekman
2 hours ago





I just tried some different things, and this is what I tried last. I now think it should be something like {modifiers:{arrow:{element:'.arrow'}}}, but that doesn't work either.
– doekman
2 hours ago


{modifiers:{arrow:{element:'.arrow'}}}




1 Answer
1



I made some changes, but i hope you will understand



https://codepen.io/anfield343/pen/xJdBzp



Propbably, the main problem was: you are using <div> instead of <span>


<div>


<span>






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

How to scale/resize CVPixelBufferRef in objective C, iOS