CSS & Bootstrap: simple application of tooltips, css tutorial
1.
For a common Element, first add an atip class in the class and add the corresponding value.
Data-toggle unchangeable data-placement can be set to top | bottom | left | right | auto. title is not empty, the title is displayed; otherwise, the data-original-title is displayed.
2. Of course, the most basic files must be imported.
Then write a JS script.
Trigger: How tooltip is triggered-click | hover | focus | manual. For other attributes, refer to the corresponding API
Name |
Type |
Default |
Description |
Animation |
Boolean |
True |
Apply a CSS fade transition to the tooltip |
Container |
String | false |
False |
Appends the tooltip to a specific element. Example:container: 'body' . This option is special useful in that it allows you to position the tooltip in the flow of the document near the triggering element-which will prevent the tooltip from floating away from the triggering element during a window resize. |
Delay |
Number | object |
0 |
Delay showing and hiding the tooltip (MS)-does not apply to manual trigger type If a number is supplied, delay is applied to both hide/show Object structure is:delay: { "show": 500, "hide": 100 } |
Html |
Boolean |
False |
Insert HTML into the tooltip. If false, jQuery'stext Method will be used to insert content into the DOM. Use text if you're worried about XSS attacks. |
Placement |
String | function |
'Top' |
How to position the tooltip-top | bottom | left | right | auto. When "auto" is specified, it will dynamically reorient the tooltip. for example, if placement is "auto left", the tooltip will display to the left when possible, otherwise it will display right. When a function is used to determine the placement, it is called with the tooltip DOM node as its first argument and the triggering element DOM node as its second.this Context is set to the tooltip instance. |
Selector |
String |
False |
If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have tooltips added. Seethisandan informative example. |
Template |
String |
'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' |
Base HTML to use when creating the tooltip. The tooltip'stitle Will be injected into.tooltip-inner . .tooltip-arrow Will become the tooltip's arrow.
The outermost wrapper element shoshould have.tooltip Class. |
Title |
String | function |
'' |
Default title value iftitle Attribute isn't present. If a function is given, it will be called with itsthis Reference set to the element that the tooltip is attached. |
Trigger |
String |
'Hover focal s' |
How tooltip is triggered-click | hover | focus | manual. You may pass multiple triggers; separate them with a space. |
Viewport |
String | object |
{Selector: 'body', padding: 0} |
Keeps the tooltip within the bounds of this element. Example:viewport: '#viewport' Or{ "selector": "#viewport", "padding": 0 }
|
How to Create a CSS style sheet
Use CSS on a webpage:
I. Internal Rules-style that is written directly inside the webpage File
1. Insert the following code between <HEAD> and </HEAD> to set the default style of this page.
<Style type = "text/css">
<! --
Body {color = red; font-size = 9pt}
-->
</Style>
2. Add style rules to HTML rows
For example:
<P style = "background: yellow; font-family: courier"> Amaze your friends! </P>
Ii. External rules-independent style sheet files
1. link the style sheet File
Method: Use the <LINK> label in <HEAD>:
For example: <link rel = stylesheet HREF = "mystyles.css" TYPE = "text/css">
Create a file named mystyles.css (corresponding to the above ). The file content is as follows:
H1 {color: green; font-family: impact}
P {background: yellow; font-family: courier}
2. input the style sheet file (return)
Method: insert the column code in <HEAD>:
<Style type = "text/css">
<! --
@ Import url(company.css );
H1 {color: orange; font-family: impact}
-->
</STYLE>
Create a file named company.css (corresponding to the above ). The file content is as follows:
H1 {color: green; font-family: impact}
P {background: yellow; font-family: courier}
The advantage of this method is that it can coexist with the internal style of the webpage.
Iii. Examples of CSS
Specify the text format of the full text:
Body {background: yellow; color = red; font-size = 9pt}
Specify the local default text format:
P {...}
H1 {...}
TH {...}
TD {...}
...
Specify the hyperlink style:
A: link {text-decoration: none; color: # 0000FF; font-family:}
A: visited {text-decoration: none; color: #800000; font-family:}
A: active {text-decoration: none; color: # FF0. ...... the remaining full text >>>
How to Create a CSS style sheet
Use CSS on a webpage:
I. Internal Rules-style that is written directly inside the webpage File
1. Insert the following code between <HEAD> and </HEAD> to set the default style of this page.
<Style type = "text/css">
<! --
Body {color = red; font-size = 9pt}
-->
</Style>
2. Add style rules to HTML rows
For example:
<P style = "background: yellow; font-family: courier"> Amaze your friends! </P>
Ii. External rules-independent style sheet files
1. link the style sheet File
Method: Use the <LINK> label in <HEAD>:
For example: <link rel = stylesheet HREF = "mystyles.css" TYPE = "text/css">
Create a file named mystyles.css (corresponding to the above ). The file content is as follows:
H1 {color: green; font-family: impact}
P {background: yellow; font-family: courier}
2. input the style sheet file (return)
Method: insert the column code in <HEAD>:
<Style type = "text/css">
<! --
@ Import url(company.css );
H1 {color: orange; font-family: impact}
-->
</STYLE>
Create a file named company.css (corresponding to the above ). The file content is as follows:
H1 {color: green; font-family: impact}
P {background: yellow; font-family: courier}
The advantage of this method is that it can coexist with the internal style of the webpage.
Iii. Examples of CSS
Specify the text format of the full text:
Body {background: yellow; color = red; font-size = 9pt}
Specify the local default text format:
P {...}
H1 {...}
TH {...}
TD {...}
...
Specify the hyperlink style:
A: link {text-decoration: none; color: # 0000FF; font-family:}
A: visited {text-decoration: none; color: #800000; font-family:}
A: active {text-decoration: none; color: # FF0. ...... the remaining full text >>>