Skip to content

Instantly share code, notes, and snippets.

@ZeRRoCull
ZeRRoCull / display-transition.css
Created April 18, 2024 10:54
Display none transition
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
}
function forcedOriginalScale( containerId ) {
var App = document.getElementById( containerId );
App.style.zoom = 1 / devicePixelRatio;
}
document.addEventListener("DOMContentLoaded", () => {
forcedOriginalScale('main-wrapper'); //выполняем функцию, передаём в неё id нашего контейнера
});
@ZeRRoCull
ZeRRoCull / common.js
Created February 13, 2024 09:14
Как использовать в js, css-анимацию (CSS-animation => JS)
document.addEventListener("DOMContentLoaded", () => {
// ============================================================
const animation = document.querySelector('.wrapper__progress').getAnimations()[0]; //На этом элементе у нас стоит CSS-анимация, мы её получаем
const outputProgress = document.querySelector('.count-progress');
let curVal = 0;
const updateValue = () => {
if (animation && animation.currentTime) {
const newVal = animation.currentTime.value;
if (newVal != curVal) {
@ZeRRoCull
ZeRRoCull / picture.pug
Created February 6, 2024 08:46
Def picture
picture
source(srcset="img/main-bg-small.png 700w" media="(max-width: 768px)")
source(srcset="img/main-bg-laptop.png 990w" media="(max-width: 992px)")
img(src="img/main-bg-desktop-2.png" loading="lazy" decoding="async" alt)
@ZeRRoCull
ZeRRoCull / styles.css
Created February 4, 2024 10:57
Настройка переноса слова CSS, HTML
<div class="box">Электрообору&shy;дование</div>
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-family: Arial;
}
// $("#stars-default").rating(); // Вызов рейтинга
// Pug структура (пример)
// .acc-sect__form-rating#stars-default
// input(type="hidden", name="rating")
(function ($) {
$.fn.rating = function (method, options) {
method = method || "create";
@ZeRRoCull
ZeRRoCull / input-date.sass
Created December 3, 2023 20:12
Настройка иконки у input(type="date")
input[type=date]
&::-webkit-inner-spin-button, &::-webkit-calendar-picker-indicator
cursor: pointer
@ZeRRoCull
ZeRRoCull / line-clamp.sass
Created October 19, 2023 09:27
Line clamp (количество строк с троеточием)
.text
display: -moz-box
display: -webkit-box
-moz-box-orient: vertical
-webkit-box-orient: vertical
-moz-line-clamp: 2
-webkit-line-clamp: 2
overflow: hidden
@ZeRRoCull
ZeRRoCull / input_date_placeholder.txt
Created August 23, 2023 06:00
Input date placeholder
// sass пример
input(type="date" placeholder="с")
input::before
color: #999
content: attr(placeholder)
margin-right: 122px
input:focus::before
content: "" !important
@ZeRRoCull
ZeRRoCull / common.js
Created July 11, 2023 15:38
Активация пунктов навигации при скроле страницы вниз
let sections = document.querySelectorAll('.section');
let navLinks = document.querySelectorAll('.main-header__nav a');
window.onscroll = () => {
let header = document.querySelector('.main-header');
sections.forEach(sec => {
let top = window.scrollY;
let height = sec.offsetHeight