부트스트랩 JS 팝오버
JS 팝오버(popover.js)
Popover 플러그인은 툴팁과 유사합니다. 사용자가 요소를 클릭할 때 나타나는 팝업 상자입니다. 차이점은 팝오버에 훨씬 더 많은 콘텐츠가 포함될 수 있다는 것입니다.
플러그인 종속성: 팝오버를 사용하려면 부트스트랩 버전에 툴팁 플러그인(tooltip.js)이 포함되어 있어야 합니다.
팝오버 에 대한 튜토리얼은 부트스트랩 팝오버 튜토리얼 을 읽어보세요 .
데이터-* 속성을 통해
팝 오버 data-toggle="popover"
를 활성화합니다.
title
속성은 팝오버의 헤더 텍스트를 지정합니다 .
속성 은 data-content
팝오버의 본문 안에 표시되어야 하는 텍스트를 지정합니다.
예시
<a href="#" data-toggle="popover" title="Popover Header" data-content="Some
content inside the popover">Toggle popover</a>
자바스크립트를 통해
팝오버는 CSS 전용 플러그인이 아니므로 jQuery로 초기화해야 합니다. 지정된 요소를 선택하고
popover()
메서드를 호출합니다.
예시
// Select all
elements with data-toggle="popover" in the document
$('[data-toggle="popover"]').popover();
// Select a specified
element
$('#myPopover').popover();
팝오버 옵션
옵션은 데이터 속성 또는 JavaScript를 통해 전달할 수 있습니다. 데이터 속성의 경우 data-placement=""에서와 같이 옵션 이름을 data-에 추가합니다.
Name | Type | Default | Description | Try it |
---|---|---|---|---|
animation | boolean | true |
Specifies whether to add a CSS fade transition effect when opening and closing the popover
|
|
container | string, or the boolean false | false | Appends the popover to a specific element. Example: container: 'body' |
|
content | string | "" | Specifies the text inside the popover's body | |
delay | number, or object | 0 | Specifies the number of milliseconds it will take to open and close the popover. To specify a delay for opening and another one for closing, use the object structure: delay: {show: 500, hide: 100} - which will take 500 ms to open the popover, but only 100 ms to close it |
|
html | boolean | false | Specifies whether to accept HTML tags in the popover:
When set to false (default), jQuery's text() method will be used. Use this if you are worried about XSS attacks |
|
placement | string | "right" | Specifies the popover position. Possible values:
|
|
selector | string, or the boolean false | false | Adds the popover to a specified selector | |
template | string | Base HTML to use when creating the popover. The popover's title will be injected into the .popover-title. The popover's content will be injected into the .popover-content. .arrow will become the popover's arrow. The outermost wrapper element should have the .popover class. |
||
title | string | "" | Specifies the header text of the popover | |
trigger | string | "click" | Specifies how the popover is triggered. Possible values:
|
|
viewport | string, or object | {selector: "body", padding: 0} | Keeps the popover within the bounds of this element. Example: viewport: '#viewport' or {selector: '#viewport', padding: 0} |
팝오버 방법
다음 표에는 사용 가능한 모든 팝오버 방법이 나열되어 있습니다.
Method | Description | Try it |
---|---|---|
.popover(options) | Activates the popover with an option. See options above for valid values | |
.popover("show") | Shows the popover | |
.popover("hide") | Hides the popover | |
.popover("toggle") | Toggles the popover | |
.popover("destroy") | Hides and destroys the popover |
팝오버 이벤트
다음 표에는 사용 가능한 모든 팝오버 이벤트가 나열되어 있습니다.
Event | Description | Try it |
---|---|---|
show.bs.popover | Occurs when the popover is about to be shown | |
shown.bs.popover | Occurs when the popover is fully shown (after CSS transitions have completed) | |
hide.bs.popover | Occurs when the popover is about to be hidden | |
hidden.bs.popover | Occurs when the popover is fully hidden (after CSS transitions have completed) |
더 많은 예
맞춤형 팝오버 디자인
CSS를 사용하여 팝오버의 모양을 사용자 정의합니다.
예시
/* Popover */
.popover {
border: 2px dotted red;
}
/* Popover Header */
.popover-title {
background-color: #73AD21;
color: #FFFFFF;
font-size: 28px;
text-align:center;
}
/* Popover Body */
.popover-content {
background-color: coral;
color: #FFFFFF;
padding: 25px;
}
/* Popover Arrow */
.arrow {
border-right-color: red !important;
}