Home Web Front-end CSS Tutorial A new beginning for div+css web page layout design (1)

A new beginning for div+css web page layout design (1)

Dec 29, 2016 pm 02:11 PM

DIV+CSS is one of the commonly used terms in website standards (or "WEB standards"). div+css is a web page layout method. This web page layout method is different from the traditional HTML web page design language. The table positioning method can realize the separation of web page content and presentation. XHTML is the abbreviation of The Extensible HyperText Markup Language. XHTML is based on Extensible Markup Language (XML), which is a new language optimized and improved on the basis of HTML. The purpose is to adapt to more needs of future network applications based on XML applications and powerful data conversion capabilities. In the XHTML website design standards, table positioning technology is no longer used, but DIV+CSS is used to achieve various positioning.

It used to be table layout. . It is basically no longer used (table is only used to display data)
div means area in Chinese, and css means cascading style sheet. It can be seen that the core is layout, not style.

I am learning DIV Before +CSS, you must be familiar with HTML. DIV+CSS must be learned on the basis of HTML

Okay, what tool are you using now? Generally, Notepad is enough, that is, Notepad + browser is OK. , you don’t need a server, you can also use Dreamweaver CS5. There are tips for this. It is best to download the Chinese version of the CSS style sheet manual for the help document, so that you can get everything done.

The above things are easy to find online, and you can Download in the group web programming development: 197132320. Of course, friends who love web programming are also welcome to join

Let’s start learning. First, familiarize yourself with the basic structure of html and create an html file test.html

1

2

3

4

5

6

7

8

<html>

<head>

<title>这是HTML基本结构</title>

<head>

<body>

hello!

</body>

</html>

Copy after login
Copy after login

Of course, you can also display it normally if you directly input hello into the html file, but this does not meet the standards.
Now let’s get to know div. In fact, it can be regarded as a container or a box, which is dedicated to holding content. ’s

1

2

3

4

5

6

7

8

<html>

<head>

<title>DIV认识</title>

<head>

<body>

<div>这是一个div</div>

</body>

</html>

Copy after login
Copy after login

But you can’t see this div on the web page, because it is still transparent
We need to give it a style to display, first let its border display, width and height 100px, the background color is red

1

2

3

4

5

6

7

8

<html>

<head>

<title>DIV认识</title>

<head>

<body>

<div style="border:solid 1px;width:100px;height:100px;background:red">这是一个div</div>

</body>

</html>

Copy after login
Copy after login

Every html tag has a style attribute, and div is no exception of course
border: solid 1px border means the css border attribute solid 1px is its two values Pay attention to the space
solid means the border is displayed 1px means the border width is 1 pixel
What is a pixel? See here http://baike.baidu.com/view/575.htm

width:100px ;height:100px; is to set the width and height of the div. Pay attention to the value of each attribute: Use;
background:red to separate the attributes. Set the background to red

The above code will be displayed in the browser as follows

A new beginning for div+css web page layout design (1)

##Close sidebar

CSS Homepage > web programming > CSS >

大中小

div +css web page layout design new beginning (1)

Time: 2014-03-09 20:49 Clicks: 709 times

DIV+CSS is a website standard (or "WEB standard") One of the commonly used terms in HTML, div+css is a web page layout method. This web page layout method is different from the table positioning method in the traditional HTML web design language, and can realize the separation of web page content and presentation. . XHTML is the abbreviation of The Extensible HyperText Markup Language. XHTML is based on Extensible Markup Language (XML), which is a new language optimized and improved on the basis of HTML. The purpose is to adapt to more needs of future network applications based on XML applications and powerful data conversion capabilities. In the XHTML website design standards, table positioning technology is no longer used, but DIV+CSS is used to achieve various positioning.


It used to be table layout. . It is basically no longer used (table is only used to display data)
div means area in Chinese, and css means cascading style sheet. It can be seen that the core is layout, not style.

I am learning DIV Before +CSS, you must be familiar with HTML. DIV+CSS must be learned on the basis of HTML

Okay, what tool are you using now? Generally, Notepad is enough, that is, Notepad + browser is OK. , you don’t need a server, you can also use Dreamweaver CS5. There are tips for this. It is best to download the Chinese version of the CSS style sheet manual for the help document, so that you can get everything done.

The above things are easy to find online, and you can Download in the group web programming development: 197132320. Of course, friends who love web programming are also welcome to join

Let’s start learning. First, familiarize yourself with the basic structure of html and create an html file test.html

1

2

3

4

5

6

7

8

<html>

<head>

<title>这是HTML基本结构</title>

<head>

<body>

hello!

</body>

</html>

Copy after login
Copy after login

Of course, you can also display it normally if you directly input hello into the html file, but this does not meet the standards.

Now let’s get to know div. In fact, it can be regarded as a container or a box, which is dedicated to holding content. ’s

1

2

3

4

5

6

7

8

<html>

<head>

<title>DIV认识</title>

<head>

<body>

<div>这是一个div</div>

</body>

</html>

Copy after login
Copy after login

But you can’t see this div on the web page, because it is still transparent

We need to give it a style to display, first let its border display, width and height 100px, background color is red

1

2

3

4

5

6

7

8

<html>

<head>

<title>DIV认识</title>

<head>

<body>

<div style="border:solid 1px;width:100px;height:100px;background:red">这是一个div</div>

</body>

</html>

Copy after login
Copy after login

每一个html标签都有style属性,div当然也不例外
border:solid 1px border表示css边框属性 solid 1px 是它的两个值 注意要空格
solid 表示边框实现显示 1px表示边框宽度为1像素
什么是像素 看这里http://baike.baidu.com/view/575.htm

width:100px;height:100px;是设置div的宽度和高度 注意每个属性给值用: 属性之间隔开用;
background:red 背景设置红色

如上代码在浏览器显示如下


还得提一下,浏览器最好用IE8 谷歌浏览器,火狐浏览器,360的也可以
因为他们支持css标准还算兼容,别的浏览器就说不准了,你看的结果可能不一样
css浏览器兼容日后再说



引入css样式除了上面一种,还有两种
一种是外部样式引入,特别推荐这种,一种是内部样式

外部样式引入需要在head标签里加

另外还的在html文件相同目录下创建mystyle.css文件

内部样式是直接在head写入,由于贴子特殊性,本贴全部用内部样式,这样看的舒服点,但在实际中最好用外部样式引入

这是内部样式

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<html>

<head>

<style type="text/css">

div{

border:solid 1px;

width:100px;

height:100px;

background:red

}

</style> <head>

<body>

<div>这是一个div</div>

</body>

</html>

Copy after login

这比之前要规范多了,body里也看的简单多了,要多多用这种样式与内容分离模式



如果是这种

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<html>

<head>

<style type="text/css">

div{

border:solid 1px;

width:100px;

height:100px;

background:red

}

</style> <head>

<body>

<div style="border:solid 1px;width:200px;height:200px;background:green">这是一个div</div>

</body>

</html>

Copy after login

两种样式你觉得它会采用哪个?
style属性这种是内联样式
这就是优先级问题,它会采用离它最近的那个,也就是style属性里的
同样,如果外部样式与内部样式相同,它会优先采用内部样式的
如果不是全部都相同,它会把不同的合并起来,相同的就优先采用内部样式的
优先级
内联》内部》外部

 以上就是div+css网页布局设计新开端(1)的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Statement of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1654
14
PHP Tutorial
1252
29
C# Tutorial
1225
24
Google Fonts   Variable Fonts Google Fonts Variable Fonts Apr 09, 2025 am 10:42 AM

I see Google Fonts rolled out a new design (Tweet). Compared to the last big redesign, this feels much more iterative. I can barely tell the difference

How to Create an Animated Countdown Timer With HTML, CSS and JavaScript How to Create an Animated Countdown Timer With HTML, CSS and JavaScript Apr 11, 2025 am 11:29 AM

Have you ever needed a countdown timer on a project? For something like that, it might be natural to reach for a plugin, but it’s actually a lot more

HTML Data Attributes Guide HTML Data Attributes Guide Apr 11, 2025 am 11:50 AM

Everything you ever wanted to know about data attributes in HTML, CSS, and JavaScript.

How to select a child element with the first class name item through CSS? How to select a child element with the first class name item through CSS? Apr 05, 2025 pm 11:24 PM

When the number of elements is not fixed, how to select the first child element of the specified class name through CSS. When processing HTML structure, you often encounter different elements...

Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Apr 05, 2025 pm 05:51 PM

Questions about purple slash areas in Flex layouts When using Flex layouts, you may encounter some confusing phenomena, such as in the developer tools (d...

A Proof of Concept for Making Sass Faster A Proof of Concept for Making Sass Faster Apr 16, 2025 am 10:38 AM

At the start of a new project, Sass compilation happens in the blink of an eye. This feels great, especially when it’s paired with Browsersync, which reloads

How We Created a Static Site That Generates Tartan Patterns in SVG How We Created a Static Site That Generates Tartan Patterns in SVG Apr 09, 2025 am 11:29 AM

Tartan is a patterned cloth that’s typically associated with Scotland, particularly their fashionable kilts. On tartanify.com, we gathered over 5,000 tartan

See all articles