<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>LOL</title> <style> body { /* 设置背景颜色 */ /* background-color: pink; */ /* 设置背景图 */ /* background-image: url("imgs/zhihu.png"); */ /* 是否重复图片铺满标签 */ /* background-repeat: no-repeat; */ /* 背景图位置 */ /* background-position: center -10px; */ /* 背景图大小:contain、cover */ /* background-size: 1150px; */ /* 默认背景滚动:scroll 不滚动背景图:fixed */ /* background-attachment: fixed; */ /* 综合写法 */ background: pink url(imgs/zhihu.png) no-repeat fixed center center; background-size: cover; } /* 半透明背景 */ /* div { height: 350px; color: #000; background:rgba(0, 0, 0, 0.5) url('imgs/油菜花.jpg') no-repeat; background-attachment:fixed; 背景图平铺,和cover的区别在于cover在不失真的情况下,保证宽高和标签相等 会截取部分图片。而contain在保证一个宽或者高相等即可。 background-size: contain; } */ /* 设置文字凸起,文字凹入只需要将 */ div p:first-child { font: normal 700 48px "微软雅黑"; color: white; text-shadow: 1px 1px 1px rgba(17, 5, 15, 0.3), -1px -1px 1px rgba(17, 5, 15, 0.3); /* background-color: grey; */ } div p { font: 700 18px "微软雅黑"; } a { /* 标签的宽高 */ width: 200px; height: 20px; /* 以行内块标签显示,使宽高设置生效 */ display: inline-block; /* 设置标签内文本字体和颜色 */ font: normal 700 18px "微软雅黑"; color: rgb(108, 6, 224); /* 使用line-height与height相等使文字垂直居中 */ line-height: 20px; /* 文字水平居中 */ text-align: center; /* 上划线: overline 下划线underline 删除线 line-through*/ text-decoration: none; /* 设置边框宽度、风格、颜色 */ border: 1px dashed white; } /* 当鼠标经过时显示背景图片 */ a:hover { background-image: url('imgs/油菜花.jpg'); background-size: cover; color: olivedrab; } </style></head><body> <a href="#">首页</a> <a href="#">故事</a> <a href="#">诗歌</a> <a href="#">小说</a> <div> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> <p>我是段落</p> </div></body></html>
