Using :before CSS pseudo element to add image to modal

后端 未结 4 1646
不思量自难忘°
不思量自难忘° 2020-12-12 23:11

I have a CSS class Modal which is absolutely positioned, z-indexed above it\'s parent, and nicely positioned with JQuery. I want to add a caret image (^) to th

4条回答
  •  执笔经年
    2020-12-12 23:45

    http://caniuse.com/#search=:after

    :after and :before with content are okay to use as they're supported in every major browser other than Internet Explorer at least 5 versions back. Internet Explorer has complete support in version 9+ and partial support in version 8.

    Is this what you're looking for?

    .Modal:after{
      content:url('blackCarrot.png'); /* with class ModalCarrot ??*/
      position:relative; /*or absolute*/
      z-index:100000; /*a number that's more than the modal box*/
      left:-50px;
      top:10px;
    }
    
    .ModalCarrot{
       position:absolute;
       left:50%;
       margin-left:-8px;
       top:-16px;
    }
    

    If not, can you explain a little better?

    or you could use jQuery, like Joshua said:

    $(".Modal").before("");

提交回复
热议问题