css中bug记录_html/css_WEB-ITnose
1.margin塌陷,通俗叫法。
假如一个盒子box里边嵌套了两个盒子(记为box1,box2)。box1的margin-top不会如预想的一样在box顶部撑开一个边距,而是以包含box的容器上边界为基准撑开边距。
解决方法:一、设置box1 padding-top.
二、设置box display:absolute.
三、设置box overflow:hidden。
2.如图示:
此类问题代码为:box{width:500px ; height:50px;line-height:50px; text-align:center; border:1px solid #333;}
box span{display:inline-block; width:100px; height: 20px;}
出现此问题有如下几点:父级元素设置text-align:center;使得盒子内文字居中,此时若不设置 span 为inline-block; ,span会自动撑开;
若span设置为inline-block; ,其宽 度和高度的设置不影响文字位置。
解决方法为:一、父元素设置padding-top。
二、父元素仍设置居中,span 不设置内联块盒子,而设置其内边距,撑开所需要的宽度。
效果如下:
。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit
