search
HomeWeb Front-endHTML TutorialCSS DIV: Implementing cool web page styles and layout_html/css_WEB-ITnose

Although I have been exposed to HTML and CSS before, and have worked on projects for a period of time, I have used CSS and DIV, but after all, I have not realized that the effects that can be achieved after integrating the two are far beyond My imagination.

In fact, many people who have written front-end pages know that DIV and CSS are actually very simple, but it is not easy to achieve the desired effect or the effect you imagine in your mind. There are a lot of techniques here. If you are not familiar with and proficient in them, then the page you create will not achieve the expected effect, and sometimes it will be particularly ugly.

First of all, let’s take a look at what DIV is?

DIV is one of the many tags in the markup language HTML, but it is the most frequently used tag for document page layout. It can define sections or sections in the document, or it can split the document into independent and different parts. It can be used as a strict organizational tool and does not use any formatting associated with it. If you use id or class to mark

, the tag will become more effective.

                                                                                                                                                                This means that its contents automatically start on a new line. In fact, line breaks are the only formatting behavior inherent to

. You can apply your custom styles through the class or id of
. Of course, you don't have to add a class or id to every
, although there are certain benefits to doing so. We can apply either class or id attributes to the same
element, but it's more common to apply only one or the other. The main difference between the two is that class is used for groups of elements (similar elements, or can be understood as a certain type of elements), while id is used to identify individual and unique elements. For example, a
can use multiple class attribute styles, but can only use one id attribute style.

Secondly, let’s look at what the hell is CSS?

We have already mentioned some things about CSS when introducing DIV above. When we add styles to HTML page elements, we often use tag selectors, id selectors and class selectors. Each of these selectors has its own characteristics: if the style is unified, it is best to use the tag selector, which can unify the styles of all the same tags on the page; and the id selector provides a more convenient personalized style. Definition, as for the class selector, it is a diverse style definition, because CSS allows the use of multiple class selector style definitions. Of course, the class selector also has "inheritance" and can derive different styles.

It may be a bit abstract, and those who have never done it may not understand it. Let’s look at a few examples:

<span style="font-size:18px;">/*标签选择器*/body{	background-color:#2a3a00;	/* 深绿色背景 */	margin:0px; padding:0px;	font-family:Arial, Helvetica, sans-serif;	font-size:12px;}img{	margin:0px; padding:0px;	border:none;}/*id选择器*/#pic{	position:absolute;	top:5%;	left:0%;	width:100%;	background:url(middle_bg.jpg) repeat-x;	/* x方向重复 */}/*class选择器*/.center {text-align: center}</span>

Where is the crazy cool page mentioned in the title? Here are a few examples to show the power of CSS DIV:

Imitate Google’s logo

Imitate the design of the website homepage

<span style="font-size:18px;">	<title>Google</title>
<style>p{	font-size:80px;	letter-spacing:-2px;		/* 字母间距 */	font-family:Arial, Helvetica, sans-serif;}.g1, .g2{ color:#184dc6; }.o1, .e{ color:#c61800; }.o2{ color:#efba00; }.l{ color:#42c34a; }</style>   		<p><span class="g1">G</span><span class="o1">o</span><span class="o2">o</span><span class="g2">g</span><span class="l">l</span><span class="e">e</span></p></span>
>

To summarize

: For many people, the concepts of CSS and DIV are already familiar, but not everyone can do crazy things. To create cool web pages, because we are not proficient enough, we are not good at using many things, and our grasp of page layout and style is not accurate enough, so the pages we create are still a little immature, but please believe in ourselves, as long as we add more Application and summary, given time, as long as you give us CSS and HTML, cool web pages will be at your fingertips

<span style="font-size:18px;"><title>World Word</title>
<link href="17.css" rel="stylesheet" type="text/css">   <div id="container">	<div id="banner"><a href="17.html"><img  src="/static/imghwm/default1.png" data-src="banner.jpg" class="lazy" border="0" alt="CSS DIV: Implementing cool web page styles and layout_html/css_WEB-ITnose" ></a></div>    <div id="navigation">		<ul>			<li><a href="page1.html">翻译服务</a></li>			<li><a href="page2.html">网站建设</a></li>			<li><a href="page3.html">服务流程</a></li>			<li><a href="page4.html">付费</a></li>		</ul>	</div>	<div id="text">		<h3 id="为您提供精准的翻译服务">为您提供精准的翻译服务</h3>		<p>您是否要将某些文档翻译成标准的英语版本?您是否担心译文会不符合西方语系的语言习惯?您是否遇到语言障碍而放缓向境外拓展业务的步伐?您是否受到时而需要处理外文资料的困扰?</p>		<p>让我们来帮您解决这些问题。我们这里提供的服务<a href="page3.html">快捷</a> 、高效、准确,而且<a href="page4.html">付费</a>方便。您无需走出家门,就可同我们一起走完服务的全过程,甚至包括付费。</p>		<p>我们有来自中国和新加坡的翻译专家,他们具有得天独厚的语言基础和深厚的文化背景。他们合作的结晶一定是非常贴切而精美的译文作品。我们会分配以您的目标语种为 母语 的翻译员为你翻译,同时他们也 精通 您的源语语种。</p>		<p>您若有此需求或任何疑问,请浏览我们的网站,也可随时同我们联系,您会得到耐心的解答。我们的联系方式是: <a href="mailto:demo@demo.com">demo@demo.com</a>。</p>	</div>	<div id="footer">联系我们: <a href="mailto:demo@demo.com">demo@demo.com</a>
</div>
</div></span>
Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

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

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.

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

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools