


.daohang a{ display:inline-block; margin-top:6px;}/*为什么更改img的上边距时,链接a也会跟着下移?*/.daohang img{ width:21px; height:21px; margin-top:7px;}
<div class="daohang"> <a href="url>首页</a> <img src="/static/imghwm/default1.png" data-src="../image/line.png" class="lazy" / alt="<a inline-block>和<img>在一行,为什么改变img的margin-top,a的位置也变了?_html/css_WEB-ITnose" >
这个模型应该可以看做一个大的div里面包含了两个小的div吧,他们应该是相互独立的呀,为什么改变img的margin会使链接a也下移呢?
我试了试审查元素,发现a的外边距并没有顶格到div上,而img是有的,这又是为什么?
回复讨论(解决方案)
请将img放在a标签中。。。
你的HTML代码呢。。。。
HTML+CSS 怎么排版也是门学问的
HTML贴粗来 可以的话贴个图之类的
估計與垂直對齊有關…
inline-block影响的吧
解决这个,可以使用float代替display,再使用margin 互相不会有影响

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 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

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

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 <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

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


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

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

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

Zend Studio 13.0.1
Powerful PHP integrated development environment

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),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
