feat: css变量与scss变量
parent
5705d1fcf9
commit
9ead405340
@ -0,0 +1,57 @@
|
|||||||
|
<template>
|
||||||
|
<div id="container">
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="markdown-body"
|
||||||
|
v-html="htmlStr"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, onMounted } from 'vue';
|
||||||
|
import { marked } from 'marked';
|
||||||
|
import { getMarkdownContent } from '@/utils/tools';
|
||||||
|
|
||||||
|
const htmlStr = ref('');
|
||||||
|
|
||||||
|
getMarkdownContent('./md/cssVariable.md').then((res) => {
|
||||||
|
htmlStr.value = marked(res);
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const container = document.querySelector('#container');
|
||||||
|
container.style.setProperty('--w', container.clientWidth + 'px');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
#container {
|
||||||
|
width: 80%;
|
||||||
|
height: 200px;
|
||||||
|
border: 1px solid #333;
|
||||||
|
margin: 0 auto;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container div {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
background-color: red;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-top: 50px;
|
||||||
|
animation: move 3s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes move {
|
||||||
|
0% {
|
||||||
|
transform: translate(0, 0);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translate(calc(var(--w) - 100%), 0);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: translate(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in New Issue