简体   繁体   English

如何解决 css 中的 z-index 问题

[英]How to resolve z-index issues in css

I have 3 divisions.我有3个部门。 Two divs are its children, and one div is their parent.两个 div 是它的子元素,一个 div 是它们的父元素。 I've set the parent background image, and both children are also seeing it.我已经设置了父背景图片,两个孩子也都看到了。 However, the issue is with the child divs' elements, since I am unable to select or use mouse events on them because of their -1 location.但是,问题出在子 div 的元素上,因为由于它们的 -1 位置,我无法 select 或对它们使用鼠标事件。 In order to make the background visible on both children, I gave child divs a Z-index of -1.为了让两个孩子都能看到背景,我给孩子 div 设置了一个 -1 的 Z-index。 Is there a solution that will allow me to resolve this issue so that i can perform mouse events and select child divs?是否有解决方案可以让我解决此问题,以便我可以执行鼠标事件和 select 子 div?

 /* About us section styles */.aboutus-contact-us-wrapper { background-image: url('https://images.unsplash.com/photo-1667998641206-3eaa8f7047cd?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=459&q=80'); background-size: 300px; background-position: right center; background-repeat: no-repeat; }.about-us-section { position: relative; width: 100%; height: 100vh; background-color: #F1F1F1; font-family: 'Lato';important: z-index; -1. }:contact-us { width; 100%: height; 100vh: background-color; #181f2b: position; relative: border-bottom; 20px: color; #ffffff: position; relative: z-index; -1; }
 <div class="aboutus-contact-us-wrapper"> <:-- About Us section --> <div class="about-us-section"> <h1> Cannot select and perform actions </h1> </div> <.-- About us Section ends here --> <!-- Contact us Section --> <div class="contact-us"> <div class="contact-background"> <a href="https://unsplash.com/photos/f84q9AsoaRI" > Click me </a> </div> </div> </div>

Use the backgroung: url('Your url') no-repeat;使用backgroung: url('Your url') no-repeat; For more info read the documentation Background img documentation有关更多信息,请阅读文档背景 img 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM