
html:
<!DOCTYPE html>
<html>
<head>
<title>My webpage</title>
</head>
<body>
<div>
<h1>My first div</h1>
<p>This div uses inline CSS to style its content.</p>
<style>
h1 {
color: red
}
p {
font-size: 16px
text-align: center
}
</style>
</div>
<div>
<h1>My second div</h1>
<p>This div uses an external CSS file to style its content.</p>
<link rel="stylesheet" type="text/css" href="styles.css">
</div>
<div>
<h1>My third div</h1>
<p>This div uses an embedded style sheet to style its content.</p>
<style>
/* This is an embedded style sheet */
h1 {
color: blue
}
p {
font-size: 14px
text-align: left
}
</style>
</div>
</body>
</html>
style.css:
/* This is an external style sheet */
h1 {
color: green
}
p {
font-size: 18px
text-align: right
}
这段代码中,第一个div使用内联CSS来样式其内容,第二个div使用外部CSS文件来样式其内容,第三个div使用嵌入式样式表来样式其内容。
<!DOCTYPE HTML><html>
<meta charset="UTF-8"/>
<head>
<title></title>
</head>
<style type="text/css">
html,body {
border: 1px solid #000000
box-sizing: border-box
width: 100%
height: 360px
margin:0
padding:0
position: relative
}
.demo{
height: 150px
width: 500px
overflow: auto
margin: auto
position: absolute
top: 0 left: 0 bottom: 0 right: 0
background: rgba(255,100,255,0.2)
border: 5px solid #ff88ff
font-size: 40px
font-family: "微软雅黑"
text-align: center
line-height: 150px
word-spacing: 20px
border-radius: 20px
box-shadow: 20px 10px 10px rgba(100,100,100,0.5)
}
</style>
<body>
<div class="demo">
</div>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)