HTML--4布局

本文介绍了HTML类的使用,如何定义和应用类以实现内容的样式统一。接着讲解了行内元素<span>的类设置,以及HTML5的布局元素如<header>, <nav>, <section>和<footer>的应用。同时,通过CSS对这些元素进行样式设计,展示了如何创建页面布局。" 95041472,7242871,AI实战:深度解析文字识别技术——LSTM+CTC、CRNN与chineseocr,"['深度学习', '图像识别', '自然语言处理', 'AI实战', '机器视觉']
摘要由CSDN通过智能技术生成

****HTML类

该功能的作用是:就好比一个模板,要让一些内容或者块表现出相同的内容,每次

设置他们的style属性太麻烦也不高效,而用HTML类就方便许多。

要在<head></head>中用上<style></style>标签,style 标签定义类(用大括号)

ex:

<head>

<style>

.cities{

background-color:black;

color:white;

margin:20px;

padding:20px;

}

</style>

</head>

这样在开头定义了一个类,使用时结合块:

ex:

<body>

<div class="cities">

内容1

</div>

<div class="cities">

内容2

</div>

$注意:在定义类时,类名前面有一点“.”

 

_______________________________________________________

******分类行内元素

设置 <span> 元素的类,能够为相同的 <span> 元素设置相同的样式。

<head>

<style>

span.red{color:red;}

</style>

</head>

$注意:采用span.类名的形式

使用:

<body>

<h1>My <span class="red">important</span>Heading</h1>

</body>

则将对important采用红色字体。

————————————————————

*****HTML布局(用html5布局和使用<div>元素的HTML布局)

header:定义文档或节的页眉

nav:定义导航链接的容器

section:定义文档中的节

footer:定义文档或者节的页脚

css:

<head>

<style>

header{

background-color:black;

color:white;

text-align:center:

padding:5px;

}

nav{

line-height:30px;

background-color:black;

height:300px;

width:100px;

float:left;

padding:5px;

}

section {
    width:350px;
    float:left;
    padding:10px;          
}

footer {
    background-color:black;
    color:white;
    clear:both;
    text-align:center;
    padding:5px;          
}
</style>
</head>

<body>

<header>
<h1>City Gallery</h1>
</header>

<nav>
London<br>
Paris<br>
Tokyo<br>
</nav>

<section>
<h1>London</h1>
<p>
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
</p>
<p>
Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.
</p>
</section>

<footer>
Copyright W3Schools.com
</footer>

</body>
</html>

 

 

#使用<div>元素的HTML布局

CSS:

<style>
#header {
    background-color:black;
    color:white;
    text-align:center;
    padding:5px;
}
#nav {
    line-height:30px;
    background-color:#eeeeee;
    height:300px;
    width:100px;
    float:left;
    padding:5px; 
}
#section {
    width:350px;
    float:left;
    padding:10px; 
}
#footer {
    background-color:black;
    color:white;
    clear:both;
    text-align:center;
    padding:5px; 
}
</style>

$注意:要有个“#”号

<body>

<div id="header">
<h1>City Gallery</h1>
</div>

<div id="nav">
London<br>
Paris<br>
Tokyo<br>
</div>

<div id="section">
<h1>London</h1>
<p>
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
</p>
<p>
Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.
</p>
</div>

<div id="footer">
Copyright W3School.com.cn
</div>

</body>

再用<div id="ID名”></div>来

 

 

$注意:不论是类名还是用HTML5布局还是使用<div>的HTML布局,<style>均要在<head></head>之内

即在<body>之外

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值