切换布局
显示结果
<!DOCTYPE html> <html> <head> <title>Popper 教程</title> <style> #tooltip { background: #333; color: white; font-weight: bold; padding: 4px 8px; font-size: 13px; border-radius: 4px; } </style> </head> <body> <button id="button" aria-describedby="tooltip">My button</button> <div id="tooltip" role="tooltip">My tooltip</div> <script src="https://unpkg.com/@popperjs/core@2"></script> <script> const button = document.querySelector('#button'); const tooltip = document.querySelector('#tooltip'); const popperInstance = Popper.createPopper(button, tooltip); </script> </body> </html>