|
导读网页的本质就是超级文本标记语言,通过结合使用其他的Web技术(如:脚本语言、公共网关接口、组件等),可以创造出功能强大的网页。因而,超级文本标记语言是万维网(Web)编程的基础,也就是说万维网是建立... 网页的本质就是超级文本标记语言,通过结合使用其他的Web技术(如:脚本语言、公共网关接口、组件等),可以创造出功能强大的网页。因而,超级文本标记语言是万维网(Web)编程的基础,也就是说万维网是建立在超文本基础之上的。超级文本标记语言之所以称为超文本标记语言,是因为文本中包含了所谓“超级链接”点。 本篇文章给大家带来的内容是关于怎么利用纯CSS实现页面换肤?CSS实现换肤方法,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
1.同一类型的属性要写在同一个样式里面。 2.关于伪类的使用 3.:target伪类 4.阴影的使用 5.z-index属性 HTML代码: <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<img class="bg bg1" id="bg1" src="img/1.jpg"/>
<img class="bg bg2" id="bg2" src="img/2.jpg"/>
<img class="bg bg3" id="bg3" src="img/3.jpg"/>
<div class="father">
<a href="#bg1">背景一</a>
<a href="#bg2">背景二</a>
<a href="#bg3">背景三</a>
</div>
</body>
</html>css代码: *{
margin: 0;
padding: 0;
}
html,body{
height: 100%;
overflow: hidden;
}
img{
position: absolute;
height: 100%;
width: 100%;
}
.father{
position: absolute;
z-index: 99;
width: 550px;
top: 40%;
left: 50%;
transform: translate(-50%,-50%);
}
a{
cursor: pointer;
position: absolute;
text-align: center;
text-decoration: none;
width: 150px;
height: 200px;
float: left;
margin-right: 50px;
line-height: 200px;
border-radius: 20px;
}
a:nth-child(1){
background: lightblue;
left: 0px;
}
a:nth-child(2){
background: lightcoral;
left: 200px;
}
a:nth-child(3){
background: #cec;
left: 400px;
}
a:after{
content: '';
width: 125px;
height: 125px;
border: 3px solid white;
position: absolute;
top: -60px;
left: 9px;
opacity: 0.7;
border-radius: 50%;
}
/*background-size必须和background在同一个样式元素内设置样式*/
a:nth-child(1):after{
background: url(../img/1.jpg);
background-size: 80%;
}
a:nth-child(2):after{
background: url(../img/2.jpg);
background-size: 80%;
}
a:nth-child(3):after{
background: url(../img/3.jpg);
background-size: 80%;
}
a:hover:after{
opacity: 0.9;
}
a:hover{
color: white;
font-family: "微软雅黑";
/*多阴影,用的不多,冷门小知识*/
text-shadow: 0 0 3px blue,
0 0 9px darkturquoise,
0 0 15px lightcoral;
}
/*:target伪类必须配合锚点使用,效果是锚点被选中时的样式*/
img:target{
z-index: 30;
}
/*:not伪类*/
img:not(:target){
z-index: 0;
}最后的效果大家自己试一试吧,注意我的页面是使用图片做背景,背景图的引入链接和自己的文件结构有关,url记得改。 如果你能看到最后,再分享一个很常用的知识: 万能清除法 父元素:after{
content: "";/*有时会用content:"."*/
clear:both;
display:block;
height:0;
overflow:hidden;
visibility:hidden;
}以上就是对怎么利用纯CSS实现页面换肤?CSS实现换肤方法的全部介绍,如果您想了解更多有关CSS视频教程,请关注PHP中文网。 以上就是怎么利用纯CSS实现页面换肤?CSS实现换肤方法的详细内容,更多请关注php中文网其它相关文章! 网站建设是一个广义的术语,涵盖了许多不同的技能和学科中所使用的生产和维护的网站。 |
温馨提示:喜欢本站的话,请收藏一下本站!