码迷,mamicode.com
首页 > Web开发 > 详细

用CSS来画空心三角形的方法

时间:2018-11-29 20:02:03      阅读:756      评论:0      收藏:0      [点我收藏+]

标签:otto   pos   像素   menu   idt   ...   play   label   tor   

画这里三角形的方法:

技术分享图片

用CSS来实现:整个弹框的ID是#favoriteOptionMenus,对于#favoriteOptionMenus这个元素设置:before和:after的样式,让:before和:after的样式偏移一个像素,就可以实现了

Html代码为:

<div id="favoriteOptionMenus" class="toolmenu">
          <ul class="saveFilterWrap">
            <li class="saveFilter">
              <div class="form-group row">
                <div class="col-xs-3 col-custom" id="saveSearchLabel"><label for="newFavoriteName">Save Search: </label></div>
                <div class="col-xs-6 col-custom"><input class="form-control" id="newFavoriteName" maxlength="100" placeholder="Type filter name..."></div>
                <div class="col-xs-3 col-custom" id="saveFilterButton">
                  <button id="btnSaveFavorite" class="btn btn-primary" style="margin-right: 10px;">
                    <span class="txt">Save</span>
                  </button>
                </div>
              </div>
            </li>
            <li class="separator"></li>
          </ul>
          <div class="form-group">
            <label for="searchFilter">Saved Searches:</label><br />
            <input class="form-control toolmenu" id="searchFilter" placeholder="Filter">
          </div>
          <ul class="toolmenu"></ul>
        </div>

对应实现三角形的CSS代码为:

#favoriteOptionMenus {
  padding: 15px 10px;
  width: 450px;
}
#favoriteOptionMenus:before {
  box-sizing: content-box;
  width: 0px;
  height: 0px;
  position: absolute;
  top: -24px;
  left: 89px;
  padding: 0;
  border-bottom: 12px solid #FFFFFF;
  border-top: 12px solid transparent;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  display: block;
  content: ‘‘;
  z-index: 12;
}
#favoriteOptionMenus:after {
  box-sizing: content-box;
  width: 0px;
  height: 0px;
  position: absolute;
  top: -26px;
  left: 88px;
  padding: 0;
  border-bottom: 13px solid #9c9999;
  border-top: 13px solid transparent;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  display: block;
  content: ‘‘;
  z-index: 10;
}

 

用CSS来画空心三角形的方法

标签:otto   pos   像素   menu   idt   ...   play   label   tor   

原文地址:https://www.cnblogs.com/fuhuirong/p/10040041.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!