在知识的海洋里奋力狗刨 2019-12-08 00:22 采纳率: 0%
浏览 427

内联样式和外联样式中的css代码一样,为什么页面刚打开的时候效果不一样?

以下是html中的代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="demo.css">
  <!-- 如果使用上面一行的外链样式表,页面刚打开的时候,就有动态效果 -->
  <!-- <style>同样的css代码写在这里,不会产生页面一打开就有动态效果的问题</style> -->
</head>
<body>
  <div class="box">
    <ul>
      <li>
        <div class="wrapper">
          <div>1</div>
          <p>2</p>
        </div>
      </li>
      <li>
        <div class="wrapper">
          <div>1</div>
          <p>2</p>
        </div>
      </li>
      <li>
        <div class="wrapper">
          <div>1</div>
          <p>2</p>
        </div>
      </li>
    </ul>
  </div>
</body>
</html>

然后以下是css代码:

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  list-style: none;
}
body {
  background-color: #fff;
}
.box {
  width: 630px;
  height: 200px;
  margin: 100px auto 0;
}
.box ul {
  width: 100%;
  height: 100%;
  list-style: none;
  text-align: center;
  line-height: 200px;
}
.box ul li {
  float: left;
  width: 200px;
  height: 100%;
  margin-right: 15px;
  perspective: 1500px;
  cursor: pointer;
}
.box ul li:last-of-type {
  margin-right: 0;
}
.box ul li .wrapper {
  width: 100%;
  height: 100%;
  transition: -webkit-transform 1.6s;
  position: relative;
  transform-style: preserve-3d;
}
.box ul li .wrapper div {
  width: 100%;
  height: 100%;
  border-radius: 5px;
  box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.3);
  background-color: blue;
  position: absolute;
  top: 0;
  transform: translateZ(100px);
  transition: all 1.6s;
}
.box ul li .wrapper p {
  width: 100%;
  height: 100%;
  border-radius: 15px;
  position: absolute;
  top: 0;
  box-shadow: none;
  background-color: gold;
  transform: rotateX(-90deg) translateZ(100px);
  transition: all 1.6s;
  text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.5);
}
.box ul li .wrapper:hover div {
  box-shadow: none;
  border-radius: 15px;
}
.box ul li .wrapper:hover p {
  box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.3);
  border-radius: 5px;
}
.box ul li:hover .wrapper {
  transform: rotateX(90deg);
}

  • 写回答

2条回答 默认 最新

  • 崽崽的谷雨 2019-12-09 17:18
    关注

    你指的是,刚进来如果是行内样式的话,会直接出效果,而外联则是有那么几毫秒才显示出效果吗?你值得不一样具体是什么?(优先级关系:内联样式 > ID 选择器 > 类选择器 = 属性选择器 = 伪类选择器 > 标签选择器 = 伪元素选择器

    )样式有权重

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?