html - 分区 :before/after interfering with other divs?

标签 html css

我正在使用 CSS :before 和 :after 将虚线视觉元素添加到 div:

enter image description here

但它似乎干扰了“编辑”按钮元素。 (当父 div 的 :before 和 :after CSS 存在时,编辑按钮不会响应任何 onClick 或 MouseOver 或 Hover 事件)关于如何在 :before 和 :after 元素“前面”呈现按钮元素的任何想法,除了 Z-index?

CSS:

.window_header{
    width:600px;
    height:42px;
    background: #333 url("../img/bg-2.png") repeat;
    -webkit-border-top-left-radius: 8px;
    -webkit-border-top-right-radius: 8px;
    border-bottom:1px dotted #666;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3),inset 0 -4px 5px rgba(0, 0, 0, 0.2),inset 1px 0px 1px rgba(0, 0, 0, 0.7),inset -1px 0px 1px rgba(0, 0, 0, 0.7),inset 0 -2px 1px rgba(0, 0, 0, 0.5),inset 0 2px 6px rgba(255, 255, 255, 0.15),inset -2px 0 6px rgba(255, 255, 255, 0.15),inset 2px 0 6px rgba(255, 255, 255, 0.15);
}

.window_header:before,
.window_header:after{
    content: "";
    position: absolute;
    top: 0;
    right: 0px;
    bottom: 562px;
    left: 0px;
    z-index:1;
    border-bottom: 1px dashed #666;
    background:-webkit-gradient(radial, center center, 0, center center, 260, from(rgba(255, 255, 255, 0.05)), to(rgba(255, 255, 255, 0)));
}

.button_edit{
    margin: 8px 8px 8px 8px;
    border-radius:6px;
    width:70px;
    font-size: 9pt;
    font-weight:bold;
    cursor:pointer;
    font-family: Helvetica, sans-serif;
    text-shadow: 0px -1px 1px rgba(0,0,0,0.5);
    border: 1px solid rgba(0, 0, 0, 0.5);
    border-top-color: rgba(0, 0, 0, 0.496094);
    -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2),0 -1px 1px rgba(0, 0, 0, 0.3);
    z-index:100;
}

.fl_right{
    float:right;
}

HTML:

<div class="window_header">
    <div class="button_edit fl_right" id="button_edit_site"> Edit </div>
</div>

最佳答案

我想你忘了添加 position: relative.button_editz-index 需要 relative/absolute 才能工作:

http://jsfiddle.net/CB2BE/1/

.button_edit{
    position: relative;
    z-index:100;
}

关于html - 分区 :before/after interfering with other divs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11194492/

相关文章:

css - Ruby on Rails,连接后 css 中的 url() 损坏

javascript - 响应式过滤图库 P

javascript - Bootstrap 4 中的输入大小小于 "form-control-sm",例如xs?

html - Amazon S3 图像,无法使用 html5 Canvas 保存,出现 Tainted Canvases 错误

html - 表设计 - 内表?

javascript - 更新Jquery中li的标题属性

javascript - 如何在angularjs中创建搜索过滤器和文本突出显示

javascript - Express js apps.local 变量和 View 输出

javascript - 如何让 DOM/事件监听器知道新附加的节点?

html - 仅将背景颜色应用于左侧和右侧;排除中间