Skip to content

Instantly share code, notes, and snippets.

View 2thecrow's full-sized avatar
🐋

Alexander Pletnev 2thecrow

🐋
View GitHub Profile
@2thecrow
2thecrow / visually-hidden.css
Last active February 28, 2023 20:50
hide html element
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
white-space: nowrap;
clip-path: inset(100%);
clip: rect(0 0 0 0);
@2thecrow
2thecrow / fast-reset.css
Last active March 9, 2023 15:22
Fast/min css reset
:root {
}
@media (prefers-reduced-motion: no-preference) {
:root {
scroll-behavior: smooth;
}
}
html {
-webkit-box-sizing: border-box;
@2thecrow
2thecrow / theme-switcher.js
Last active February 28, 2023 20:56
Simply theme switcher
// Get the theme toggle input
const currentTheme = localStorage.getItem("theme");// If the current local storage item can be found
// Function that will switch the theme based on the if the theme toggle is checked or not
function switchTheme() {
if (document.documentElement.getAttribute("data-theme") === "dark") {
document.documentElement.setAttribute("data-theme", "light");
// Set the user's theme preference to dark
localStorage.setItem("theme", "light");
} else {
@2thecrow
2thecrow / gradient-overlay-text.css
Last active February 28, 2023 20:56
How to add a gradient overlay to text with CSS
https://fossheim.io/writing/posts/css-text-gradient/
.gradient-text {
/* Fallback: Set a background color. */
background-color: red;
/* Create the gradient. */
background-image: linear-gradient(45deg, #f3ec78, #af4261);
/* Set the background size and repeat properties. */
@2thecrow
2thecrow / tabs.js
Created November 11, 2021 19:58
simple tabs JQ
$('.some__tab').click(function (e) {
e.preventDefault();
$('.some__tab').removeClass('some__tab--active');
$('.some__tab-content').removeClass('some__tab-content--active');
var href = $(this).attr('href');
$(this).addClass('some__tab--active');
$(href).addClass('some__tab-content--active');
});
@2thecrow
2thecrow / styles-list.css
Last active February 28, 2023 21:00
Styled list (ul) bullets
ul {
list-style: none; /* Remove default bullets */
}
ul li::before {
content: "\2022"; /* Add content: \2022 is the CSS Code/unicode for a bullet */
color: red; /* Change the color */
font-weight: bold; /* If you want it to be bold */
display: inline-block; /* Needed to add space between the bullet and the text */
width: 1em; /* Also needed for space (tweak if needed) */
@2thecrow
2thecrow / remove-action.css
Last active November 18, 2023 18:37
Remove actions on hover
.class {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
pointer-events: none;
}
@2thecrow
2thecrow / mobile-menu-actions.js
Last active February 28, 2023 21:02
Mobile menu
/* Hamburher menu */
const menu = document.querySelector('.mobile-menu'); /* Aside menu */
const burger = document.querySelector('.burger'); /* desktop btn aside menu */
const menuClose = document.querySelector('.mobile-menu__closebtn'); /* close btn for aside menu */
const overlay = document.querySelector('.overlay'); /* overlay for aside menu */
/* lock screen scroll */
const lockScroll = () => {
document.body.classList.add('lock');
}
@2thecrow
2thecrow / horizontal-line-decor.html
Last active February 28, 2023 21:02
Element decor with left/right horizontal line
<div class="mobile-login__or-decor">
<span>или</span>
</div>
@2thecrow
2thecrow / multi-swiperJS.js
Last active February 28, 2023 21:03
Many SwiperJS sliders on page
const sliders = document.querySelectorAll('.swiper-container');
sliders.forEach((el) => {
let swiper = new Swiper(el, {
slidesPerView: 3,
spaceBetween: 10,
loop: true,
pagination: {
el: el.querySelector('.swiper-pagination'),
clickable: true,