CSS未知属性“transform”

发布于 2025-01-02 16:38:21 字数 4236 浏览 0 评论 0原文

我的样式表遇到一些问题。我正在尝试做一些有趣的悬停效果,但不知何故我无法使用变换。有人可以帮助我吗?该错误发生在评论“查看一”下方。

HTML:

<html xmlns="http://www.w3.org/1999/xhtml">
    <link rel="stylesheet" href="stylesheets/style.css" type="text/css" media="screen" />
    <head>
        <title>thomasteilmann.dk</title>    
    </head>

    <body>
        <div class="header">
            <h1><img src="teilmann.jpg" alt="Sick Logo" /></a></h1>
            Copyright Thomas Teilmann
        </div>
        <div id="content">
            <div class="view view-first">
            <img src="images/cosmic_art_icon.jpg"/>
            <div class="mask">
                <h2>Cosmic Art</h2>
                <p>A galleri of cosmic art made in Photoshop</p>
                <a href="#" class="info">View</a>
            </div>
        </div>
    </body>
</html>

CSS:

body {
    background: #21211f;
    width: 902px;
    font-family: helvetica, arial, sans-serif;
    margin: 0 auto;
    padding: 40px 0 0 0;
}

.header{
    position: absolute;
    width: 185px;
}

h1 img{
    float: left;
    padding: 0;

    margin: 0;
}

#navbar ul {
    position: absolute;
    margin-left: 190px;
    padding: 5px;
    list-style-type: none;
    text-align: center;
    background-color: white;
    width: 692px;
    margin-top: 65px;
}

#navbar ul li {
    display: inline;
}

#navbar ul li a {
    text-decoration: none;
    padding: .2em 1em;
    font-family: Georgia, times, serif;
    color: black;
    background-color: white;
}

#navbar ul li a:hover {
    color: black;
    background-color: #fff;
}

#content{
    width: 612px;
    background: #466287 url(images/corner.jpg) top right no-repeat;
    line-height: 22px;
    font-size: 18px;
    font-family: Georgia, times, serif;
    margin: 0 0 10px 0;
    float: left;
    color: #ffffff;
    margin-left: 190px;
    margin-top: 100px;
    padding: 20px 60px 20px 30px;
}


img {
    border: none;
}

.form{
    margin: 15px 0;
    padding: 20px 0 20px 0;
    background: url(form1.jpg) no-repeat;
    font-family: helvetica, arial, sans-serif;
}


/*
 * View
*/

.view {
    width: 279px;
    height: 198px;
    margin: 10px;
    float: left;
    border: 5px solid white;
    overflow: hidden;
    position: relative;
    text-align: center;
    box-shadow: 1px 2px 2px #e6e6e6;
    cursor: default;
    background: #fff url(../images/bgimg.jpg) no-repeat center center;
}
.view .mask, .view .content {
    width: 279px;
    height: 198px;
    position: absolute;
    overflow: hidden;
    top: 0;
    left: 0;
}
.view img {
    display: block;
    position: relative;
}
.view h2 {
    text-transform: uppercase;
    color: #fff;
    text-align: center;
    position: relative;
    font-size: 17px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.8);
    margin: 20px 0 0 0;
}
.view p {
    font-family: Georgia, serif;
    font-style: italic;
    font-size: 12px;
    position: relative;
    color: #fff;
    padding: 10px 20px 20px;
    text-align: center;
}
.view a.info {
    display: inline-block;
    text-decoration: none;
    padding: 7px 14px;
    background: #000;
    color: #fff;
    text-transform: uppercase;
    box-shadow: 0 0 1px #000;
}
.view a.info:hover {
    box-shadow: 0 0 5px #000;
}


/* View one
*/

.view-first img {
    transition: all 0.2s linear;
}
.view-first .mask {
    opacity: 0;
    background-color: rgba(219,127,8, 0.7);
    transition: all 0.4s ease-in-out;
}
.view-first h2 {
    transform: translateY(-100px);
    opacity: 0;
    transition: all 0.2s ease-in-out;
}
.view-first p {
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.2s linear;
}
.view-first a.info{
    opacity: 0;
    transition: all 0.2s ease-in-out;
}

.view-first:hover img {
    transform: scale(1.1);
}
.view-first:hover .mask {
    opacity: 1;
}
.view-first:hover h2,
.view-first:hover p,
.view-first:hover a.info {
    opacity: 1;
    transform: translateY(0px);
}
.view-first:hover p {
    transition-delay: 0.1s;
}
.view-first:hover a.info {
    transition-delay: 0.2s;
}

I am having some problems with my stylesheet. I am trying to do some funny hover effects, but somehow I can't use transform. Can anyone help me? The error occurs down below the comment "view one".

HTML:

<html xmlns="http://www.w3.org/1999/xhtml">
    <link rel="stylesheet" href="stylesheets/style.css" type="text/css" media="screen" />
    <head>
        <title>thomasteilmann.dk</title>    
    </head>

    <body>
        <div class="header">
            <h1><img src="teilmann.jpg" alt="Sick Logo" /></a></h1>
            Copyright Thomas Teilmann
        </div>
        <div id="content">
            <div class="view view-first">
            <img src="images/cosmic_art_icon.jpg"/>
            <div class="mask">
                <h2>Cosmic Art</h2>
                <p>A galleri of cosmic art made in Photoshop</p>
                <a href="#" class="info">View</a>
            </div>
        </div>
    </body>
</html>

CSS:

body {
    background: #21211f;
    width: 902px;
    font-family: helvetica, arial, sans-serif;
    margin: 0 auto;
    padding: 40px 0 0 0;
}

.header{
    position: absolute;
    width: 185px;
}

h1 img{
    float: left;
    padding: 0;

    margin: 0;
}

#navbar ul {
    position: absolute;
    margin-left: 190px;
    padding: 5px;
    list-style-type: none;
    text-align: center;
    background-color: white;
    width: 692px;
    margin-top: 65px;
}

#navbar ul li {
    display: inline;
}

#navbar ul li a {
    text-decoration: none;
    padding: .2em 1em;
    font-family: Georgia, times, serif;
    color: black;
    background-color: white;
}

#navbar ul li a:hover {
    color: black;
    background-color: #fff;
}

#content{
    width: 612px;
    background: #466287 url(images/corner.jpg) top right no-repeat;
    line-height: 22px;
    font-size: 18px;
    font-family: Georgia, times, serif;
    margin: 0 0 10px 0;
    float: left;
    color: #ffffff;
    margin-left: 190px;
    margin-top: 100px;
    padding: 20px 60px 20px 30px;
}


img {
    border: none;
}

.form{
    margin: 15px 0;
    padding: 20px 0 20px 0;
    background: url(form1.jpg) no-repeat;
    font-family: helvetica, arial, sans-serif;
}


/*
 * View
*/

.view {
    width: 279px;
    height: 198px;
    margin: 10px;
    float: left;
    border: 5px solid white;
    overflow: hidden;
    position: relative;
    text-align: center;
    box-shadow: 1px 2px 2px #e6e6e6;
    cursor: default;
    background: #fff url(../images/bgimg.jpg) no-repeat center center;
}
.view .mask, .view .content {
    width: 279px;
    height: 198px;
    position: absolute;
    overflow: hidden;
    top: 0;
    left: 0;
}
.view img {
    display: block;
    position: relative;
}
.view h2 {
    text-transform: uppercase;
    color: #fff;
    text-align: center;
    position: relative;
    font-size: 17px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.8);
    margin: 20px 0 0 0;
}
.view p {
    font-family: Georgia, serif;
    font-style: italic;
    font-size: 12px;
    position: relative;
    color: #fff;
    padding: 10px 20px 20px;
    text-align: center;
}
.view a.info {
    display: inline-block;
    text-decoration: none;
    padding: 7px 14px;
    background: #000;
    color: #fff;
    text-transform: uppercase;
    box-shadow: 0 0 1px #000;
}
.view a.info:hover {
    box-shadow: 0 0 5px #000;
}


/* View one
*/

.view-first img {
    transition: all 0.2s linear;
}
.view-first .mask {
    opacity: 0;
    background-color: rgba(219,127,8, 0.7);
    transition: all 0.4s ease-in-out;
}
.view-first h2 {
    transform: translateY(-100px);
    opacity: 0;
    transition: all 0.2s ease-in-out;
}
.view-first p {
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.2s linear;
}
.view-first a.info{
    opacity: 0;
    transition: all 0.2s ease-in-out;
}

.view-first:hover img {
    transform: scale(1.1);
}
.view-first:hover .mask {
    opacity: 1;
}
.view-first:hover h2,
.view-first:hover p,
.view-first:hover a.info {
    opacity: 1;
    transform: translateY(0px);
}
.view-first:hover p {
    transition-delay: 0.1s;
}
.view-first:hover a.info {
    transition-delay: 0.2s;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苏别ゝ 2025-01-09 16:38:21

transform 还不是标准,因此目前没有浏览器支持它。

但是,某些浏览器支持基于草案的供应商扩展:

  • Internet Explorer 9 中的 -ms-transform
  • -moz-transform Mozilla 浏览器(尤其是 Firefox)
  • - Webkit 浏览器(Chrome、Safari 等)中的 webkit-transform
  • Opera 中的 -o-transform
  • 可能还有其他,我不知道。

transform isn't a standard yet, so no browser supports it at present.

However, some browsers support vendor extensions based on the draft:

  • -ms-transform in Internet Explorer 9
  • -moz-transform in Mozilla browsers (most notably Firefox)
  • -webkit-transform in Webkit browsers (Chrome, Safari, etc.)
  • -o-transform in Opera
  • Possibly others, I don't know.
沉鱼一梦 2025-01-09 16:38:21

只需在您的 css 代码中使用此 css。请记住,转换并非在所有浏览器中都有效。

.view-first:hover {
    transform: rotate(30deg);
 -ms-transform: rotate(30deg); /* IE 9 */
 -webkit-transform: rotate(30deg); /* Safari and Chrome */
 -o-transform: rotate(30deg); /* Opera */
 -moz-transform: rotate(30deg); /* Firefox */
}

just use this css inside your css code.Remember transform does not work in all browsers.

.view-first:hover {
    transform: rotate(30deg);
 -ms-transform: rotate(30deg); /* IE 9 */
 -webkit-transform: rotate(30deg); /* Safari and Chrome */
 -o-transform: rotate(30deg); /* Opera */
 -moz-transform: rotate(30deg); /* Firefox */
}
↘人皮目录ツ 2025-01-09 16:38:21

您可能需要使用供应商特定的过渡样式,例如:

#id_of_element {
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;

}

您可以在此处阅读有关过渡和转换的更多信息 - http ://css3.bradshawenterprises.com/

You'll probably need to use vendor specific styles for the transitions, for example:

#id_of_element {
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;

}

You can read more about transitions and transformations here - http://css3.bradshawenterprises.com/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文