search
HomeWeb Front-endHTML Tutorial如何解决DIV占用另一DIV空间问题_html/css_WEB-ITnose

本帖最后由 oqzuser2352925146 于 2012-09-05 11:58:15 编辑

我设置了三个DIV,分别为左中右,都没有设定高度,因为文章长度不确定,当我在中间层输入文字时,把左右两层的空间也占用了,各层都设定了宽度的,如何解决这个问题呢?

另外,如何在渐变的背景上加背景图片呢?下面的渐变效果好像不是很好

<style type="text/css"><!--#content {    width:1003px;	margin:0 auto;    background: #979797; /* Old browsers */	background: -moz-linear-gradient(top,  #6a6a6a 0%, #FFFFFF 100%); /* FF3.6+ */	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6a6a6a), color-stop(100%,#FFFFFF)); /* Chrome,Safari4+ */	background: -webkit-linear-gradient(top,  #6a6a6a 0%,#FFFFFF 100%); /* Chrome10+,Safari5.1+ */	background: -o-linear-gradient(top,  #979797 0%,,#FFFFFF 100%); /* Opera 11.10+ */	background: -ms-linear-gradient(top,  #979797 0%,#FFFFFF 100%); /* IE10+ */	background: linear-gradient(to bottom,  #979797 0%,#FFFFFF 100%); /* W3C */	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#979797', endColorstr='#FFFFFF',GradientType=0 ); /* IE6-9 */}#content_left {    float:left;	width:115px;}content_main {    word-wrap:break-word;    width:872px;}#content_right {    float:right;	width:116px;	}--></style><div id="content">    <div class="main">        <div id="content_left">            <div>            <img  src="/static/imghwm/default1.png"  data-src="images/what-we-do_47.gif"  class="lazy"    alt="如何解决DIV占用另一DIV空间问题_html/css_WEB-ITnose" >            </div>        </div>        <div id="content_main">        南都讯 记者薛冰妮 实习生 邓倩晖 昨日,广东省计生委主任骆文智做客民声热线,首度正式回应“单独子女生二胎”等调整生育政策的呼声。骆文智称,国家目前没有做出决定搞生育政策调整试点工作,也没有接受过各省试点工作的申报,更不存在批与不批的问题。他强调,近期国家生育政策不会有大的调整。  近一段时期生育政策不会有大的调整  面对计生政策是否调整的疑问,广东省计生委主任骆文智回应,生育政策的调整必须经中央批准,任何地方都无权力调整政策,最近国家人口计生委也反复强调,在国家没有调整政策前,任何部门都不能随意发表意见,更不能擅自调整政策,这是重要、严肃的政治组织纪律。最近,部分专家、学者对调整生育政策提出了一些建议和看法,这是正常的,但是个人所言,并不代表政府。  骆文智还特别说明,“国家到目前为止没有做出决定搞生育政策调整试点工作,也没有正式、也没有在任何时候接受过各省试点工作的申报,更不存在批与不批的问题。所以只要国家政策没有调整,大家都要自觉遵守和支持计划生育政策。”他表示,近一段时期国家生育政策不会有大的调整,即使以后要完善和调整生育政策还是计划生育。  广东“失独”家庭至少3 .6万户  骆文智表示,广东目前登记的“失独”家庭有36000多户,其中76%的“失独”家庭实现了再生育。骆文智表示,36000户的数据未必统计完全,有些家庭不一定愿意领每月150元的补助,所以不愿登记。        </div>        <div id="content_right">        </div>      </div></div>

回复讨论(解决方案)

<style type="text/css"><!--#content {    width:1003px;    margin:0 auto;    background: #979797; /* Old browsers */    background: -moz-linear-gradient(top,  #6a6a6a 0%, #FFFFFF 100%); /* FF3.6+ */    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6a6a6a), color-stop(100%,#FFFFFF)); /* Chrome,Safari4+ */    background: -webkit-linear-gradient(top,  #6a6a6a 0%,#FFFFFF 100%); /* Chrome10+,Safari5.1+ */    background: -o-linear-gradient(top,  #979797 0%,,#FFFFFF 100%); /* Opera 11.10+ */    background: -ms-linear-gradient(top,  #979797 0%,#FFFFFF 100%); /* IE10+ */    background: linear-gradient(to bottom,  #979797 0%,#FFFFFF 100%); /* W3C */    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#979797', endColorstr='#FFFFFF',GradientType=0 ); /* IE6-9 */}#content_left {    float:left;    width:115px;}#content_main {    width:700px;margin:0 125px;}#content_right {    float:right;    width:116px;  }--></style><div id="content">    <div class="main">        <div id="content_left">            <div>    左            </div>        </div><div id="content_right">右        </div>         <div id="content_main">        南都讯 记者薛冰妮 实习生 邓倩晖 昨日,广东省计生委主任骆文智做客民声热线,首度正式回应“单独子女生二胎”等调整生育政策的呼声。骆文智称,国家目前没有做出决定搞生育政策调整试点工作,也没有接受过各省试点工作的申报,更不存在批与不批的问题。他强调,近期国家生育政策不会有大的调整。  近一段时期生育政策不会有大的调整  面对计生政策是否调整的疑问,广东省计生委主任骆文智回应,生育政策的调整必须经中央批准,任何地方都无权力调整政策,最近国家人口计生委也反复强调,在国家没有调整政策前,任何部门都不能随意发表意见,更不能擅自调整政策,这是重要、严肃的政治组织纪律。最近,部分专家、学者对调整生育政策提出了一些建议和看法,这是正常的,但是个人所言,并不代表政府。  骆文智还特别说明,“国家到目前为止没有做出决定搞生育政策调整试点工作,也没有正式、也没有在任何时候接受过各省试点工作的申报,更不存在批与不批的问题。所以只要国家政策没有调整,大家都要自觉遵守和支持计划生育政策。”他表示,近一段时期国家生育政策不会有大的调整,即使以后要完善和调整生育政策还是计划生育。  广东“失独”家庭至少3 .6万户  骆文智表示,广东目前登记的“失独”家庭有36000多户,其中76%的“失独”家庭实现了再生育。骆文智表示,36000户的数据未必统计完全,有些家庭不一定愿意领每月150元的补助,所以不愿登记。        </div>             </div></div>

HTML code

<div id="content">    <div class="main">        <div id="content_left">            <div>            <img  src="/static/imghwm/default1.png"  data-src="images/what-we-do_47.gif"  class="lazy"    alt="如何解决DIV占用另一DIV空间问题_html/css_WEB-ITnose" >            </div>        </div>        <div id="content_right">        </div>          <div id="content_main"   style="max-width:90%">        南都讯 记者薛冰妮 实习生 邓倩晖 昨日,广东省计生委主任骆文智做客民声热线,首度正式回应"单独子女生二胎"等调整生育政策的呼声。骆文智称,国家目前没有做出决定搞生育政策调整试点工作,也没有接受过各省试点工作的申报,更不存在批与不批的问题。他强调,近期国家生育政策不会有大的调整。  近一段时期生育政策不会有大的调整  面对计生政策是否调整的疑问,广东省计生委主任骆文智回应,生育政策的调整必须经中央批准,任何地方都无权力调整政策,最近国家人口计生委也反复强调,在国家没有调整政策前,任何部门都不能随意发表意见,更不能擅自调整政策,这是重要、严肃的政治组织纪律。最近,部分专家、学者对调整生育政策提出了一些建议和看法,这是正常的,但是个人所言,并不代表政府。  骆文智还特别说明,"国家到目前为止没有做出决定搞生育政策调整试点工作,也没有正式、也没有在任何时候接受过各省试点工作的申报,更不存在批与不批的问题。所以只要国家政策没有调整,大家都要自觉遵守和支持计划生育政策。"他表示,近一段时期国家生育政策不会有大的调整,即使以后要完善和调整生育政策还是计划生育。  广东"失独"家庭至少3 .6万户  骆文智表示,广东目前登记的"失独"家庭有36000多户,其中76%的"失独"家庭实现了再生育。骆文智表示,36000户的数据未必统计完全,有些家庭不一定愿意领每月150元的补助,所以不愿登记。        </div>    </div></div>

content_main {    word-wrap:break-word;    width:872px;}


改成

#content_main {    word-wrap:break-word;    width:872px;}


LZ忘记content_main是id了吧  

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

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

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

HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

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.

The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 08, 2025 pm 07:05 PM

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.

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 Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

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.