Skip to content

Instantly share code, notes, and snippets.

View kovtunos's full-sized avatar

Andrey Kovtun kovtunos

View GitHub Profile
@kovtunos
kovtunos / .htaccess
Last active September 29, 2017 14:19
Remove trailing slash #htaccess
RewriteBase /
# Remove trailing slash
RewriteRule ^(.*)/$ $1 [R=301,L]
@kovtunos
kovtunos / full-width.css
Last active February 28, 2018 19:04
Full width section inside fixed width container #css
/* Variant 1 */
.full-width {
margin-left: calc(-50vw + 50%);
margin-right: calc(-50vw + 50%);
}
/* Variant 2 */
.full-width {
width: 100vw;
margin-left: -50vw;
@kovtunos
kovtunos / drop_shadow.css
Last active September 29, 2017 14:19
Drop shadow on png image with alpha channel #css
filter: drop-shadow(5px 5px 5px #222);
@kovtunos
kovtunos / title-lines.scss
Last active September 29, 2017 14:23
Lines on both sides of title #sass
h1 {
overflow: hidden;
&::after,
&::before {
border-bottom: 4px solid black;
content: '';
display: inline-block;
height: .1em;
position: relative;
@kovtunos
kovtunos / slanting-section.html
Last active June 15, 2017 14:46
Slanting section #svg #html #css #sass
// HTML
<section>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" preserveAspectRatio="none" id="skew-top">
<polygon points="0,0 0,100 100,0"/>
</svg>
...
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" preserveAspectRatio="none" id="skew-bottom">
<polygon points="0,100 100,0 100,100"/>
</svg>
@kovtunos
kovtunos / views-ajax-scroll.php
Last active September 29, 2017 14:07 — forked from opi/gist:3247047
Prevent views_load_more to scroll #drupal #drupal7 #ajax
/**
* Implements hook_views_ajax_data_alter()
*/
function mymodule_views_ajax_data_alter(&$commands, $view) {
// Do not scroll when using views_load_more module
if ($view->query->pager->definition['handler'] == 'views_plugin_pager_load_more') {
foreach($commands as $k => $command) {
if ($command['command'] == 'viewsScrollTop') {
// Remove viewsScrollTop command
unset($commands[$k]);
@kovtunos
kovtunos / selected.js
Created September 29, 2017 10:12
Add class to selected form #jquery #form
// Add class to Selected form
$('select').on('change', function() {
if ($(this).val()) {
return $(this).addClass('is-selected');
} else {
return $(this).removeClass('is-selected');
}
});
@kovtunos
kovtunos / select-month.html
Created October 4, 2017 17:51
Select month #html
<select name="month" id="month">
<option selected disabled>Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
@kovtunos
kovtunos / credit-card.js
Created October 8, 2017 08:18
Simple credit card type detection on typing the first digit #jquery
$('#card_number').keyup(function(event) {
if (this.selectionStart == 1) {
if ($(this).val() == '4') {
$(this).parent().removeClass('is-mastercard').addClass('is-visa');
}
if ($(this).val() == '5') {
$(this).parent().removeClass('is-visa').addClass('is-mastercard');
}
}
@kovtunos
kovtunos / ol-counter.css
Last active October 9, 2017 17:48
Ordered lists with counter numeration like 1.1.1, 1.1.2 #css
ol {
list-style-type: none;
counter-reset: item;
margin: 0 0 15px;
padding: 0;
}
ol > li {
display: table;
counter-increment: item;