美文网首页
仿bootstrap hover 提示字符

仿bootstrap hover 提示字符

作者: 子母粉丝 | 来源:发表于2017-09-30 10:25 被阅读99次
1506737197152.gif

要实现的效果大概就是这样----

思路:对target 设置自data-msg 自定义属性
利用伪元素 content: attr(data-msg) 拿到内容
接下来就是针对伪元素进行定位以及修饰了,这里用到::before 作为箭头;

首先设置一个div,data-msg是悬停的内容
<div class="inner" data-msg = "这是悬停的效果">测试内容</div>

如下是样式:

.inner {
position: relative;
width:300px;
background: #39f;
}
/* 主要内容/
.inner:hover::after {
position: absolute;
content: attr(data-msg);
top: 35px;
left:-6px;
font-size: 20px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: #000;
color: #ffffff;
}
/
箭头*/
.inner:hover::before {
position: absolute;
top:21px;
left:0;
content: '';
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-top:7px solid transparent;
border-bottom: 7px solid black;
}

相关文章

  • 仿bootstrap hover 提示字符

    要实现的效果大概就是这样---- 思路:对target 设置自data-msg 自定义属性利用伪元素 conte...

  • Cypress 里的 Flaky test 管理

    鼠标 hover 上去,看到提示信息:This test both passed and failed when ...

  • W2

    bootstrap: 用bootstrap进行网页的修饰,源码如下: 效果如图: JavaScript 字符串 字...

  • bootstrap提示信息

    div标签:-alert类:为提示信息添加样式-alert-info类:为提示信息添加样式,类似的还有alert-...

  • Bootstrap 如何实现导航栏菜单文字居中

    问题来源: 今天用Bootstrap练习仿站时,发现目标站导航栏的菜单是居中排版方式,而Bootstrap貌似没有...

  • bootstrap 插件集

    bootstrap-growl bootstrap-notify 这两个是简单易用的提示框插件,实现右上角弹窗

  • appium踩坑记(MAC)

    问题1:运行提示error:Error: Android bootstrap socket crashed: Er...

  • Bootstrap

    Bootstrap的导航条下拉菜单为了适应移动设备没有鼠标hover的状态,都是点击弹出下拉菜单,为了适应一般网站...

  • CocoaPods 使用

    升级ruby 环境 因为准备在项目中使用bootstrap,在安装bootstrap过程中提示需要Ruby的版本在...

  • bootstrap dropdown事件由click成hover

    第一次接触到dropdown是在现成的网站模板中,感觉挺好用的,不需要自己去修改任何代码了。很快项目需要,要把菜单...

网友评论

      本文标题:仿bootstrap hover 提示字符

      本文链接:https://www.haomeiwen.com/subject/mvjgextx.html