search
HomeWeb Front-endHTML TutorialProblems with html and css_html/css_WEB-ITnose

本帖最后由 liulinisgood 于 2012-12-03 11:10:20 编辑

第一段代码
<div>   <ul style="list-style:none">      <li style="float:left;width:50px; height:50px; ">	     <img  src="/static/imghwm/default1.png"  data-src="qq.jpg"  class="lazy"   / alt="Problems with html and css_html/css_WEB-ITnose" >	  </li>	  <li   style="max-width:90%">	     <img  src="/static/imghwm/default1.png"  data-src="vs.jpg"  class="lazy"   / alt="Problems with html and css_html/css_WEB-ITnose" >	  </li>	  <li   style="max-width:90%">	    <img  src="/static/imghwm/default1.png"  data-src="eclipse.jpg"  class="lazy"   / alt="Problems with html and css_html/css_WEB-ITnose" >	  </li>   </ul></div>

效果图如下

第二段代码
<div>   <ul   style="max-width:90%">      <li style="float:left; ">	     <img  src="/static/imghwm/default1.png"  data-src="qq.jpg"  class="lazy"   / alt="Problems with html and css_html/css_WEB-ITnose" >	  </li>	  <li >	     <img  src="/static/imghwm/default1.png"  data-src="vs.jpg"  class="lazy"   / alt="Problems with html and css_html/css_WEB-ITnose" >	  </li>	  <li>	    <img  src="/static/imghwm/default1.png"  data-src="eclipse.jpg"  class="lazy"   / alt="Problems with html and css_html/css_WEB-ITnose" >	  </li>   </ul></div>

效果图如下

第三段代码
<div>   <ul   style="max-width:90%">      <li style="float:left;width:50px; height:50px; background-color:#009966; ">	     1	  </li>	  <li style="width:50px; height:50px; background-color:#339933; ">	     2	  </li>	  <li style="width:50px; height:50px; background-color:#666666; ">	    3	  </li>   </ul></div>

效果图如下

第四段代码

   

          

  •      1
      

  •   

  •      2
      

  •   

  •     3
      

  •    


效果图如下:
---------------------------------------------------------------------------------
提问:1.为什么不加宽度下一层的元素会和float:left的元素在一行。
      2.在第三个图的2和3数字会重叠在一起,为什么不像1图中直接覆盖。
大家可以具体解释每个图中的现象,第四个图中的数字2会被挤到数字1的右边。

回复讨论(解决方案)

同样问题,求分析

同样问题,求分析
没人回答。。。

前台修饰弄的比较少,css是个神奇的东西,有定位真心感觉难!

我是这样理解的:
       第一张图:ul,li都是块级元素,会独占一行,设置宽度以后,ul的宽度也是50px,float浮动属性虽然会影响下一个块级元素,但是因为两个li的宽度小于ul的宽度,所以显不出来;
       第二张图:宽度自适应,所以即不存在一图的问题;
       第三张图:这也是一个宽度不够的问题,这边之所以2和3重叠,其实是看浏览器的,估计你用的是firefox,浏览器之间显示是有差异的,在2的样式表里添加clear:left;就不会出现重叠问题了;
       第四张图:2不能说是被1挤到右边的,因为用了浮动属性,所以改变了2的块级元素,所以2合1显示在同一行,因为你的1设置了宽度,2当然从宽度后开始显示,怎么能叫挤呐。

同学求给分。

多做几个案例,总结一下。
这个问题都不是什么问题,很简单的。

出现这种问题,基本都是浮动,宽度的问题。

继续加油。

我是这样理解的:
       第一张图:ul,li都是块级元素,会独占一行,设置宽度以后,ul的宽度也是50px,float浮动属性虽然会影响下一个块级元素,但是因为两个li的宽度小于ul的宽度,所以显不出来;
       第二张图:宽度自适应,所以即不存在一图的问题;
       第三张图:这也是一个宽度不够的问题,这边之所以2和3重叠,其实是看浏览器的,估……
哥们说的挺好的,分会给的,浏览器ie,chrome,firefox其实都是一样的

多做几个案例,总结一下。
这个问题都不是什么问题,很简单的。

出现这种问题,基本都是浮动,宽度的问题。

继续加油。
3q

下面是一个简易选项卡的例子,涉及到你那种方式布局,可以参考一下

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><!-- saved from url=(0038)http://js.fgm.cc/learn/lesson2/07.html --><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>简易选项卡</title><style>body,ul,li{margin:0;padding:0;}body{font:12px/1.5 Tahoma;}#outer{width:450px;margin:10px auto;}#tab{overflow:hidden;zoom:1;background:#000;border:1px solid #000;}#tab li{float:left;color:#fff;height:30px;cursor:pointer;line-height:30px;list-style-type:none;padding:0 20px;}#tab li.current{color:#000;background:#ccc;}#content{border:1px solid #000;border-top-width:0;}#content ul{line-height:25px;display:none;margin:0 30px;padding:10px 0;}</style><script>window.onload = function (){	var oLi = document.getElementById("tab").getElementsByTagName("li");	var oUl = document.getElementById("content").getElementsByTagName("ul");		for(var i = 0; i < oLi.length; i++)	{		oLi[i].index = i;		oLi[i].onmouseover = function ()		{			for(var n = 0; n < oLi.length; n++) oLi[n].className="";			this.className = "current";			for(var n = 0; n < oUl.length; n++) oUl[n].style.display = "none";			oUl[this.index].style.display = "block"		}		}}</script></head><body><div id="outer">    <ul id="tab">        <li class="">第一课</li>        <li class="">第二课</li>        <li class="current">第三课</li>    </ul>    <div id="content">        <ul style="display: none; ">            <li>网页特效原理分析</li>            <li>响应用户操作</li>            <li>提示框效果</li>            <li>事件驱动</li>            <li>元素属性操作</li>            <li>动手编写第一个JS特效</li>            <li>引入函数</li>            <li>网页换肤效果</li>            <li>展开/收缩播放列表效果</li>        </ul>        <ul style="display: none; ">            <li>改变网页背景颜色</li>            <li>函数传参</li>            <li>高重用性函数的编写</li>            <li>126邮箱全选效果</li>            <li>循环及遍历操作</li>            <li>调试器的简单使用</li>            <li>典型循环的构成</li>            <li>for循环配合if判断</li>            <li>className的使用</li>            <li>innerHTML的使用</li>            <li>戛纳印象效果</li>            <li>数组</li>            <li>字符串连接</li>        </ul>        <ul style="display: block; ">            <li>JavaScript组成:ECMAScript、DOM、BOM,JavaScript兼容性来源</li>            <li>JavaScript出现的位置、优缺点</li>            <li>变量、类型、typeof、数据类型转换、变量作用域</li>            <li>闭包:什么是闭包、简单应用、闭包缺点</li>            <li>运算符:算术、赋值、关系、逻辑、其他运算符</li>            <li>程序流程控制:判断、循环、跳出</li>            <li>命名规范:命名规范及必要性、匈牙利命名法</li>            <li>函数详解:函数构成、调用、事件、传参数、可变参、返回值</li>            <li>定时器的使用:setInterval、setTimeout</li>            <li>定时器应用:站长站导航效果</li>            <li>定时器应用:自动播放的选项卡</li>            <li>定时器应用:数码时钟</li>            <li>程序调试方法</li>        </ul>    </div></div></body></html>

下面是一个简易选项卡的例子,涉及到你那种方式布局,可以参考一下
XML/HTML code?12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747……
非常感谢

我是沙发,本来看到有不少回复感到挺兴奋的,但是认真看了两遍后感觉失望,大家都没有清楚地正视问题,譬如一个块元素的长宽高是否属于这个块?为什么会出现完全的重叠,而且之后为什么内容“2”会偏离出本身在块元素内的位置,独自被逼到一边去?clear: left又是为什么会成功?为什么我的safari和ff都同时显现了楼主的情况,究竟是不是浏览器的问题我表示质疑。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

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

Zend Studio 13.0.1

Powerful PHP integrated development environment