Git Product home page Git Product logo

jspractice's Introduction

JsPractice

📇 🎃 🍺 🍥 :octocat:
clock:☆ GreedySnake:★☆ TicTacToe:★ calculator:★ WeatherApp:★☆
JavaScript30:★☆ Minesweeper:★ ToDoList:★

clock : ☆

知识点:

  • 1、html自定义属性data-name=value,以data-开头
<div class="hand hour" data-hour-hand></div>
  • 2、css自定义变量--name:value,以--开头
.clock .number {
    /* css自定义变量:--name:value */
    --rotation: 0;
    position: absolute;
    width: 100%;
    height: 100%;
    text-align: center;
    /* 使用var引用变量 */
    transform: rotate(var(--rotation));
    font-size: 1.5rem;
}

运行效果


GreedySnake : ★☆

知识点:

  • 1、grid布局
#game-board {
    background-color: #ccc;
    width: 100vmin;
    height: 100vmin;
    display: grid;
    /* 定义大小为21*21 */
    grid-template-columns: repeat(21, 1fr);
    grid-template-rows: repeat(21, 1fr);
}

运行效果


TicTacToe : ★

知识点:

  • 1、::after与::before以及not选择器的使用
.cell.x::before,
.cell.x::after,
/* 不是x类也不是circle类才会应用此属性 */
.board.x .cell:not(.x):not(.circle):hover::before,
.board.x .cell:not(.x):not(.circle):hover::after {
    content: "";
    position: absolute;
    width: calc(var(--mark-size) * .15);
    height: var(--mark-size);
}

运行效果


一个简易计算器

运行效果


WeatherApp : ★☆

知识点:

  • api的使用
fetchWeather(city) {
    fetch(`http://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${this.key}&units=metric`)
    .then(response => response.json())
    .then(data => this.displayWeather(data))
}

API

获取天气 获取天气图片 具体使用见代码line17 line29

运行效果


JavaScript30 : ★☆

实现了部分JavaScript30上的代码

知识点:

  • audio标签
<audio src="./sounds/tink.wav" data-key="76"></audio>
  • classList.toggole
const panels = document.querySelectorAll('.panel')
panels.forEach(panel => panel.addEventListener('click', e=>{
    // toggle:The toggle() method of the DOMTokenList interface 
    // removes a given token from the list and returns false. 
    // If token doesn't exist it's added and the function returns true.
    panel.classList.toggle('open')
}))
  • js修改css变量
const suffix = this.dataset.sizing || ''
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix)

运行效果

DrumKit

FlexPanelsImageGallery

FlexPanelsImageGallery


运行效果


ToDoList : ★

运行效果

jspractice's People

Contributors

nu11able avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.