好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

css怎么实现对话框

css实现 对话 框的方法:首先创建一个HT ML 示例文件;然后让父元素相对定位;接着用css的 伪类 before或after写个三角形;最后通过设置css样式实现对话框即可。

本文操作环境:windows7系统、HTML5 && CSS3版、Dell G3 电 脑。

纯cs S写 带小三角对话框

在实际样式中经常会遇到要写类似对话框的样式,而这种样式往往会有一个小三角,如下所示:

示例图片

那么如何用css写出来呢,其实很 简单 ,先让父元素相对定位,然后运用css的伪类before或after。就可以写个三角形,如果想要带边框的三角形,则可以两个重叠使用。代码如下:

<p class="box2">
    纯css写带小三角对话框
</p>
.box2{  
    float:left;  
    pos IT ion:relative;  
    width:200px;  
    h ei ght:100px;  
    border:1px solid  # 00f;  
    m arg in:50px;  
    box -s izing:border-box;  
    font- Size: 14px;  
    padding:10px;  
    box-shadow:0 0 2px rgba(0,0,0,.5)  
}  
.box2:before,
.box2 :after {  
    position:absolute;  
    content:'';
    border:10px solid;
}  
.box2:before{  
    right: -20px;
    top:20px;
    border-color: transparent transparent transparent #00f;
}  
.box2:after{  
    border-color: transparent transparent transparent #fff;
    right: -18px;
    top: 20px;
}

推荐学习:css视频教程

以上就是css怎么实现对话框的详细内容,更多请关注其它相关 文章 !

总结

以上是 为你收集整理的 css怎么实现对话框 全部内容,希望文章能够帮你解决 css怎么实现对话框 所遇到的问题。

如果觉得 网站内容还不错, 推荐好友。

查看更多关于css怎么实现对话框的详细内容...

  阅读:34次