点击查看Vue编辑器说明文档

Less学习edit icon

|
|
Fork(复制)
|
|
作者:
军军-360

👉 新版编辑器已上线,点击进行体验吧!

BUG反馈
嵌入
设置
下载
<template>
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
            
            <!-- 示例代码 -->
<header id="header">{{ title }}</header>

<ul class="list">
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
</ul>

<div class="tag-box">
    <div class="tag tag_blue">tag_1</div>
    <div class="tag tag_green">tag_2</div>
    <div class="tag tag_red">tag_3</div>
</div>
        
<style>
格式化
            
            /* 示例代码 */
html,
body {
    margin: 0px;
    padding: 0px;
}

@width: 50vw;
@height: 100px;
@fontColor: #777;
@bgColor: #cef;
@borderColor: black;

.bordered {
    border-top: 1px solid @borderColor;
    border-bottom: 1px solid @borderColor;
}

#header {
    position: relative;
    width: @width;
    height: @height;
    background-color: @bgColor;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    margin: 10px;
    border-radius: 5px;
    .bordered();

    @btHeight: 10px;

    &:after {
        content: '';
        display: block;
        font-size: 0px;
        height: @btHeight;
        background-color: #0ef;
        width: 100%;
        position: absolute;
        bottom: -(@btHeight+1);
        border-radius: 5px;
    }
}

.list {
    list-style: none;
    margin: 0px;
    padding: 20px;
    background-color: #ecf;

    li {
        width: 55vw;
        margin: 3px 0px;
        @base: #f04615;

        .setBackgroundColor(@index) when (@index > 0) {
            &:nth-child(@{index}) {
                color: lighten(@base , (@index * 8%));
                background-color: darken(@base, (@index * 5%));
            }

            .setBackgroundColor(@index - 1);
        }

        .setBackgroundColor(10); // 假设最大10个li元素
    }
}

.tag-box {
    @tagColors: blue, green, red;

    .tag {
        display: inline-block;
        border-radius: 5px;
        padding: 5px 10px;
        font-size: 12px;
        color: white;
        line-height: 1;
        margin-right: 5px;
    }

    each(@tagColors, {
        .tag_@{value} {
            border: 1px solid @value;
            background-color: @value;
        }
    })
}
        
<script setup>
格式化
            
            // 示例代码
import { ref } from "vue"

const title = ref("Hello 笔.COOL");
const descr = ref("一笔一划,绘就人生;一码一境,酷创未来。");

        
预览
控制台