html怎么添加css样式?
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> html添加css样式有三种<span style="color: black;">办法</span>,分别为行内式(<span style="color: black;">运用</span>style属性,在特定的HTML标签内<span style="color: black;">运用</span>)、内嵌式(style标签把css代码放在特定页面的head部分中)、外联式(<span style="color: black;">运用</span>link标签,将<span style="color: black;">外边</span>css文件链接到HTML中)。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><a style="color: black;"><span style="color: black;"><span style="color: black;">web前端学习:web前端<span style="color: black;">基本</span>资料免费领取(面试题、视频、进阶路线)</span><span style="color: black;"><span style="color: black;"></span>zh</span></span></a>uanlan.zhihu.com/p/136454207</div>
<h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">1、</span>行内式</h2>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">运用</span>style属性在特定的HTML标记内设置CSS样式。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">意见</span>不要<span style="color: black;">运用</span>内联CSS,<span style="color: black;">由于</span><span style="color: black;">每一个</span>HTML标记都<span style="color: black;">必须</span>单独设置样式,<span style="color: black;">倘若</span>您只<span style="color: black;">运用</span>内联CSS,管理网站可能会变得<span style="color: black;">非常</span>困难。<span style="color: black;">然则</span>,它在某些<span style="color: black;">状况</span>下<span style="color: black;">特别有</span>用。例如,在您<span style="color: black;">没</span>法<span style="color: black;">拜访</span>CSS文件或仅需要为单个元素应用样式的<span style="color: black;">状况</span>下。带有内联CSS的HTML页面示例如下所示:</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><!DOCTYPE html>
<html>
<body style="bac<span style="color: black;">公斤</span>round-color:black;">
<h1 style="color:white;padding:30px;">Hostinger Tutorials</h1>
<p style="color:white;">Something usefull here.</p>
</body>
</html></div>
<h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">2、</span>内嵌式</h2>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">内嵌css样式<span style="color: black;">便是</span>把css代码放在特定页面的<head>部分中。内嵌CSS<span style="color: black;">必须</span>放在<style></style>标签之间。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">类和ID可用于引用CSS代码,但它们仅在该特定页面上<span style="color: black;">处在</span>活动状态。每次页面加载时都会下载以这种方式嵌入的CSS样式,<span style="color: black;">这般</span><span style="color: black;">能够</span><span style="color: black;">加强</span>加载速度。在某些<span style="color: black;">状况</span>下<span style="color: black;">运用</span>内嵌样式表<span style="color: black;">特别有</span>用,<span style="color: black;">例如</span>:向某人发送页面模板, <span style="color: black;">由于</span>一切都在一个页面中,<span style="color: black;">因此</span>看到预览要容易得多。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">内部样式表的一个示例:</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><head>
<style type="text/css">
p {color:white; font-size: 10px;}
.center {display: block; margin: 0 auto;}
#button-go, #button-back {border: solid 1px black;}
</style>
</head></div>
<h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">3、</span>外联式</h2>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">外联式<span style="color: black;">便是</span><span style="color: black;">运用</span>link标签元素将<span style="color: black;">外边</span>CSS文件(.css文件)引用到HTML页面中,引用需要放在页面的<head>部分中。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这是将CSS添加到html页面上最方便的<span style="color: black;">办法</span>。<span style="color: black;">这般</span>,您对<span style="color: black;">外边</span>CSS文件所做的任何更改都将反映在你的网站上。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">外联样式表的一个示例:</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">而style.css<span style="color: black;">包括</span>所有样式规则。例如:</p>
<div style="color: black; text-align: left; margin-bottom: 10px;">.xleftcol {
float: left;
width: 33%;
bac<span style="color: black;">公斤</span>round:#809900;
}
.xmiddlecol {
float: left;
width: 34%;
bac<span style="color: black;">公斤</span>round:#eff2df;
}</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">如今大<span style="color: black;">都数</span>网站<span style="color: black;">运用</span><span style="color: black;">外边</span>样式表,<span style="color: black;">外边</span>样式是在单独的文档中编写<span style="color: black;">而后</span>附加到<span style="color: black;">各样</span>Web文档的样式。<span style="color: black;">外边</span>样式表会影响它们所连接的任何文件,这<span style="color: black;">寓意</span>着<span style="color: black;">倘若</span>你有一个20页的网站,<span style="color: black;">每一个</span>页面<span style="color: black;">运用</span>相同的样式表,当<span style="color: black;">必须</span>改变的话只需编辑该样式表<span style="color: black;">就可</span>完成这些页面,这使得<span style="color: black;">长时间</span>站点管理变得更加容易。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">以上<span style="color: black;">便是</span>html怎么添加css样式?的<span style="color: black;">仔细</span>内容,<span style="color: black;">更加多</span>请关注我!!!</p>
谢谢、感谢、感恩、辛苦了、有你真好等。
页:
[1]