Home Web Front-end CSS Tutorial Hierarchy (z-index) problems caused by negative margin values

Hierarchy (z-index) problems caused by negative margin values

May 21, 2017 am 10:50 AM
margin z-index Hierarchy

This article mainly introduces the solution to the hierarchical (z-index) problem caused by negative margin values. Friends in need can refer to it. Let’s look at this piece of code first:


Copy code

The code is as follows :




Script Home



##Under IE6 and IE7, the inner layer The container is covered by the outer layer, as shown in the picture:

Under IE8 and ff, the outer container is covered by the inner layer, as shown in the picture:

Really Crazy, if you want to achieve the effect of IE8's outer container being covered by the inner layer, IE7 can solve the problem by triggering the inner layer's layout, but IE6 can't. You can only use position:relative in the inner layer to solve the problem. Of course, position :relative also solves the problem of ie7, because position:relative itself can trigger layout.
Look at the code:



Copy the code

The code is as follows:



Script Home




##Of course If you want IE8 and FF to achieve the effect of IE6 and IE7, you only need to add overflow:hidden in the outer layer. See the code





# #Copy code

The code is as follows:

< a href="http://www.jb51.net/" mce_href="http://www.jb51.net/">Script Home




The above is the detailed content of Hierarchy (z-index) problems caused by negative margin values. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of CSS border properties: padding, margin and border Detailed explanation of CSS border properties: padding, margin and border Oct 21, 2023 am 11:07 AM

CSS border properties explained in detail: padding, margin and borderCSS is a style sheet language used to control and layout web page elements. In web design, the border attribute is one of the most important parts. This article will introduce in detail how to use the border attribute in CSS and provide specific code examples. padding The padding property is used to set the padding of an element, which is the space between the element's content and the element's borders. We can set padding using positive numbers or percentage values

Easy way: remove z-index attribute with jQuery Easy way: remove z-index attribute with jQuery Feb 23, 2024 pm 05:18 PM

Using jQuery to remove the z-index attribute is a very simple operation. The following will demonstrate how to achieve this operation through specific code examples. First, we need to introduce the jQuery library into HTML, you can use the following CDN link: &

What does margin mean in css What does margin mean in css Dec 18, 2023 am 10:30 AM

In CSS, margin is a property used to set the outer margins of an element. Margins are the space between an element's border and its content. Margin can accept the following values: 1. A single value: for example, margin: 10px; Set all four margins (top, right, bottom, left) to 10 pixels; 2. Two values: for example, margin : 10px 20px; Set the top and bottom margins to 10 pixels, and the left and right margins to 20 pixels; 3, four values, and so on.

Interpretation of CSS cascading properties: z-index and position Interpretation of CSS cascading properties: z-index and position Oct 20, 2023 pm 07:19 PM

Interpretation of CSS cascading properties: z-index and position In CSS, the design of layout and style is very important. In design, it is often necessary to layer and position elements. Two important CSS properties, z-index and position, can help us achieve these needs. This article will dive into these two properties and provide specific code examples. 1. z-index attribute The z-index attribute is used to define the stacking order of elements in the vertical direction. Stacking of elements

What does z-index mean in css? What does z-index mean in css? Nov 20, 2020 pm 02:21 PM

In CSS, z-index means "level, layer space stacking level". You can specify the stacking order of an element, which is used to confirm the stacking level of the element in the current stacking context. Elements with a higher stacking order will always be In front of elements lower in the stacking order; syntax "element {z-index:auto|<integer>}".

Detailed explanation of CSS text layout properties: text-overflow and white-space Detailed explanation of CSS text layout properties: text-overflow and white-space Oct 20, 2023 am 11:19 AM

Detailed explanation of CSS text layout properties: text-overflow and white-space In web design, text layout is a very important link. Reasonable layout can make the text more readable and beautiful. CSS provides several properties to control how text is displayed, including text-overflow and white-space. This article will detail the usage and sample code of these two properties. 1. text-overflow attribute text

What does margin mean in html What does margin mean in html Sep 13, 2021 pm 04:26 PM

In HTML, margin means "margin", which refers to the blank area surrounding the border of an element; setting margins will create additional "blank" outside the element, allowing a "blank" distance between boxes. . To set margins, you need to use the css margin property, which accepts any length unit, percentage value, or even negative value.

Anatomy of the Java technology stack: Uncovering the mysteries of its various layers Anatomy of the Java technology stack: Uncovering the mysteries of its various layers Jan 10, 2024 am 08:53 AM

Analyzing the Java technology stack: Uncovering the mysteries of its various layers requires specific code examples. In recent years, Java technology has become increasingly widely used in the field of software development. As a cross-platform, object-oriented programming language, Java has become the first choice of many developers through its powerful functions and rich class libraries. However, it is not easy to deeply understand and master the Java technology stack. This article will analyze each level of the Java technology stack from the underlying JVM to the upper-level framework, and reveal the secrets behind it. First, let’s learn about Java

See all articles