起因是刷知乎时碰到这么个问题:https://www.zhihu.com/question/41400503
问题代码如下:
<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><style> .cf { zoom: 1; } .cf:after { clear: both; content: ""; display: block; } .cf:before { content: ""; display: block; } .out { width: 730px; border: 1px solid #ccc; } .left { float: left; width: 90px; height: 20px; margin: 3px 5px; background: #D7E9F7; } .other { width: 10px; background: red; }</style></head><body> <div class="out cf"> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left"></div> <div class="left other"></div> </div></body></html>
在chrome中,最后一个.other会float到第一行的末尾:
最开始认为是before伪类的问题:
给出的解决方案是让提问者删掉.cf的before伪类,然后.other正常float到第二行最后。
后来细细想了下,没有听说过类似的问题,搜了下也没有发现类似案例,怀疑问题判断有误。copy提问者代码到sublime里面进行排错测试,习惯性把css代码compact,.other居然正常float。
恰巧前几天见过一个不可见字符导致页面显示错误的问题,灵光一闪地往这方面怀疑起来,设置sublime显示空白:"draw_white_space": "all"。果然有问题:
改用UltraEdit的16进制视图打开:
在display前面有两个编码为e38080的不可见字符,查编码对照表:
最近状态不佳,一直无所事事打酱油,碰到个问题不断往深处探究,感觉真是比打DOTA还爽!!!
UltraEdit

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

How to design the dotted line segmentation effect in the menu? When designing menus, it is usually not difficult to align left and right between the dish name and price, but how about the dotted line or point in the middle...

HTML Element Analysis in Web Code Editor Many online code editors allow users to enter HTML, CSS, and JavaScript code. Recently, someone proposed...

About how to avoid code compression when building static pages using react-app-rewired Many developers want to deliver to...


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

Dreamweaver CS6
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment