div里嵌套了img底部会有白块问题和图片一像素问题解决_html/css_WEB-ITnose
div里嵌套了img底部会有白块
因为img默认是按基线(baseline)对齐的。对比一下图片和右边的p, q, y等字母,你会发现这三个字母的“小尾巴”和图片下方的空白一样高。下面这张图中的黑线就是那条基线。
解决方案:一:vertical-align: bottom(推荐)
解决方案:二:display:block;(不推荐)
不推荐原因:因为img在浏览器里的默认样式是inline,除非有特别的需要否则还是不改变盒模型为好,在这个问题中本质还是行内元素的纵向对齐问题,可以给img调整vertical-align来解决,本题中用bottom就行了
扩展:什么是基线?
基线就是我们小时候用的英语本中,中间的第三条线就是基线;
第一条线是:上升高度(帽高度)
第二条线是:中值高度
第四条线是:下降高度
解读:ascent 上升 mean line 平均线 descent 下降
html img 图片上方产生1像素px间隙解决
方案一:通过css对图片加一个浮动元素,比如.divcss5 img{ float:left}
方案二:将图片高度处理为单数(1、3、5、7单数),比如图片本身为200px高度,为了解决我们将图片PS处理成201px或199px高度。图片本身高度为202px双数在IE6和IE7浏览器中就会在图片上方产生多1px的空白距离。所以制作图片切图时候,让图片高度为单数(奇数)即可解决。

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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



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.

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.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

The necessity of registering VueRouter in the index.js file under the router folder When developing Vue applications, you often encounter problems with routing configuration. Special...
