#back {
background-size: cover;
background: url(mainSpidey.jpg) no-repeat 100% 0;
}
background-image
background-position
background-size
background-repeat
background-origin
background-clip
background-attachment
background-color
#back {
background: url(mainSpidey.jpg) no-repeat 100% 0 / cover;
}
#back {
background: url(mainSpidey.jpg) no-repeat 100% 0;
background-size: cover;
}
// Для главной страницы
if(/^\/$/g.test(location.pathname)) {
document.addEventListener("DOMContentLoaded", function(){
var b = document.querySelector('.circle_wrap')
if (b) b.classList.add('animation'); // Проверка все равно будет не лишней
}, false);
}
// Для страницы contacts.html
if (/^\/contacts\.html$/g.test(location.pathname)) {
document.addEventListener("DOMContentLoaded", function(){
var b = document.querySelector('.circle_wrap')
if (b) b.classList.add('animation');
}, false);
}
// Так тоже будет работать без ошибок на любой странице,
// где есть соответствующий элемент
document.addEventListener("DOMContentLoaded", function(){
var b = document.querySelector('.circle_wrap')
if (b) b.classList.add('animation');
}, false);
bower init
bower install --save jquery owl.carousel
<div id="someId">
<!-- COMMENT One-->
<!-- COMMENT Two -->
<!-- {"json": true} -->
</div>
<output></output>
let out = document.querySelector('output');
let el = document.querySelector('#someId');
for (let i = 0; i < el.childNodes.length; i++) {
let child = el.childNodes[i];
if (child.nodeType == 8) {
console.log(child.textContent);
out.innerHTML += ' <br> ' + child.textContent;
}
}
<div class="filters">
<button class="filter" data-filter="isSport">Sport</button>
<button class="filter" data-filter="isFood">Food</button>
<button class="filter" data-filter="isWears">Wears</button>
</div>
<div class="wrapper">
<div class="link link_visible isSport">SPORT</div>
<div class="link link_visible isSport">SPORT</div>
<div class="link link_visible isSport">SPORT</div>
<div class="link link_visible isFood">FOOD</div>
<div class="link link_visible isFood">FOOD</div>
<div class="link link_visible isFood">FOOD</div>
<div class="link link_visible isWears">WEARS</div>
<div class="link link_visible isWears">WEARS</div>
<div class="link link_visible isWears">WEARS</div>
</div>
let filters = document.querySelector('.filters');
let filterButtons = filters.querySelectorAll('.filter');
let wrapper = document.querySelector('.wrapper');
let links = wrapper.querySelectorAll('.link');
filters.addEventListener('click', e => {
if (e.target.dataset.filter) {
if (e.target.classList.contains('filter_active')) {
e.target.classList.remove('filter_active');
links.forEach(item => item.classList.add('link_visible'));
} else {
filterButtons.forEach(btn => btn.classList.remove('filter_active'));
e.target.classList.add('filter_active');
links.forEach(item => {
item.classList.toggle(
'link_visible',
item.classList.contains(e.target.dataset.filter)
);
});
}
}
});
var promise = new Promise(function(resolve, reject) {
console.log('I\'m promise');
resolve('resolve');
});
for (var i=0; i<10000; i++) {
console.log(1);
}
promise.then( function (result) {
console.log(result);
return 'f1';
});
promise.then( function (result) {
console.log(result);
return 'f2';
});
I'm promise
(10000 раз) 1
resolve
resolve
hp
), высоту окна (hw
)smax = hp - hw
и минимальный smin = 0
hmax
) и конечный (hmin
) размеры целевого элементаs
)ds = smax - smin = smax
dh = hmax - hmin
s / ds = h / dh , где h - приращение высоты целевого элемента
h = hmax - (dh * s) / ds
h = (dh * s) / ds + hmin
var element = document.getElementById('d');
var hp = document.body.scrollHeight,
hw = window.innerHeight,
smax = hp - hw,
smin = 0,
hmin = 100,
hmax = 300,
ds = smax - smin,
dh = hmax - hmin;
window.addEventListener('scroll', function () {
var s = window.pageYOffset; // current scrollTop
var h = hmax - (dh * s) / ds;
element.style.height = h + 'px';
});
var element = document.getElementById('d');
var hmin = 100,
hmax = 300;
window.addEventListener('scroll', function () {
var s = window.pageYOffset; // current scrollTop
var h = hmax - ((hmax - hmin) * s) / (document.body.scrollHeight - window.innerHeight);
element.style.height = h + 'px';
});