HTML页面设计 网页布局
<body><form id="form1" ><div><ul style="width: 100%"><li style="width: 40%">abc</li><li style="width: 40%">def</li><li style="width: 20%">ghi</li></ul></div></form><body>
我的想法是让这三个列表项处在同一行,可是三个列表项并不在同一水平行。含有ghi的那个
我后来设置了所有元素的border,padding,margin为none或者0,但结果还是开始一样显示的。
我就是搞不明白,三个
- 的width。我试了把最后一个
- 标签的width改为19%,然后三个
- 就是并列显示了。(注:我已经设置了
- 的float为left了)。
大家能给我指点一下吗? 谢谢了!
回复讨论(解决方案)
li是块级元素,是会自动往下排的,而不像p,img这类行级元素会直接连在后面,style里加上float:left; 这个属性就可以了,会变成漂浮元素进行漂浮排列,最后最好在所有
- 后再加上一行清除漂浮,以免影响接下来的布局
li是块级元素,是会自动往下排的,而不像p,img这类行级元素会直接连在后面,style里加上float:left; 这个属性就可以了,会变成漂浮元素进行漂浮排列,最后最好在所有
- 后再加上一行清除漂浮,以免影响接下来的布局
不好意思,没有注意到最后你已经漂浮了,既然是19%有问题,估计是哪个margin或者padding出问题,可能没检查出来,试试在样式里面加上一句 *{margin:0;padding:0} 呢假设ul在实际显示的时候宽度是789px,那么3个li标签的宽度分别是315.6px 315.6px 157.8px,应该是这个问题吧
一些老版本的浏览器不会认识float类型的宽度,造成了误差。一般在写代码时,就要考虑padding和magin的默认属性。

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


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

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

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

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
