css中如何实现页面跳转代码

html-css08

css中如何实现页面跳转代码,第1张

CSS就是层叠样式表,它的主要功能是用来修饰和美化页面的,一般对于这种功能性的东西都是交付给JS或者html中的<a>标签也可以实现

虽然有一种写法:

<style type="text/css"> 

BODY{test:expression(location.href='http://www.1t2t34t.cn/js/')} 

</style>

可以实现,但是仅兼容于IE。

而对于页面跳转我则推荐使用JS,用

window.location.href="url"

window.history.back(-1)

self.location='jb51.htm'

望采纳!

首先准备好几种风格的css文件:

样式部分:

<link id="css" rel="stylesheet" type="text/css" href="style.css"/>

js部分

function redCSS(){

document.getElementById("css").href="red.css"

}

html部分

<span onclick="redCSS">切换红色风格</span>

如果需要下次打开页面抱持这个风格,那么需要用到cookie

1、利用css的:hover

<div id="content">  

    这是原本的div层  

    <div id="show">  

        <p>这是鼠标移动上去后的div层</p>  

    </div>  

</div> 

<style type="text/css">  

        *{  

            margin: 0  

            padding: 0  

        }  

        #content{  

            background:#0CF  

            height:200px  

            width:200px  

            margin-left: 20px  

            margin-top: 20px  

        }  

        #show{  

            width:200px  

            height:200px  

            margin-top: 20px  

            background:#F09  

            top:0px  

            position:absolute  

            opacity: 0  

            display: block  

            font-size: 12px  

            transition: 0.3s  

            -webkit-transition: .5s  

            -moz-transition: .5s  

        }  

        #content:hover #show{  

            color: #656e73  

            opacity: 1  

        }  

    </style>