Skip to content

Instantly share code, notes, and snippets.

PHP:
<?php $background = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'full' ); ?>
HTML:
<div style="background-image: url('<?php echo $background[0]; ?>');">
// http://anton.shevchuk.name/javascript/jquery-for-beginners/
$(document).ready(function(){
$(".accordion h3:first").addClass("active");
$(".accordion p:not(:first)").hide();
$(".accordion h3").click(function(){
$(this).next("p").slideToggle("slow")
.siblings("p:visible").slideUp("slow");
$(this).toggleClass("active");
/* http://stackoverflow.com/questions/1464934/text-align-justify-and-images */
<style>
.justify-image{ text-align: justify;}
.justify-image img{display:inline-block;}
.justify-image:after{content:""; display: inline-block; width: 100%; height: 0;}
</style>
<p class="justify-image">
<img src="/path/img.jpg" alt="my image">
<img src="/path/img.jpg" alt="my image">
function browser() {
var ua = navigator.userAgent;
if (ua.search(/MSIE/) != -1) return 'Internet Explorer';
if (ua.search(/Firefox/) != -1) return 'Firefox';
if (ua.search(/Opera/) != -1) return 'Opera';
if (ua.search(/Chrome/) != -1) return 'Google Chrome';
if (ua.search(/Safari/) != -1) return 'Safari';
if (ua.search(/Konqueror/) != -1) return 'Konqueror';
if (ua.search(/Iceweasel/) != -1) return 'Debian Iceweasel';
function os() {
var os = 0;
if (navigator.userAgent.indexOf('Windows') != -1) return 'Windows';
if (navigator.userAgent.indexOf('Linux') != -1) return 'Linux';
if (navigator.userAgent.indexOf('Mac') != -1) return 'Mac';
if (navigator.userAgent.indexOf('FreeBSD') != -1) return 'FreeBSD';
}
@oleksapro
oleksapro / toggle
Last active August 29, 2015 14:27
as jquery
$('a').click(function() {
var clicks = $(this).data('clicks');
if (clicks) {
alert('odd number of clicks');
} else {
alert('even number of clicks');
}
$(this).data("clicks", !clicks);
});
@oleksapro
oleksapro / divs justify
Last active September 9, 2015 14:21
css
http://jsfiddle.net/thirtydot/EDp8R/
#container {
border: 2px dashed #444;
height: 125px;
text-align: justify;
/* just for demo */
min-width: 612px;
}
@oleksapro
oleksapro / gotoSlide
Created August 14, 2015 13:34
bx-slider
$('.active-ads-campaign__format__item').click(function(e) {
e.preventDefault();
var $this = $(this);
var currentSlide;
sliderTwo.goToSlide($this.data('format'));
currentSlide = sliderTwo.getCurrentSlide();
$this.addClass('active')
.siblings('.active-ads-campaign__format__item').removeClass('active');
});
http://bavotasan.com/2011/style-select-box-using-only-css/
<select name="timepass" class="fast-approval__select">
<option>Суточная посещаемость Вашего сайта</option>
<option>Driving</option>
<option>Internet</option>
<option>Movie</option>
<option>Music</option>
<option>Reading</option>
<option>Sports</option>
</select>
// http://stackoverflow.com/questions/4917664/detect-viewport-orientation-if-orientation-is-portrait-display-alert-message-ad
if(window.innerHeight > window.innerWidth){
alert("Please use Landscape!");
}