search
HomeWeb Front-endHTML TutorialRookie question: Two divs cannot be displayed up and down. The lower div covers half of the upper part_html/css_WEB-ITnose

Rookie question, please help

Two divs, I want div1 to go up and div2 to go down like this

The height of div1 cannot be set because the length inside div1 is not fixed

div2 always covers div1. Why? ? ?

The question page is here. I wonder if it can be posted. The footer of an article page cannot be postponed and the content will be covered
http://www.cczxs.com/baojia


Reply to discussion (solution)

Is anyone here?

<html><head><meta charset="utf-8"/><title>test</title><style type="text/css">	#test1{		width:800px;		margin-bottom:10px;		border:2px solid red;	}</style></head><body><div id="test1">百度,全球最大的中文搜索引擎、最大的中文网站。2000年1月创立于北京中关村。1999年底,身在美国硅谷的李彦宏看到了中国互联网及中文搜索引擎服务的巨大发展潜力,抱着技术改变世界的梦想,他毅然辞掉硅谷的高薪工作,携搜索引擎专利技术,于2000年1月1日在中关村创建了百度公司。从最初的不足10人发展至今,员工人数超过17000人。如今的百度,已成为中国最受欢迎、影响力最大的中文网站。百度拥有数千名研发工程师,这是中国乃至全球最为优秀的技术团队,这支队伍掌握着世界上最为先进的搜索引擎技术,使百度成为中国掌握世界尖端科学核心技术的中国高科技企业,也使中国成为美国、俄罗斯、和韩国之外,全球仅有的4个拥有搜索引擎核心技术的国家之一。从创立之初,百度便将“让人们最便捷地获取信息,找到所求”作为自己的使命,成立以来,公司秉承“以用户为导向”的理念,不断坚持技术创新,致力于为用户提供“简单,可依赖”的互联网搜索产品及服务,其中包括:以网络搜索为主的功能性搜索,以贴吧为主的社区搜索,针对各区域、行业所需的垂直搜索,Mp3搜索,以及门户频道、IM等,全面覆盖了中文网络世界所有的搜索需求,根据第三方权威数据,百度在中国的搜索份额超过80%。在面对用户的搜索产品不断丰富的同时,百度还创新性地推出了基于搜索的营销推广服务,并成为最受企业青睐的互联网营销推广平台。目前,中国已有数十万家企业使用了百度的搜索推广服务,不断提升着企业自身的品牌及运营效率。通过持续的商业模式创新,百度正进一步带动整个互联网行业和中小企业的经济增长,推动社会经济的发展和转型。为推动中国数百万中小网站的发展,百度借助超大流量的平台优势,联合所有优质的各类网站,建立了世界上最大的网络联盟,使各类企业的搜索推广、品牌营销的价值、覆盖面均大面积提升。与此同时,各网站也在联盟大家庭的互助下,获得最大的生存与发展机会。作为国内的一家知名企业,百度也一直秉承“弥合信息鸿沟,共享知识社会”的责任理念,坚持履行企业公民的社会责任。成立来,百度利用自身优势积极投身公益事业,先后投入巨大资源,为盲人、少儿、老年人群体打造专门的搜索产品,解决了特殊群体上网难问题,极大地弥补了社会信息鸿沟问题。此外,在加速推动中国信息化进程、净化网络环境、搜索引擎教育及提升大学生就业率等方面,百度也一直走在行业领先的地位。2011年初,百度还特别成立了百度基金会,围绕知识教育、环境保护、灾难救助等领域,更加系统规范地管理和践行公益事业。2005年,百度在美国纳斯达克上市,一举打破首日涨幅最高等多项纪录,并成为首家进入纳斯达克成分股的中国公司。通过数年来的市场表现,百度优异的业绩与值得依赖的回报,使之成为中国企业价值的代表,傲然屹立于全球资本市场。2009年,百度更是推出全新的框计算技术概念,并基于此理念推出百度开放平台,帮助更多优秀的第三方开发者利用互联网平台自主创新、自主创业,在大幅提升网民互联网使用体验的同时,带动起围绕用户需求进行研发的产业创新热潮,对中国互联网产业的升级和发展产生巨大的拉动效应。今天,百度已经成为中国最具价值的品牌之一,英国《金融时报》将百度列为“中国十大世界级品牌”,成为这个榜单中最年轻的一家公司,也是唯一一家互联网公司。而“亚洲最受尊敬企业”、“全球最具创新力企业”、“中国互联网力量之星”等一系列荣誉称号的获得,也无一不向外界展示着百度成立数年来的成就。多年来,百度董事长兼CEO李彦宏,率领百度人所形成的“简单可依赖”的核心文化,深深地植根于百度。这是一个充满朝气、求实坦诚的公司,以搜索改变生活,推动人类的文明与进步,促进中国经济的发展为己任,正朝着更为远大的目标而迈进。。</div><div id="test2">2009年,百度更是推出全新的框计算技术概念,并基于此理念推出百度开放平台,帮助更多优秀的第三方开发者利用互联网平台自主创新、自主创业,在大幅提升网民互联网使用体验的同时,带动起围绕用户需求进行研发的产业创新热潮,对中国互联网产业的升级和发展产生巨大的拉动效应。今天,百度已经成为中国最具价值的品牌之一,英国《金融时报》将百度列为“中国十大世界级品牌”,成为这个榜单中最年轻的一家公司,也是唯一一家互联网公司。而“亚洲最受尊敬企业”、“全球最具创新力企业”、“中国互联网力量之星”等一系列荣誉称号的获得,也无一不向外界展示着百度成立数年来的成就。多年来,百度董事长兼CEO李彦宏,率领百度人所形成的“简单可依赖”的核心文化,深深地植根于百度。这是一个充满朝气、求实坦诚的公司,以搜索改变生活,推动人类的文明与进步,促进中国经济的发展为己任,正朝着更为远大的目标而迈进。</div></body></html>

Try it, don’t set the height of div1, use margin -bottom to adjust the spacing

Try setting zindex

Try, do not set the height of div1, use margin-bottom to adjust the spacing



Settings Margin-bottom is off, I don’t know why, it may have other effects

Try, don’t set the height of div1, use margin-bottom to adjust the spacing


Solution, go to the top A div is set to float


Try, instead of setting the height of div1, use margin-bottom to adjust the spacing


Solution, the previous div is set to float
I haven’t set float on both divs, but the lower one still covers part of the upper one. Why?
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
What are boolean attributes in HTML? Give some examples.What are boolean attributes in HTML? Give some examples.Apr 25, 2025 am 12:01 AM

Boolean attributes are special attributes in HTML that are activated without a value. 1. The Boolean attribute controls the behavior of the element by whether it exists or not, such as disabled disable the input box. 2.Their working principle is to change element behavior according to the existence of attributes when the browser parses. 3. The basic usage is to directly add attributes, and the advanced usage can be dynamically controlled through JavaScript. 4. Common mistakes are mistakenly thinking that values ​​need to be set, and the correct writing method should be concise. 5. The best practice is to keep the code concise and use Boolean properties reasonably to optimize web page performance and user experience.

How can you validate your HTML code?How can you validate your HTML code?Apr 24, 2025 am 12:04 AM

HTML code can be cleaner with online validators, integrated tools and automated processes. 1) Use W3CMarkupValidationService to verify HTML code online. 2) Install and configure HTMLHint extension in VisualStudioCode for real-time verification. 3) Use HTMLTidy to automatically verify and clean HTML files in the construction process.

HTML vs. CSS and JavaScript: Comparing Web TechnologiesHTML vs. CSS and JavaScript: Comparing Web TechnologiesApr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

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.

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

Video Face Swap

Video Face Swap

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

Hot Tools

SecLists

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.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)