我正在使用Compass(一个CSS框架)来生成精灵图像.它工作,但指南针只为每个图像生成一个背景位置.
是否有可能获得精灵中每个图像的宽度和高度?
这是我的代码:
@import "ico/*.png";
@include all-ico-sprites;
Run Code Online (Sandbox Code Playgroud)
生成的代码:
.ico-sprite, .ico-bag-blue, .ico-bag-black {
background: url('../images/ico-s78b1a1919b.png') no-repeat;
}
.ico-bag-blue {
background-position: 0 0;
}
.ico-bag-black {
background-position: 0 -24px;
}
Run Code Online (Sandbox Code Playgroud)
我想要的代码:
.ico-sprite, .ico-bag-blue, .ico-bag-black {
background: url('../images/ico-s78b1a1919b.png') no-repeat;
}
.ico-bag-blue {
background-position: 0 0;
width:40px;
height:24px;
}
.ico-bag-black {
background-position: 0 -24px;
width:44px;
height:30px;
}
Run Code Online (Sandbox Code Playgroud)
谁能向我解释我怎么能这样做?谢谢.
像使用Compass的SASS(在SCSS文件中),是否有一种方法(通过扩展或工具)直接从.Less管理Sprite?
我有一个 Nestjs 应用程序(一个 Rest API),我想在另一个节点模块中导入它,作为一个简单的 Express 中间件(不是 Nest 中间件)。实际上,我仍然无法使其正常工作。
// main.ts
// => The main file of my Nest app, this one is working properly.
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
Run Code Online (Sandbox Code Playgroud)
// app.middleware.ts
import {Injectable, NestMiddleware} from '@nestjs/common';
import {NestFactory} from '@nestjs/core';
import {AppModule} from './app.module';
import {ExpressAdapter} from '@nestjs/platform-express';
import express, {Request, Response} from 'express';
const bootstrap = async () …Run Code Online (Sandbox Code Playgroud) 从这段代码:
HTML
<div class="test"></div>
Run Code Online (Sandbox Code Playgroud)
CSS
.test {
background-color:red;
font-size:20px;
-custom-data1: value 1;
-custom-data2: 150;
-custom-css-information: "lorem ipsum";
}
Run Code Online (Sandbox Code Playgroud)
使用javascript - 例如来自a $('.test')- 如何获得具有以前缀"-custom-"开头的属性名称的CSS属性列表?(它们可以有各种名称,但总是相同的前缀)
我想得到这个:
{
customData1: "value 1",
customData2: 150,
customCssInformation: "lorem ipsum"
}
Run Code Online (Sandbox Code Playgroud)
我知道我也可以使用data-HTML属性,但出于一些非常具体的原因,我需要使用CSS等价物.谢谢你的帮助.
在JavaScript中,这个正则表达式很容易匹配字母和重音:
text.match(/[a-z\u00E0-\u00FC]+/i);
Run Code Online (Sandbox Code Playgroud)
并且只有小写字母和重音符没有i选项:
text.match(/[a-z\u00E0-\u00FC]+/);
Run Code Online (Sandbox Code Playgroud)
但是正确的正则表达式只匹配大写字母和重音符号是什么?
编辑:就像下面已经提到的答案一样,上面的正则表达式也匹配其他一些标志,并且错过了一些特殊的重音字符,如ý和Ý,ć和Ć等等.
如何从PowerShell中的特定.png文件获取详细信息?
像尺寸,钻头深度和尺寸.
我有这个嵌套的对象数组:
var tree = [
{
name: "item 1",
link: "#link-1",
children: [
{
name: "item 1.1",
link: "#link-11",
children: [
{
name: "item 1.1.1",
link: "#link-111",
children: []
}
]
},
{
name: "item 1.2",
link: "#link-12",
children: []
}
]
},
{
name: "item 2",
children: []
}
];
Run Code Online (Sandbox Code Playgroud)
我想ul li从这个模型生成一个HTML 树结构.
我找到的唯一解决方案就在下面(通过递归函数).但我想避免字符串连接,因为在我的实际情况中,我有更多的标记要添加到每一行li(这真的不方便).
<%
var markup = '';
function htmlTreeBuilder(items) {
if (items.length) {
markup += '<ul>';
}
for (var i = 0; i …Run Code Online (Sandbox Code Playgroud) 我有 2 张桌子,lists并且items. 列表可以有 0 个或多个项目。一项仅在一个列表中。
export class List {
@OneToMany(() => Item, (item) => item.list, {
nullable: true,
})
items: Item[];
}
export class Item {
@ManyToOne(() => List, (list) => list.items)
list: List;
}
Run Code Online (Sandbox Code Playgroud)
list包含0项的对象?我的下面的代码返回错误:“where 子句”中的未知列“list.items”。
const listsWithoutItems = await this.listsRepository
.createQueryBuilder('list')
.where('list.item IS NULL')
.getMany();
Run Code Online (Sandbox Code Playgroud) 我有一个colors表和一个items表,这两个表之间存在多对多items_colors关系(通过表)。一个项目可以有多种颜色,一种颜色可以有很多项目。并且没有重复的颜色。
items
id
colors
id
name
items_colors
item_id [foreign key: items(id)]
color_id [foreign key: colors(id)]
Run Code Online (Sandbox Code Playgroud)
例如,我想获取所有具有蓝色 和红色的项目(如果它有另一种颜色或只有两种颜色之一,则必须忽略它)。
我仍然无法得到它......例如,下面的查询返回太多项目(例如,除了蓝色和红色之外还有其他颜色的项目)。
items
id
colors
id
name
items_colors
item_id [foreign key: items(id)]
color_id [foreign key: colors(id)]
Run Code Online (Sandbox Code Playgroud)
这是解决我的问题的小提琴:https://dbfiddle.uk/?rdbms= postgres_13&fiddle=9de03c642da5b018d6f20b44bcf91876
我正在使用Nestjs (7.x) 和Fastify(带有@nestjs/platform-fastify)。我正在尝试在我的项目 ( ) 中安装Helmetfastify-helmet,但我无法弄清楚如何将其与 Nestjs 集成/配置。将其带上飞机的正确方法是什么?
这是我的 Nestjs 引导程序:
import { NestFactory } from '@nestjs/core';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import { MainModule } from './main.module';
import * as helmet from 'fastify-helmet';
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(MainModule);
await app.listen(3000, 0.0.0.0);
}
bootstrap();
Run Code Online (Sandbox Code Playgroud) javascript ×4
css ×3
css-sprites ×2
nestjs ×2
sass ×2
compass-sass ×1
ejs ×1
express ×1
fastify ×1
helmet.js ×1
html ×1
jquery ×1
less ×1
many-to-many ×1
middleware ×1
mysql ×1
png ×1
postgresql ×1
powershell ×1
regex ×1
sql ×1
typeorm ×1
typescript ×1