怎么實(shí)現(xiàn)簡(jiǎn)單的Tooltip提示框? - wordpress開(kāi)發(fā)

    如果直接在文本中寫(xiě)就介紹的話,就很容易打亂文本整體的連貫性,這一節(jié)的wordpress開(kāi)發(fā)就教大家如何實(shí)現(xiàn)簡(jiǎn)單的Tooltip提示框

    在編輯大量專(zhuān)業(yè)的知識(shí)時(shí)我們往往需要對(duì)一些比較生僻的詞匯進(jìn)行解釋或是對(duì)一些引用內(nèi)容進(jìn)行介紹,如果直接在文本中寫(xiě)就的話,就很容易打亂文本整體的連貫性,這一節(jié)的wordpress開(kāi)發(fā)就教大家如何實(shí)現(xiàn)簡(jiǎn)單的Tooltip提示框。

    怎么實(shí)現(xiàn)簡(jiǎn)單的Tooltip提示框? - wordpress開(kāi)發(fā)
    背景圖片

    效果如下:

    在 WordPress 的文章編輯器?登鸛雀樓里面只要輸入?白日依山盡,黃河入海流。欲窮千里目,更上一層樓。如下格式的短代碼

    [tooltip tip="提示內(nèi)容"]

    代碼部署:

    在主題根目錄下的 functions.php 文件中的<?php下面添加以下代碼:

    // [tooltip tip=""]
    add_shortcode('tooltip', 'shortcode_tooltip');
    function shortcode_tooltip($attrs, $content = null) {
    	$return = '';
    	extract(shortcode_atts(array(
    		'tip' => "",
    	), $attrs));
    		ob_start(); ?>
    		<span class="tooltip"><span class="tooltip-icon">?</span><span class="tip-content"><span class="tip-content-inner"><?php echo $tip; ?></span></span></span>
    		<?php
    		$return = ob_get_clean();
    	return $return;
    }

    在主題根目錄下的style.css底部添加以下樣式代碼:

    .tooltip{
    	position: relative;
    	display: inline-block;
    	margin-left: 5px;
    	margin-right: 5px;
    	height: 16px;
    	line-height: 16px;
    	vertical-align: middle;
    }
    .tooltip-icon{
    	display: block;
    	width: 14px;
    	height: 14px;
    	line-height: 14px;
    	border: 1px solid #999;
    	border-radius: 50%;
    	font-size: 12px;
    	font-weight: 700;
    	font-family: "caption", Arial;
    	text-align: center;
    }
    .tip-content{
    	z-index: 999999;
    	display: none;
    	position: absolute;
    	left: -5px;
    	bottom: 30px;
    	width: 240px;
    }
    .tip-content-inner{
    	position: absolute;
    	bottom: 0;
    	left: 0;
    	display: block;
    	width: auto;
    	max-width: 200px;
    	padding: 10px;
    	line-height: 20px;
    	border: 1px solid #ccc;
    	background: #fff;
    	line-height: 20px;
    	color: #333;
    	font-size: 16px;
    }
    .tip-content-inner:before{
    	content: "";
    	position: absolute;
    	left: 7px;
    	bottom: -24px;
    	border-style: solid solid solid solid;
    	border-color: #ccc transparent transparent transparent;
    	border-width: 12px 6px;
    }
    .tip-content-inner:after{
    	content: "";
    	position: absolute;
    	left: 8px;
    	bottom: -20px;
    	border-style: solid solid solid solid;
    	border-color: #fff transparent transparent transparent;
    	border-width: 10px 5px;
    }
    .tooltip:hover > .tip-content{
    	display: block;
    }

    使用:

    在文章編輯器里面只要輸入如下格式的短代碼:

    [tooltip tip=”提示內(nèi)容”]

    提示:

    – PS0: 那個(gè)圓圈是用 css3 實(shí)現(xiàn)的,所以 IE8 下面會(huì)變成方框……需要支持 IE8 的朋友自己改成背景圖方式吧。
    – PS1: tip 內(nèi)容用了 2 個(gè)容器的目的是為了讓 tip 內(nèi)容顯示能 width:auto 效果,也就是說(shuō) .tip-content 的 width 起到 max-width 效果,然后 .tip-content-inner 就有了類(lèi)似 max-width 的屬性效果了

    相關(guān):

    怎么實(shí)現(xiàn)簡(jiǎn)單的Tooltip提示框? - wordpress開(kāi)發(fā)-Npcink
    怎么實(shí)現(xiàn)簡(jiǎn)單的Tooltip提示框? - wordpress開(kāi)發(fā)-Npcink

    怎么添加Tooltip提示框? - css筆記

    擴(kuò)展:

    如果你擔(dān)心自己的原創(chuàng)內(nèi)容被被輕易的復(fù)制,那么在被人復(fù)制時(shí)加一個(gè)提示會(huì)是一個(gè)不錯(cuò)的選擇,參考這一篇wordpres開(kāi)發(fā)教程來(lái)增添這一小功能吧。

    怎么實(shí)現(xiàn)簡(jiǎn)單的Tooltip提示框? - wordpress開(kāi)發(fā)-Npcink
    怎么實(shí)現(xiàn)簡(jiǎn)單的Tooltip提示框? - wordpress開(kāi)發(fā)-Npcink

    怎么在復(fù)制文字時(shí)展示提示框? - WordPress教程

    國(guó)內(nèi)主題

    計(jì)算姬 - 仿桌面的WordPress博客主題

    2020-8-8 12:22:49

    國(guó)內(nèi)主題

    Acuity- 適用于圖片站、資訊站、娛樂(lè)站的WordPress主題

    2019-12-3 9:22:02

    ??
    Npcink上的部份代碼及教程來(lái)源于互聯(lián)網(wǎng),僅供網(wǎng)友學(xué)習(xí)交流,若您喜歡本文可附上原文鏈接隨意轉(zhuǎn)載。
    無(wú)意侵害您的權(quán)益,請(qǐng)發(fā)送郵件至 1355471563#qq.com 或點(diǎn)擊右側(cè) 私信:Muze 反饋,我們將盡快處理。
    0 條回復(fù) A文章作者 M管理員
      暫無(wú)討論,說(shuō)說(shuō)你的看法吧
    ?
    個(gè)人中心
    購(gòu)物車(chē)
    優(yōu)惠劵
    今日簽到
    有新私信 私信列表
    搜索
    主站蜘蛛池模板: 亚洲AV无码一区二区三区牛牛| 卡通动漫中文字幕第一区| 日韩一区二区三区视频久久| 国产av一区最新精品| 天堂一区人妻无码| 国产在线精品一区二区| 性色av闺蜜一区二区三区| 韩国一区二区三区| 色精品一区二区三区| 日本不卡一区二区三区视频| 久久久久久免费一区二区三区| 无码精品国产一区二区三区免费| 国产乱码一区二区三区四| 九九无码人妻一区二区三区 | 精品伦精品一区二区三区视频 | 无码一区二区三区亚洲人妻| 一区二区高清在线| 久久se精品一区二区| 在线观看一区二区三区av| 日韩精品无码久久一区二区三| 亚洲一区二区三区在线观看精品中文| 国产午夜精品一区理论片飘花| 性无码免费一区二区三区在线| 国产精品美女一区二区三区| 一区二区三区视频免费观看 | 国产成人一区二区三中文| 国产精品久久久久久一区二区三区 | 一区二区三区影院| 中文字幕一区二区精品区| 日本精品3d动漫一区二区| 国产一区二区三区久久| 怡红院美国分院一区二区| 亚洲色欲一区二区三区在线观看| 无码成人一区二区| 日韩十八禁一区二区久久| 麻豆国产一区二区在线观看| 日韩A无码AV一区二区三区| 精品欧洲av无码一区二区三区| 久久精品人妻一区二区三区| 亚洲性无码一区二区三区| 精品人妻少妇一区二区三区在线|