更改字体和效果

时间:2017-09-03 08:44:11

标签: javascript html css

这是我当前HTML的外观:

<div class="model-selection">
    <span id="model-selection-error-value"></span>
    <span id="model-selection-value"></span>
</div>

这就是我目前的CSS外观:

#model-selection-value
{
    color: blue;
}

文本由脚本生成(意味着文本各不相同),但截至目前,代码创建了带蓝色文本的标准字体。

<script>
var $errorDiv = $('#model-selection-error-value');
var $selectionDiv = $('#model-selection-value');
.........

这就是我想要实现的目标:

https://codepen.io/nw/pen/jhKtk

我以为我可能只会将CSS复制/粘贴到我的中,对吗?我应该做些什么调整来使这项工作?

EDIT。这就是我现在所拥有的:(应该是正确的吗?)

<div class="model-selection">
    <span id="model-selection-error-value"></span>
    <div class="logo"><span id="model-selection-value"></span></div>
</div>

CSS

.model-selection
{
    position:         absolute;
    top:              0;
    left:             0;
    z-index:          5;
    margin:           0.3em;
    padding:          0.3em;
    font-size:        2em;
    font-family:      sans-serif;
    background-color: rgba(255, 255, 255, 0.85);
    border-radius:    8px;
}

#model-selection-error-value
{
    color: red;
}

#model-selection-value
{
    color: blue;
}

.logo {
  margin: 50px auto;
  text-align: center;
}
.logo span {
  text-decoration: none;
  -webkit-transform: perspective(2.5em) rotateX(15deg) scaleY(0.8);
  -moz-transform: perspective(2.5em) rotateX(15deg) scaleY(0.8);
  -ms-transform: perspective(2.5em) rotateX(15deg) scaleY(0.8);
  -o-transform: perspective(2.5em) rotateX(15deg) scaleY(0.8);
  transform: perspective(2.5em) rotateX(15deg) scaleY(0.8);
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
  transition: all 0.5s;
  display: inline-block;
  text-align: center;
  text-transform: uppercase;
  font-size: 75px;
  font-weight: 700;
  font-family: 'Exo 2';
  line-height: 0.8;
  color: #fbd62a;
  text-shadow: 0 -1px 15px rgba(0, 0, 0, 0.9), 0 1px 0 #7f6303, 0 3px 0 #846703, 0 5px 0 #896b03, 0 7px 0 #8e6f03, 0 9px 0 #937203, 0 6px 50px rgba(252, 223, 92, 0.8);
}
.logo span:first-line {
  font-size: 0.8em;
}
.logo span:hover {
  -webkit-transform: perspective(8em) rotateX(11deg) scale(1.2);
  -moz-transform: perspective(8em) rotateX(11deg) scale(1.2);
  -ms-transform: perspective(8em) rotateX(11deg) scale(1.2);
  -o-transform: perspective(8em) rotateX(11deg) scale(1.2);
  transform: perspective(8em) rotateX(11deg) scale(1.2);
  text-shadow: 0 -1px 15px black, 0 1px 0 #7f6303, 0 2px 0 #846703, 0 0px 0 #896b03, 0 1px 0 #8e6f03, 0 2px 0 #937203, 0 2px 30px rgba(252, 223, 92, 0.6);
}

1 个答案:

答案 0 :(得分:2)

检查出来:

&#13;
&#13;
var $error = $('#model-selection-error-value');
var $selection = $('#model-selection-value');

var i = 0;
setInterval(function() {
	$selection.text(++i);
}, 150);
setInterval(function() {
	$error.text(i / 2);
}, 300);
&#13;
body {
  background-color: #02111b;
}

.container {
  margin: 40px auto;
  text-align: center;
}
.container span {
  margin-bottom: 35px;
  text-decoration: none;
  -webkit-transform: perspective(2.5em) rotateX(15deg) scaleY(0.8);
  -moz-transform: perspective(2.5em) rotateX(15deg) scaleY(0.8);
  -ms-transform: perspective(2.5em) rotateX(15deg) scaleY(0.8);
  -o-transform: perspective(2.5em) rotateX(15deg) scaleY(0.8);
  transform: perspective(2.5em) rotateX(15deg) scaleY(0.8);
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
  transition: all 0.5s;
  display: inline-block;
  text-align: center;
  text-transform: uppercase;
  font-size: 75px;
  font-weight: 700;
  font-family: 'Exo 2';
  line-height: 0.8;
  color: #fbd62a;
  text-shadow: 0 -1px 15px rgba(0, 0, 0, 0.9), 0 1px 0 #7f6303, 0 3px 0 #846703, 0 5px 0 #896b03, 0 7px 0 #8e6f03, 0 9px 0 #937203, 0 6px 50px rgba(252, 223, 92, 0.8);
}
.container span:first-line {
  font-size: 0.8em;
}
.container span:hover {
  -webkit-transform: perspective(8em) rotateX(11deg) scale(1.2);
  -moz-transform: perspective(8em) rotateX(11deg) scale(1.2);
  -ms-transform: perspective(8em) rotateX(11deg) scale(1.2);
  -o-transform: perspective(8em) rotateX(11deg) scale(1.2);
  transform: perspective(8em) rotateX(11deg) scale(1.2);
  text-shadow: 0 -1px 15px black, 0 1px 0 #7f6303, 0 2px 0 #846703, 0 0px 0 #896b03, 0 1px 0 #8e6f03, 0 2px 0 #937203, 0 2px 30px rgba(252, 223, 92, 0.6);
  cursor: pointer;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="model-selection container">
    <span id="model-selection-error-value"></span><br />
    <span id="model-selection-value"></span>
</div>
&#13;
&#13;
&#13;