html - div : believe it to be due to the svg background 内的按钮不可点击

标签 html css button svg clickable

我有两个按钮放置在几层 div 中。将按钮放在 div 外部可以使它们变得可点击,但在内部则不能。经过一些测试后,它似乎是阻止可点击按钮的“背景”div,可能是由于 svg 被用作按钮后面的背景?我曾尝试将 z index 与 position:absolute 一起使用,但没有成功。同时使按钮 visibility:visible

    .background {
    background-image: url(images/background.svg);
    background-size: cover;
    width: 100%;
    height: 100vh;
    position: relative;
    top:-76px;
    z-index: -1;

}

    .left-header {
    position: relative;
    top: 40vh;
    
}


    .btn-primary {
    margin-top: 30px;
    text-transform: uppercase; 
    font-family: Roboto;
    font-weight: 500;
    font-size: 15px;
    margin-right: 20px;
    transition: all 0.3s ease 0s;
    outline: none;    
    border-radius: 4px;
    display: inline-block;
    letter-spacing: .025em;
    line-height: 25px;
    cursor: pointer !important;
    

}
<div class="background">
            <div class="container left-header">
                <div class="row">
                    <div class="col">
                            <h1>hello.</h1>
                            <h2>some text</h2>
                            <button type="button" href="#!" class="btn btn-primary shadow"  id="but1">Create Account</button>
                            <button type="button" class="btn btn-primary shadow" id="but2">Contact Us</button>                  
                    </div>
                    <div class="col">
                        <div class="illustration"><img src="images/illustration.svg"></div>        
                    </div>
                </div>              
            </div>      
        </div>

.

最佳答案

我的猜测是您的背景上的 pointer-events: none 导致了问题。您可以尝试将 pointer-events: all 添加到类 btn-primary 吗?

关于html - div : believe it to be due to the svg background 内的按钮不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52411228/

相关文章:

javascript - 单击链接时如何显示ul?

javascript - 如何调整来自不同 HTML 元素的背景图像的堆叠顺序/z-index

html - 防止 'jumpy' 带有提示(适合网格)文本的元素上的 CSS 转换

android - 如何向我的 android 应用程序添加一个按钮而不是像 facebook 页面一样?

javascript - 将 TabIndex 添加到由 JavaScript 构建的按钮

html - 如何使用适合页面的图像创建着陆 div,并有可能滚动到其他内容

html - 使用 cssResource 设计 gwt 超链接

javascript - 播放和暂停按钮如何使用 javascript 在游戏中工作?

html - CSS-HTML : Inline box expands larger than expected?

ionic-framework - 如何覆盖 Ionic 3 中的硬件后退按钮操作?