Graphic trouble in MS Edge - css

I'm developing a site that actively uses CSS3 transitions and flexbox-based layout. It works well in Chrome, Firefox, iPad 2 (Safari) and even in Windows Phone 8.1 (not sure which version of IE is in there). But in Edge I see some strange visual glitches, what seems to appear on hover state.
So here is what I get in every modern browser (except Edge, obviously):
And this is what get in Edge:
As you can see, it's totally messed up. And also there is another window right to the Edge window, and Edge somehow bring this "trouble" to another window. Moreover, I was not able to screenshot this (Edge repaints window right before shooting) so I've captured it on photo. This is not the only buggy place, it happens everywhere with CSS transitions, independetly what and for how long it animates. And every trouble is unique, I can't catch some pattern and realize what's the problem.
At first it seems like graphic driver or hardware issues, but it's a new computer (by "new" I mean 3-days-old) with new hardware and clean Windows 10 with every update installed, and I can't see anything like this bug on any other site in Edge or in any other browser or application.
Is it common or only I'm so lucky? And what can I do, except to remove any animation in Edge? My GPU is Intel HD 530, BTW.
upd: I'm sorry, I forgot to include this:
function calcTooltips() {
$('.photo').hide().show(0);
if ( $(window).innerWidth() >= 769 ) {
$('.tt-center').each(function() {
var index = $(this).data('tooltip');
var pPos = $(this).position();
var pWidth = $(this).outerWidth();
var pHeight = $(this).outerHeight();
$('.tooltip.tt[data-tooltip="' + index + '"]').css({
width: pWidth + 'px',
top: $('body').scrollTop() + pPos.top + pHeight + 'px',
left: pPos.left + 'px'
});
});
$('.tt-left').each(function() {
var index = $(this).data('tooltip');
var pPos = $(this).position();
var pWidth = $(this).outerWidth();
var pHeight = $(this).outerHeight();
$('.tooltip.tt[data-tooltip="' + index + '"]').css({
width: pWidth * 2 + 'px',
top: $('body').scrollTop() + pPos.top + pHeight + 'px',
left: pPos.left + 'px'
});
});
$('.tt-right').each(function() {
var index = $(this).data('tooltip');
var pPos = $(this).position();
var pWidth = $(this).outerWidth();
var pHeight = $(this).outerHeight();
$('.tooltip.tt[data-tooltip="' + index + '"]').css({
width: pWidth * 2 + 'px',
top: $('body').scrollTop() + pPos.top + pHeight + 'px',
left: pPos.left - pWidth + 'px'
});
});
}
}
function initTooltips() {
$(window).load(calcTooltips);
$(window).resize(calcTooltips);
$(window).scroll(calcTooltips);
$('.tt-trigger').hover(function() {
var index = $(this).data('tooltip');
$('.tooltip.tt[data-tooltip="' + index + '"]').finish().fadeIn('fast');
}, function() {
var index = $(this).data('tooltip');
$('.tooltip.tt[data-tooltip="' + index + '"]').fadeOut('fast');
});
}
function initMobileMenu() {
$(window).resize(function() {
if ( $(window).width() >= 961 ) {
$('#mobile-menu').hide();
$('main').removeClass('blurred');
$('footer').removeClass('blurred');
}
});
$('.toggle-button').click(function() {
$('#mobile-menu').toggle('slide', {}, 'fast');
$('main').toggleClass('blurred');
$('footer').toggleClass('blurred');
$('body').toggleClass('noscroll');
});
}
var didScroll;
var lastScrollTop = 0;
var delta = 50;
var navbarHeight = $('#classic-menu').outerHeight();
function hasScrolled() {
if ( $(window).innerWidth() >= 769 ) {
var st = $(this).scrollTop();
if(Math.abs(lastScrollTop - st) <= delta)
return;
if (st > lastScrollTop && st > navbarHeight) {
$('#classic-menu').removeClass('nav-down').addClass('nav-up');
$('.tooltip.tt').hide();
} else {
if(st + $(window).height() < $(document).height()) {
$('#classic-menu').removeClass('nav-up').addClass('nav-down');
}
}
lastScrollTop = st;
}
}
function initScroll() {
$(window).scroll(function(event){
didScroll = true;
});
$(window).resize(function(event){
$('#classic-menu').removeClass('nav-up').addClass('nav-down');
});
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
}
var activeSlide = '';
function initSlides() {
$('.slide').click(function() {
if ( !$(this).hasClass('active') ) {
$('.slide.active').removeClass('active');
$(this).toggleClass('active');
activeSlide = $(this).data('slide');
}
});
}
var formRegexps = {
'name': /^.{2,}$/,
'address': /^.{6,}$/,
'email': /^\w+([\.\w]+)*\w#\w((\.\w)*\w+)*\.\w{2,3}$/,
'tel': /^\+7 \([0-9]{3}\) [0-9]{3} [0-9]{2}-[0-9]{2}$/
}
var formReturns = {
'name': false,
'address': false,
'email': false,
'tel': false
}
function formValidate() {
var isValid = true;
$.each(formRegexps, function(key, value) {
var exp = new RegExp(formRegexps[key]);
formReturns[key] = exp.test($('#' + key).val());
if (!formReturns[key]) { isValid = false }
});
return isValid;
}
function formShowErrors() {
$.each(formReturns, function(key, value) {
if (!formReturns[key]) {
$('.' + key + '-message').show();
}
});
$('.check-message.overall-message').show();
}
function formHideErrors() {
$.each(formReturns, function(key, value) {
$('.' + key + '-message').hide();
});
$('.check-message.overall-message').hide();
$('#classic-menu').removeClass('nav-up').addClass('nav-down');
}
function initFormCheck() {
$('form').submit(function (evt) {
formHideErrors();
if ( formValidate() == true ) {
evt.preventDefault(); // DELETE THIS LATER
} else {
evt.preventDefault();
formShowErrors();
}
});
}
function initPhoneInput() {
$('#tel').mask('+7 (999) 999 99-99');
}
$(function() {
initTooltips();
initMobileMenu();
initScroll();
initSlides();
initFormCheck();
initPhoneInput();
});
/* Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
a {
background: inherit;
color: inherit;
text-decoration: none;
}
ul {
list-style-type: none;
}
input,
select,
button {
outline: none;
}
img,
button,
.button,
.column h1,
.column h2,
.column h3,
.slide h1,
.slide h2,
.slide h3 {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Colors */
/* Shadows */
/* Borders */
/* Typography */
body,
input,
button {
font-family: 'Roboto', sans-serif;
}
p {
font-size: 17px;
}
/* Media Queries */
/* Base Layout */
html {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
body,
header,
main,
nav,
footer,
.layout,
.column,
.container,
.links,
.header-content,
.flex,
.full-flex .splash-link-inner {
display: flex;
}
#media (max-width: 960px) {
body,
main,
footer {
transition: -webkit-filter 0.3s, -moz-filter 0.3s, filter 0.3s;
}
}
body {
flex-flow: column;
min-height: 100vh;
background: url('../assets/images/temp-bg.jpg') fixed;
background-size: cover;
}
main {
flex: 1 0 auto;
align-self: center;
margin: 87px 0 0 0;
padding: 1rem 0 0 0;
justify-content: center;
align-items: flex-start;
width: 100%;
}
#media (max-width: 960px) {
main {
margin: 0;
padding: 4rem 0 0 0;
}
}
p {
margin: 1rem;
}
.photo {
width: 100%;
}
/* Containers */
.main.container {
flex-flow: column;
background: rgba(0, 0, 0, 0.8);
color: #F7F7F7;
padding: 1rem 1rem 0 1rem;
margin: 0 0 1rem 0;
width: 100%;
max-width: 960px;
}
.main.container.narrow {
max-width: 640px;
}
/* Header */
header {
z-index: 101;
flex-shrink: 0;
justify-content: center;
align-items: center;
background: rgba(0, 0, 0, 0.8);
border-bottom: 1px solid #F7F7F7;
position: fixed;
top: 0;
width: 100%;
transition: top 0.2s;
}
.header-content {
justify-content: space-around;
flex: 1;
padding: 0 .5rem;
}
/* Footer */
footer {
z-index: 100;
width: 100%;
height: auto;
min-height: 1.4rem;
padding: 1rem 0;
justify-content: flex-end;
background: rgba(0, 0, 0, 0.6);
color: #F7F7F7;
}
#media (max-width: 768px) {
footer {
flex-flow: column;
align-items: center;
}
}
footer .links {
min-height: 1.4rem;
}
#media (max-width: 768px) {
footer .links {
padding-right: 1rem;
}
}
footer .links a {
margin: 0 1rem;
}
#media (max-width: 540px) {
footer .links a {
margin-left: 0;
margin-right: .5rem;
}
}
#media (max-width: 768px) {
footer .links a.last-link {
margin-right: 0;
}
}
footer .links a:hover {
opacity: 1;
border-bottom: 2px dashed #FFF;
}
#media (max-width: 768px) {
footer .links,
footer .copyright {
margin: 0;
padding: 0;
}
}
footer .phone {
margin: 0 1rem;
}
#media (max-width: 768px) {
footer .phone {
display: none;
}
}
footer .phone:hover {
opacity: 1;
}
footer .copyright,
footer .links a,
footer .phone {
opacity: 0.8;
}
/* Horizontal Divider */
hr {
border-color: #F7F7F7;
}
/* Links */
.splash-link,
.nav-link-container {
transition: .3s;
}
/* Buttons */
.button {
display: block;
padding: 0 1rem;
line-height: 2rem;
transition: .2s;
border: 0;
cursor: pointer;
font-size: 16px;
}
.button i {
margin-right: .5rem;
}
.button.accent {
background: #F7F7F7;
color: #303030;
}
.button.accent:hover,
.button.accent:active {
background: #dedede;
}
.action {
background: #FF530D;
color: #F7F7F7;
}
.action:focus {
background: #FF530D;
color: #F7F7F7;
}
.action:hover,
.action:active {
background: #d93f00;
}
.positive {
background: #1ABC9C;
color: #F7F7F7;
}
.positive:focus {
background: #1ABC9C;
color: #F7F7F7;
}
.positive:hover,
.positive:active {
background: #148f77;
}
.neutral {
background: #F7F7F7;
color: #303030;
}
.neutral:focus {
background: #F7F7F7;
color: #303030;
}
.neutral:hover,
.neutral:active {
background: #dedede;
}
.negative {
background: #E74C3C;
color: #F7F7F7;
}
.negative:focus {
background: #E74C3C;
color: #F7F7F7;
}
.negative:hover,
.negative:active {
background: #d62c1a;
}
/* Forms */
input,
select {
margin-left: .5rem;
padding: .5rem;
}
input {
font-size: 18px;
letter-spacing: .25px;
}
input:not(.modal) {
border: none !important;
}
select {
font-size: inherit;
}
/* Helpers */
.left-sided {
padding-left: 1rem;
margin-right: auto;
}
.right-sided {
padding-right: 1rem;
margin-left: auto;
}
.left-fixed {
left: 0;
}
.right-fixed {
right: 0;
}
.flex {
flex: inherit !important;
}
.full-flex {
flex: 1 1 100% !important;
}
#media (max-width: 960px) {
.hideable {
display: none;
}
}
.hidden {
display: none;
}
.blurred {
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
filter: blur(5px);
}
.noscroll {
overflow: hidden;
}
.uppercase {
text-transform: uppercase;
}
.lowercase {
text-transform: lowercase;
}
.nav-up {
top: -88px;
}
/* Menu */
#media (max-width: 960px) {
#classic-menu .header-content,
#mobile-menu .header-content {
display: none;
}
}
#classic-menu .nav-link-container,
#mobile-menu .nav-link-container {
display: flex;
flex: 1;
align-items: center;
color: #F7F7F7;
text-align: center;
justify-content: center;
}
#classic-menu .nav-link-container .nav-link,
#mobile-menu .nav-link-container .nav-link {
font-weight: bold;
text-transform: uppercase;
}
#classic-menu .nav-link-container .nav-link:after,
#mobile-menu .nav-link-container .nav-link:after {
content: '';
display: block;
margin: auto;
height: 3px;
width: 0px;
background: transparent;
transition: width 0.2s ease, background-color 0.2s ease;
}
#classic-menu .nav-link-container.active,
#mobile-menu .nav-link-container.active {
color: #ababab;
}
#classic-menu .nav-link-container:hover:not(.active) > .nav-link:after,
#mobile-menu .nav-link-container:hover:not(.active) > .nav-link:after {
width: 100%;
background: #F7F7F7;
}
#mobile-menu {
width: 100%;
height: 100%;
position: fixed;
margin-top: 51px;
display: none;
}
#mobile-menu .mobile-header-content {
margin-top: -102px;
width: 100%;
}
#mobile-menu .mobile-header-content .logo-link {
display: flex;
align-items: center;
justify-content: center;
}
#media (max-height: 280px) {
#mobile-menu .mobile-header-content .logo-link {
display: none;
}
}
#mobile-menu .mobile-header-content .nav-link {
padding: 1rem;
}
/* Logo */
.logo {
width: 220px;
}
/* Toggle Button */
.toggle-button {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
position: fixed;
background: rgba(0, 0, 0, 0.8);
left: 0;
right: 0;
cursor: pointer;
text-align: center;
font-weight: bold;
text-transform: uppercase;
color: #F7F7F7;
padding: 1rem;
z-index: 102;
display: none;
}
#media (max-width: 960px) {
.toggle-button {
display: block;
}
}
.toggle-button i {
width: 30px;
}
/* Tooltips */
.tooltip {
text-align: center;
background: rgba(0, 0, 0, 0.8);
color: #F7F7F7;
position: absolute;
z-index: 1000;
display: none;
}
.tooltip p {
margin: .65rem;
}
/* Slide */
.slides.container {
margin-bottom: 1rem;
justify-content: space-between;
}
#media (max-width: 540px) {
.slides.container {
flex-flow: column;
}
}
.slides.container .slide {
display: flex;
align-items: flex-end;
justify-content: center;
flex: 1;
min-height: 200px;
padding: 1rem;
cursor: pointer;
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
margin: 0 1rem 0 0;
transition: .2s;
}
#media (max-width: 540px) {
.slides.container .slide {
margin: 0 0 1rem 0;
align-items: center;
min-height: 100px;
}
.slides.container .slide:hover {
flex: 1;
}
}
.slides.container .slide .header {
text-shadow: 0 2px 5px #000;
transition: .2s;
}
.slides.container .slide:hover:not(.active) {
flex: 3;
}
.slides.container .slide.first-slide {
background-image: url('../assets/images/first-option.jpg');
background-size: cover;
}
.slides.container .slide.second-slide {
background-image: url('../assets/images/second-option.jpg');
background-size: cover;
}
.slides.container .slide.third-slide {
background-image: url('../assets/images/third-option.jpg');
background-size: cover;
margin: 0;
}
.slides.container .slide.active {
opacity: .5;
cursor: default;
}
.slides.container .slide.active .header {
text-shadow: none;
}
/* Form */
.form {
margin-top: 1rem;
margin-bottom: 1rem;
}
.form form {
display: flex;
flex-flow: column;
}
.form form .row {
display: flex;
align-items: center;
margin-bottom: 1rem;
}
.form form .row label {
width: 100px;
}
.form form .row input {
width: 100%;
}
.form button {
align-self: flex-end;
}
.asterisk {
margin: 0 .2rem 0 .2rem;
color: #FF3800;
}
/* Paragraph Override */
p {
margin: 0;
}
p.check-message {
margin: 0 0 1rem 100px;
text-align: center;
display: none;
}
p.check-message .fa {
color: #FF3800;
}
p.check-message.overall-message {
border-top: 1px solid #F7F7F7;
margin: 0 0 1rem 0;
padding: .5rem 0 0 0;
}
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no">
<link rel="icon" href="../favicon.ico?v=2">
<link rel="stylesheet" href="../styles/vendor/pace.css">
<script src="../scripts/vendor/pace.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic">
<link rel="stylesheet" href="../styles/vendor/font-awesome.min.css">
<!-- FOR DEVELOPMENT ONLY -->
<link rel="stylesheet" href="../styles/order.dev.css"> <!-- END -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.1/less.min.js"></script> -->
</head>
<body><header id="classic-menu" class="remodal-bg">
<div class="header-content">
<div class="flex">
<span class="nav-link">Каталог</span><span class="nav-link">Тач-панели</span><span class="nav-link">Заказ</span> </div>
<img src="../assets/images/main-logo.png" alt="Логотип EON2" class="logo">
<div class="flex">
<span class="nav-link">Где купить</span><span class="nav-link">Под­держка</span><span class="nav-link">Кон­такты</span> </div>
</div>
</header>
<div class="toggle-button"><i class="fa fa-reorder"></i>Меню</div>
<header id="mobile-menu">
<div class="mobile-header-content">
<img src="../assets/images/main-logo.png" alt="Логотип EON2" class="logo">
<div class="flex">
<span class="nav-link">Каталог</span><span class="nav-link">Тач-панели</span><span class="nav-link">Заказ</span> </div>
<div class="flex">
<span class="nav-link">Где купить</span><span class="nav-link">Под­держка</span><span class="nav-link">Кон­такты</span> </div>
</div>
</header>
<div class="tooltip tt" data-tooltip="0">
<p>Главная страница</p>
</div>
<div class="tooltip tt" data-tooltip="1">
<p>Каталог стан­дарт­ных решений на основе ПЛК</p>
</div>
<div class="tooltip tt" data-tooltip="2">
<p>Передовые решения с исполь­зованием тач-панелей</p>
</div>
<div class="tooltip tt" data-tooltip="3">
<p>Заказ уникаль­ного решения</p>
</div>
<div class="tooltip tt" data-tooltip="4">
<p>Информация о магазинах</p>
</div>
<div class="tooltip tt" data-tooltip="5">
<p>Обновление ПО и замена запчастей</p>
</div>
<div class="tooltip tt" data-tooltip="6">
<p>Адреса и телефоны</p>
</div><main>
<div class="main container narrow">
<div class="slides container">
<div class="slide first-slide " data-slide="first"><h2 class="header">First Option</h2></div>
<div class="slide second-slide " data-slide="second"><h2 class="header">Second Option</h2></div>
<div class="slide third-slide " data-slide="touch-panel"><h2 class="header">Тач-панель</h2></div>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda deleniti, beatae eum totam odit expedita modi laudantium praesentium, quasi vero nihil doloribus consequatur! Aspernatur quae numquam nulla quidem iusto reiciendis hic deserunt a eaque ad ipsa, quibusdam magni laborum similique, rem laboriosam odit! Voluptates adipisci magni expedita fugit autem totam.</p>
<div class="form">
<form action="" method="post">
<div class="row">
<label for="name">Имя<span class="asterisk">*</span>:</label>
<input type="text" name="name" id="name" placeholder="Иван Иванов">
</div>
<p class="check-message name-message"><i class="fa fa-warning"></i> Имя должно состоять из 2 символов или более.</p>
<div class="row">
<label for="address">Адрес<span class="asterisk">*</span>:</label>
<input type="text" name="address" id="address" placeholder="ул. Первая, 32">
</div>
<p class="check-message address-message"><i class="fa fa-warning"></i> Адрес должно состоять из 7 символов или более.</p>
<div class="row">
<label for="email">E-mail:</label>
<input type="text" name="email" id="email" placeholder="example#mail.ru">
</div>
<p class="check-message email-message"><i class="fa fa-warning"></i> E-mail должен быть верным.</p>
<div class="row">
<label for="tel">Телефон<span class="asterisk">*</span>:</label>
<input type="text" name="tel" id="tel" placeholder="+7 (900) 800 70-60">
</div>
<p class="check-message tel-message"><i class="fa fa-warning"></i> Телефон должен состоять только из цифр.</p>
<p class="check-message overall-message">Форма заполнена неверно. Обратите внимание, что так <span class="asterisk">*</span> помечены обязательные к заполнению поля.</p>
<button class="positive button"><i class="fa fa-check"></i> Отправить</button>
</form>
</div>
</div>
</main> <footer class="remodal-bg">
<span class="left-sided copyright">© 2009—2016 ООО «ИПН»</span>
<div class="links">
Обратная связь
Оферта
Карта сайта
</div>
<span class="phone"><i class="fa fa-phone"></i> +7 (863) 231-09-18</span>
</footer>
<script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.0-rc.2/jquery-ui.min.js" integrity="sha256-55Jz3pBCF8z9jBO1qQ7cIf0L+neuPTD1u7Ytzrp2dqo=" crossorigin="anonymous"></script>
<script src="../scripts/vendor/maskedinput.min.js"></script>
<script src="../scripts/order.js"></script>
</body>
</html>
This is a part of site, it was taken very roughly, but should be readable. All you need to do is to click on "Меню" button and hover on some links. It triggers bug for me in Edge.

Related

I need to toggle between an X button and hamburger menu with Bootstrap. I'm using React.js

I'm using the latest version of Bootstrap and want to toggle between the famous X icon and hamburger menu. I don't know if I can actually change the 3 lines of the menu since it's by default, but these 2 icons presently overlap each other.
So there are 2 questions here:
How can I toggle these two icons?
When the menu is clicked, it should have a complete white background (right now it doesn't completely cover the screen in white)
Sorry I don't have a sandbox example for you right now.
Thanks for your input!
/*JSX code*/
import React from 'react';
import { NavigationBarStyled } from './style';
import { Nav, Navbar } from 'react-bootstrap';
//IMAGES
import logo from '../../images/adyslogo.png';
import Image from 'react-bootstrap/Image';
import { GrCart } from 'react-icons/gr';
import CloseButton from '../../images/closebutton.svg';
const NavigationBar = () => {
return (
<NavigationBarStyled>
<Navbar expand='sm' fixed='top'>
<Navbar.Brand href='/'><Image src={logo} className='logo'/></Navbar.Brand>
<div className='close-button'>
<button type="button" className="x-closebutton" aria-label="Close">
<img src={CloseButton} className='x-button' alt="close configuration" draggable="false" />
</button>
<Navbar.Toggle aria-controls='basic-navbar-nav' className='hamburger-menu'/>
</div>
<Navbar.Collapse id='basic-navbar-nav'>
<Nav className='mr-auto'>
<Nav.Item><Nav.Link href='/' className="middle-menu">HOME</Nav.Link></Nav.Item>
<Nav.Item><Nav.Link href='/about' className="middle-menu">ABOUT</Nav.Link></Nav.Item>
<Nav.Item><Nav.Link href='/menu' className="middle-menu">MENU</Nav.Link></Nav.Item>
<Nav.Item><Nav.Link href='/gallery' className="middle-menu">GALLERY</Nav.Link></Nav.Item>
<Nav.Item><Nav.Link href='/contact' className="middle-menu">CONTACT</Nav.Link></Nav.Item>
</Nav>
<Nav className='ml-auto'>
<Nav.Item><Nav.Link href='/cart'><GrCart size='25px' className='cart'/></Nav.Link></Nav.Item>
</Nav>
</Navbar.Collapse>
</Navbar>
</NavigationBarStyled>
)
}
export default NavigationBar;
/*CSS*/
import styled from 'styled-components';
export const NavigationBarStyled = styled.nav`
.navbar {
background-color: #FFF;
height: 80px;
}
.navbar-brand, .navbar-nav .nav-link {
color: #273746 ;
font-size: 1rem;
font-weight: 600;
&:hover {
color: rgb(255, 20, 147);
}
}
.logo {
max-height: 60px;
max-width: 60px;
}
.middle-menu {
margin: 20px;
}
.cart {
margin-right: 50px;
}
.close-button {
display: flex;
align-items: flex-start;
justify-content: flex-start;
}
.x-closebutton {
display: flex;
align-items: flex-start;
justify-content: flex-start;
border: none;
background-color: #fff;
margin-right: -54px;
}
.x-button {
display: flex;
width: 45px;
height: 45px;
cursor: pointer;
}
.hamburger-menu {
border: none;
color: #000;
}
.mr-auto {
display: flex;
align-items: center;
background-color: white;
min-width: 100vw;
min-height: 100vh;
}
`;
It's actually rather easy to toggle state but, keep in mind you won't have the graceful height calculation which comes with Bootstrap.
I'll comment out what doesn't seem important to this answer...
import React, { Component } from "react";
//import { Link } from "gatsby";
//import Image from "./image";
import "../../scss/molecules/_topnav.scss";
//const helpers = require("../../helpers");
class Nav extends Component {
state = { collapse: true };
/*
componentDidMount() {
helpers.useIntersect(".navbar-collapse", "navbar-collapsed");
}
*/
constructor(props) {
super(props);
this.brandLogo = this.props.brandLogo;
this.listItems = this.props.pages
//.sort((a, b) => (a.node.navigationOrder || 100) - (b.node.navigationOrder || 100))
.map((page) => page.node.slug && page.node.pageName && !page.node.hideInNavigation && (
<li className="nav-item" key={page.node.id}>
<Link to={`${page.node.slug}`} className="nav-link" title={page.node.pageName}>{page.node.pageName}</Link>
</li>)
);
}
render() {
return (
<>
<nav className={[
"navbar",
"navbar-expand-lg",
"navbar-light",
"fixed-top",
this.state.collapse ? "" : "active"].join(" ")}
>
<a className="navbar-brand" href="/"><Image fluid={this.brandLogo} /></a>
<button
className="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#topnav"
aria-controls="topnav"
aria-expanded={!this.state.collapse}
aria-label="Toggle navigation" onClick={() => {
this.setState({ collapse: !this.state.collapse });
}
}>
<span className="navbar-toggler-icon"></span>
</button>
<div
className={[
"collapse",
"navbar-collapse",
"fade",
!this.state.collapse ? "show" : "",
].join(" ")} id="topnav">
<ul className="navbar-nav ml-lg-auto">{this.listItems}</ul>
</div>
</nav>
</>
);
}
}
export default Nav;
SCSS solution to cover state and mobile -vs- desktop navigation
A simple toggle between display "none" and "block". You can transition transforms to counter the missing height calculation.
We'll use the proper content characters to cover the icons.
It's a bit too much but I'll leave this file complete.
#import "../variables";
#import "../functions";
#import "../vendor/bootstrap/functions";
#import "../vendor/bootstrap/variables";
#import "../vendor/bootstrap/mixins";
#import "../vendor/bootstrap/transitions";
.navbar {
&.navbar-light {
transition: all ease 0.2s;
.navbar-brand {
transition: all ease 0.2s;
.image {
height: auto;
width: rem-value(142);
}
}
.nav-item {
align-items: center;
display: flex;
}
.nav-link {
font-family: $font-family-monospace;
font-size: rem-value(20);
}
#include media-breakpoint-up(md) {
.navbar-collapse {
&:not(.show) {
opacity: 1;
}
}
.nav-item {
margin: auto 1rem;
}
}
#include media-breakpoint-up(lg) {
.nav-item {
&:last-child {
.nav-link {
background-color: $primary;
border-radius: rem-value(3);
color: $white;
margin-left: 1.5rem;
&:hover,
&:active,
&:focus {
background-color: $brand-primary-headings;
}
}
}
}
}
#include media-breakpoint-down(md) {
background-color: $white;
box-shadow: 0 0 1px 1px $gray-300;
padding-top: 0;
padding-bottom: 0;
.navbar-brand {
transform: scale(0.65);
transform-origin: left;
padding-top: 0;
padding-bottom: 0;
}
.navbar-collapse {
&.collapse {
background: white;
margin: 0 -1rem;
height: 0;
transform: scale(0);
transform-origin: top center;
transition: all ease 0.5s;
padding: 1rem;
position: relative;
&.show {
height: calc(100vh - 80px);
transform: scale(1);
}
}
}
.navbar-toggler {
&[aria-expanded="true"] {
.navbar-toggler-icon {
background-image: none;
position: relative;
&:before {
content: "\00d7";
font-family: sans-serif;
font-size: rem-value(40);
line-height: 0.8;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
}
}
}
.nav-item {
border-bottom: 1px solid $gray-300;
margin: 0;
position: relative;
&:before {
content: "\203A";
line-height: 1.2;
font-size: rem-value(30);
color: $brand-primary-headings;
position: absolute;
right: 0.5rem;
width: rem-value(40);
height: rem-value(40);
text-align: center;
}
}
.nav-link {
line-height: 1.8;
width: 100%;
}
}
#at-root .scrolled & {
background-color: $white;
box-shadow: 0 0 1px 1px $gray-300;
padding-top: 0;
padding-bottom: 0;
.navbar-brand {
transform: scale(0.65);
padding-top: 0;
padding-bottom: 0;
}
}
}
}
Example can be seen at devlab.career
Hopefully with this example you can implement this too.

Move on click - html, css only - media queries

I have a link on my menu items and id's on h2 of the text that belong to it. All I want to do is easy - when I click on certain item in the menu I want it to move down to the text that belongs to it. Easy.
I have it like side menu on the left and next to it is the text. When the resolution is under 479px the "side menu" is at the top and the text is under it. And what I want it to do is only when it is under this resolution - to jump down to the text (h2). When is it side by side it is fine and there is no need to do that of course. So my question is.. is it posiible to do so somehow only by using html and css? To make it work ("jump") only when it is under 479px? Media queries somehow?
Thanks you
<section id="budova">
<div class="materials">
<div class="container">
<h1>BUDOVA (izolace)</h1>
<div class="materials-container">
<div class="kategorie">
<h2 data-kategorie="#silsonic" class="active">Silsonic</h2>
<h2 data-kategorie="#mappysil400">Mappysil CR 400</h2>
<h2 data-kategorie="#mappysil404">Mappysil CR 404</h2>
<h2 data-kategorie="#polistik">Polistik / M under special HQ</h2>
<h2 data-kategorie="#pavisol">Pavisol</h2>
<h2 data-kategorie="#mappysilent">Mappysilent</h2>
<h2 data-kategorie="#fonosilent">Fonosilent</h2>
<h2 data-kategorie="#bugnato">Mappysil CR Bugnato</h2>
<h2 data-kategorie="#mappysil-re">Mappysil CR RE</h2>
<h2 data-kategorie="#mappypren">Mappypren AU</h2>
<h2 data-kategorie="#stopfire">Stopfire Bugnato</h2>
</div>
<div class="produkty" id="produkty">
<div id="silsonic" class="active">
<h3>Silsonic</h3>
<img src="./img/materials/budova/silsonic.jpg" alt="Silsonic">
<p>Cena od 150 kč vč. DPH</p>
<p>v 40/š 600/d 1200 mm ( ostatní rozměry v sekci ceník )</p>
<p>SILSONIC je termoizolační a akusticky absorpční materiál vyrobený z tepelně zpracovaných, recyklovaných polyesterových vláken. Panely SILSONIC se používají k tepelné a zvukové izolaci všech druhů zdiva, sádrokartonových konstrukcí, stropů a pro podstřešní izolace.</p>
</div>
.
.
.
more text
CSS
.materials-container {
display: grid;
grid-template-columns: 1fr 3fr;
margin: 3rem 0;
}
.materials h1 {
text-align: center;
padding: 6rem 0 1.5rem;
font-family: "Montserrat", sans-serif;
font-weight: 300;
letter-spacing: 1px;
border-bottom: 1px solid;
width: 90%;
margin: auto;
}
.kategorie {
background-color: #c4c4c4;
text-align: center;
padding: 1rem 0;
border-radius: 10px;
margin-bottom: 8rem;
}
.produkty {
display: flex;
justify-content: center;
/* align-items: center; */
margin-left: 10rem;
}
.produkty div {
display: none;
}
.produkty div.active {
display: initial;
}
.produkty h4 {
text-transform: uppercase;
margin-top: 3rem;
}
.produkty p:first-of-type,
.produkty p:nth-of-type(2) {
font-weight: 600;
}
.produkty img {
max-width: 300px;
}
.materials {
padding-bottom: 40px;
}
.materials p {
line-height: 24px;
}
.materials h1 {
margin-bottom: 5rem;
}
.materials h2 {
width: 70%;
cursor: pointer;
font-size: 1.2rem;
font-weight: 300;
padding: 0.8rem 0;
border-bottom: 1px solid transparent;
margin: 0 auto;
transition: all 0.3s;
}
.materials h2:hover {
border-bottom: 1px solid #fff;
color: #fff;
}
#media (max-width: 479px) {
.main-text p {
line-height: 2rem;
}
.main-text h1 {
padding: 4rem 0 0.5rem;
}
.photos img {
width: 60%;
margin: auto;
}
.photos {
height: 160px;
}
.nav-menu .logo {
width: 53%;
height: 52px;
}
.materials-container {
display: block;
}
.materials h2 {
font-size: 1.2rem;
}
.kategorie {
margin-bottom: 5rem;
}
#fonosilent {
width: 100%;
}
}
make an extra "link" in the html
on small screens one will be hidden (the one without jump-to-link) while the other one (with anchor-tag and jump-to) will be shown.
...
<div class="kategorie">
<h2 data-kategorie="#silsonic" class="active">Silsonic</h2>
<h2 data-kategorie="#silconic" class="active big-screen">Silsonic</h2>
...
media-queries in css:
#media (max-width: 479px) {
.big-screen {
display: none;
}
.small-screen {
display: grid/flex/whatever;
}
}
#media (min-width: 480px) {
.big-screen {
display: grid/flex/whatever;
}
.small-screen {
display: none;
}
}

Custom WordPress nav menu the last li item – two social icons

I need to create WordPress custom nav menu containing two social icons in the last li item.
document.addEventListener('DOMContentLoaded', function() {
// Toggle
const btn = document.querySelector('#btnToggle');
btn.addEventListener('click', function(e) {
e.preventDefault();
document.body.classList.toggle('nav-show');
this.classList.toggle('btn-toggle--toggled');
});
// Highlight current page active menu item.
const selector = '.nav__link';
const elems = Array.from(document.querySelectorAll(selector));
const navigation = document.querySelector('nav');
function makeActive(evt) {
const target = evt.target;
if (!target || !target.matches(selector)) {
return;
}
elems.forEach(elem => elem.classList.remove('active'));
evt.target.classList.add('active');
};
navigation.addEventListener('mousedown', makeActive);
});
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
overflow-x: hidden;
}
img {
max-width: 100%;
display: block;
}
.social__link {
display: block;
}
svg {
width: 100%;
display: block;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
.container {
margin: 0 auto;
width: 100%;
max-width: 1400px;
}
.header {
position: sticky;
top: 0;
background-color: #fff;
z-index: 1;
}
.logo__container {
padding: .3125rem .3125rem .625rem;
}
.logo {
display: flex;
align-items: center;
}
.logo__heart {
flex-basis: 27%;
}
.hgroup {
padding-left: .625rem;
}
.headline__light {
display: none;
}
.headline {
font-size: 1.25rem;
text-transform: uppercase;
margin: 0;
}
.navigation__container {
align-items: center;
}
.header__item {
display: flex;
}
.btn-toggle button {
background: none;
border: 0;
}
.btn-toggle {
width: 40px;
height: 40px;
cursor: pointer;
border: 1px solid #DDD;
border-radius: 4px;
padding: 9px;
position: absolute;
top: 24px;
right: 20px;
background: none;
}
.btn-toggle .line {
background: #888;
border-radius: 10px;
display: block;
position: absolute;
height: 2px;
transform: translate(-50%, -50%) rotate(0deg);
transition: transform 0.25s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.25s cubic-bezier(0.22, 0.61, 0.36, 1);
opacity: 1;
top: 50%;
left: 50%;
width: 80%;
}
.btn-toggle .line:nth-child(1) {
margin-top: -6px;
}
.btn-toggle .line:nth-child(3) {
margin-top: 6px;
}
.btn-toggle--toggled .line:nth-child(2) {
opacity: 0;
}
.btn-toggle--toggled .line:nth-child(1) {
margin-top: 0;
transform: translate(-50%, -50%) rotate(45deg);
}
.btn-toggle--toggled .line:nth-child(3) {
margin-top: 0;
transform: translate(-50%, -50%) rotate(-45deg);
}
.nav {
background: #F2EFE8;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
max-height: 0;
overflow: hidden;
transition: 0.5s max-height;
}
.nav-show .nav {
max-height: 700px;
}
.nav__list {
display: flex;
flex-direction: column;
background: #F2EFE8;
border-top: 1px solid #DDD;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
}
.nav__item {
flex-basis: 100%;
text-transform: uppercase;
font-size: .875rem;
text-align: center;
border-bottom: 1px solid #888;
letter-spacing: .0625rem;
}
.nav__link {
display: block;
text-decoration: none;
text-transform: uppercase;
color: #222;
padding: .625rem;
}
.nav__link:hover {
background: #c2def7;
}
.nav__link.active {
background: #abd4f8;
}
.icon__container {
display: flex;
justify-content: space-evenly;
align-items: center;
}
.nav__item.social__icon {
padding: .625rem;
}
.icon {
width: 10%;
}
#media only screen and (min-device-width: 320px) and (max-device-width: 568px) and (orientation: landscape) {
.nav__list {
flex-direction: row;
flex-wrap: wrap;
}
.nav__item {
width: 50%;
flex-basis: 50%;
}
.nav__item:nth-of-type(1) {
order: 1;
}
.nav__item:nth-of-type(2) {
order: 3;
}
.nav__item:nth-of-type(3) {
order: 5;
}
.nav__item:nth-of-type(4) {
order: 7;
}
.nav__item:nth-of-type(5) {
order: 9;
}
.nav__item:nth-of-type(6) {
order: 2;
}
.nav__item:nth-of-type(7) {
order: 4;
}
.nav__item:nth-of-type(8) {
order: 6;
}
.nav__item:nth-of-type(9) {
order: 8;
}
.nav__item:nth-of-type(10) {
order: 10;
padding: .3125rem 0;
border-bottom: 1px solid #888;
}
.icon {
width: 9%;
}
}
#media only screen and (min-width: 768px) {
.logo__heart {
flex-basis: 25%;
}
.hgroup {
flex-basis: 71%;
}
.headline__light {
display: block;
font-size: .875rem;
text-transform: none;
}
.nav__list {
flex-grow: 1;
flex-wrap: wrap;
flex-direction: row;
}
.nav__item {
width: 33.33%;
flex-basis: 33.33%;
}
.nav__item:nth-of-type(1) {
order: 1;
}
.nav__item:nth-of-type(2) {
order: 4;
}
.nav__item:nth-of-type(3) {
order: 7;
}
.nav__item:nth-of-type(4) {
order: 2;
}
.nav__item:nth-of-type(5) {
order: 5;
}
.nav__item:nth-of-type(6) {
order: 8;
}
.nav__item:nth-of-type(7) {
order: 3;
}
.nav__item:nth-of-type(8) {
order: 6;
}
.nav__item:nth-of-type(9) {
order: 9;
}
.nav__item:nth-of-type(10) {
order: 10;
padding: .625rem;
flex-basis: 100%;
}
.icon {
width: 4%;
}
}
#media only screen and (min-width: 1024px) {
.logo {
width: 100%;
}
.logo__heart {
flex-basis: 30%;
}
.hgroup {
flex-basis: 100%;
padding: 0;
}
.unboxing__trick {
background-color: #F2EFE8;
width: 100vw;
position: relative;
margin: 0 calc(-50vw + 50%);
padding: 0 calc(50vw - 50%);
}
.btn-toggle {
display: none;
}
.nav {
max-height: 100%;
transition: none;
transition-duration: 0s;
display: flex;
flex-direction: row;
}
.nav__list {
flex-direction: row;
flex-wrap: nowrap;
border-top: none;
padding: .625rem 0;
}
.nav__item {
flex-basis: auto;
width: auto;
flex-grow: 1;
flex: 1 1 auto;
position: relative;
border-bottom: none;
}
.nav__item:after {
content: '';
position: absolute;
width: 1px;
left: 0;
top: 0;
bottom: 0;
background: linear-gradient(hsla(0, 0%, 0%, 0) 0%, hsla(0, 0%, 0%, .20) 50%, hsla(0, 0%, 0%, 0) 100%);
}
.nav__item:last-of-type {
border-right: 0;
}
.nav__item:nth-of-type(1) {
order: 1;
}
.nav__item:first-child::after {
display: none;
}
.nav__item:nth-of-type(2) {
order: 2;
}
.nav__item:nth-of-type(3) {
order: 3;
}
.nav__item:nth-of-type(4) {
order: 4;
}
.nav__item:nth-of-type(5) {
order: 5;
}
.nav__item:nth-of-type(6) {
order: 6;
}
.nav__item:nth-of-type(7) {
order: 7;
}
.nav__item:nth-of-type(8) {
order: 8;
}
.nav__item:nth-of-type(9) {
order: 9;
}
.nav__item:nth-of-type(10) {
order: 10;
flex: 1 1 8%;
padding: .3125rem 0;
border-bottom: none;
}
.nav__link:hover {
background: none;
color: #b8795a;
}
.nav__link.active {
background: none;
color: #b8795a;
}
.icon {
width: 25px;
}
}
#supports (position: sticky) {
.header {
position: sticky;
top: 0;
}
}
<!doctype html>
<html lang="pl">
<head>
<meta charset="utf-8">
<title></title>
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="style.css">
<script src="app.js"></script>
</head>
<body>
<header class="header">
<section class="container">
<div class="header__container">
<div class="logo__container header__item">
<div class="logo">
<div class="logo__heart">
<img class="img__logo" src="http://placehold.it/169x160" alt="" title="">
</div>
<div class="hgroup">
<h1 class="headline__bold headline">Czysta świadomość</h1>
<h2 class="headline__light headline">
... stan bycia poza umysłem, wolny od goniących myśli, wszelkich uwarukowań, pobudek ego.<br> Czysta Świadomość to prawdziwe JA... to Światło i Miłość
</h2>
</div>
</div>
</div>
<nav class="navigation__container">
<button class="btn-toggle" id="btnToggle" aria-label="Open / Close Menu">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</button>
<div class="unboxing__trick">
<div class="nav">
<ul class="nav__list">
<li class="nav__item">
<a class="nav__link active" href="#">Strona Główna</a>
</li>
<li class="nav__item">
<a class="nav__link" href="#">Ja jestem</a>
</li>
<li class="nav__item">
<a class="nav__link" href="#">Kalendarz</a>
</li>
<li class="nav__item">
<a class="nav__link" href="#">Warsztaty</a>
</li>
<li class="nav__item">
<a class="nav__link" href="#">Wykłady</a>
</li>
<li class="nav__item">
<a class="nav__link" href="#">Artykuły</a>
</li>
<li class="nav__item">
<a class="nav__link" href="#">Audio</a>
</li>
<li class="nav__item">
<a class="nav__link" href="#">Youtube</a>
</li>
<li class="nav__item">
<a class="nav__link" href="#">Kontakt</a>
</li>
<li class="nav__item social__icon">
<figure class="icon__container">
<div class="icon">
<a class="social__link social__link--fb" href="#">
<svg version="1.1" id="Social_Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-297.5 123.5 595 595" enable-background="new -297.5 123.5 595 595" reserveAspectRatio="xMidYMid meet" xml:space="preserve">
<rect x="-64.47" y="206.101" fill="#FFFFFF" width="276.871" height="512.399"/>
<path id="Facebook" fill="#4460A0" d="M20.309,718.5H-264.66c-18.143,0-32.84-14.707-32.84-32.84V156.342
c0-18.144,14.698-32.842,32.84-32.842h529.324c18.135,0,32.836,14.698,32.836,32.842V685.66c0,18.137-14.701,32.84-32.836,32.84
H113.042V488.082h77.34l11.581-89.799h-88.921v-57.328c0-26,7.218-43.713,44.5-43.713l47.548-0.02v-80.316
c-8.223-1.092-36.449-3.538-69.289-3.538c-68.561,0-115.496,41.851-115.496,118.698v66.222H-57.23v89.798H20.31V718.5H20.309z"/>
</svg>
</a>
</div>
<div class="icon">
<a class="social__link social__link--youtube" href="#">
<svg version="1.1" id="Social_Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 36.305 595 595" enable-background="new 0 36.305 595 595" reserveAspectRatio="xMidYMid meet" xml:space="preserve">
<polygon fill="#FFFFFF" points="214.04,443.136 214.04,214.49 432.938,328.812 "/>
<path id="Youtube" fill="#CE1312" d="M589.05,214.115c0,0-5.819-41.248-23.65-59.408c-22.629-23.849-47.991-23.959-59.611-25.343
c-83.265-6.06-208.158-6.06-208.158-6.06h-0.261c0,0-124.895,0-208.157,6.06c-11.641,1.384-36.984,1.495-59.63,25.343
C11.75,172.873,5.948,214.115,5.948,214.115S0,262.565,0,310.993v45.417c0,48.445,5.949,96.875,5.949,96.875
s5.802,41.247,23.633,59.407c22.647,23.851,52.379,23.102,65.617,25.591c47.6,4.602,202.301,6.021,202.301,6.021
s125.024-0.185,208.288-6.246c11.621-1.4,36.983-1.514,59.611-25.36c17.831-18.166,23.652-59.408,23.652-59.408
S595,404.859,595,356.41v-45.417C595,262.565,589.05,214.115,589.05,214.115z M236.066,411.443l-0.019-168.18l160.762,84.38
L236.066,411.443z"/>
</svg>
</a>
</div>
</figure>
</li>
</ul>
</div>
</div>
</nav>
</div>
</section>
</header>
</body>
</html>
I cannot comment on Marco’s answer because I have not enough reputation, so I create a new answer…
Marco’s code only needs a small adjustment, then it should work: The social icons markup needs to be added to $items, and in the end, $items needs to be returned by the filter function.
function add_last_nav_item( $items ) {
$items .= sprintf(
'<li class="nav__item social__icon">
<figure class="icon__container">
<div class="icon">
<img src="%2$s/images/icon__facebook.svg">
</div>
<div class="icon">
<img src="%2$s/images/icon__youtube.svg"> .
</div>
</figure>
</li>',
'https://www.facebook.com/Czysta-%C5%9Awiadomo%C5%9B%C4%87-%C5%9Awiat%C5%82o-i-Mi%C5%82o%C5%9B%C4%87pl-811435542275919/',
get_template_directory_uri(),
'https://www.youtube.com/channel/UCxxKwAW7JE6eCx3OjNcO6Yw/'
);
return $items;
}
add_filter( 'wp_nav_menu_items', 'add_last_nav_item' );
Update for adding classes
To add a class to the li and a elements of the nav items, you can use the following snippet:
/**
* Add classes to li and a elements of the nav menus.
*
* #param string $items HTML of menu items.
*
* #return string
*/
function themeslug_add_menu_item_classes( $items ) {
// Disable libxml errors.
libxml_use_internal_errors( true );
// Create new DOMDocument object.
$dom = new DOMDocument();
// Load the HTML.
// Trick with <?xml endocing="utf-8" loadHTML() method of https://github.com/ivopetkov/html5-dom-document-php
$dom->loadHTML( '<?xml encoding="utf-8" ?>' . $items, 0 | LIBXML_NOENT );
$xpath = new DOMXPath( $dom );
// Get all nodes.
$nodes = $xpath->query( '//*' );
// Loop them.
foreach ( $nodes as $node ) {
// Check if we have an li element.
if ( 'li' === $node->tagName ) {
// Get existing classes from element and add our custom class.
$classes = $node->getAttribute( 'class' ) . ' my-custom-list-item-class';
// Set the custom class.
$node->setAttribute( 'class', $classes );
} // End if().
// Check if the node is an a element.
if ( 'a' === $node->tagName ) {
// Get existing classes from element and add our custom class.
$classes = $node->getAttribute( 'class' ) . ' my-custom-a-element-class';
// Set the custom class.
$node->setAttribute( 'class', $classes );
} // End if().
} // End foreach().
// Save the dom.
$items = themeslug_save_html( $dom );
// Return the items.
return $items;
}
add_filter( 'wp_nav_menu_items', 'themeslug_add_menu_item_classes' );
/**
* Enhanced variation of DOMDocument->saveHTML().
*
* Fix for cyrillic from https://stackoverflow.com/a/47454019/7774451.
* Replacement of doctype, html, and body from archon810\SmartDOMDocument.
*
* #param DOMDocument $dom DOMDocument object of the dom.
*
* #return string DOM or empty string.
*/
function themeslug_save_html( DOMDocument $dom ) {
$xpath = new DOMXPath( $dom );
$first_item = $xpath->query( '/' )->item( 0 );
return preg_replace(
array(
'/^\<\!DOCTYPE.*?<html><body>/si',
'!</body></html>$!si',
),
'',
$dom->saveHTML( $first_item )
);
}
It uses DOMDocument to parse the HTML of the nav items and DOMXPath to get all HTML nodes. After that, the nodes are looped and inside the loop it checks for the element type and adds a class if it is a li or a element.
could you paste this code on your functions.php
it should add the li at the end of your wp_nav_menu()
function add_last_nav_item($items) {
?>
<li class="nav__item social__icon">
<figure class="icon__container">
<div class="icon">
<img src="<?php echo get_template_directory_uri(); ?>/images/icon__facebook.svg">
</div>
<div class="icon">
<img src="<?php echo get_template_directory_uri(); ?>/images/icon__youtube.svg"> .
</div>
</figure>
</li>
<?php
}
add_filter('wp_nav_menu_items','add_last_nav_item');
You can extend the WordPress Walker class to build a custom menu.
Have a look at the codex documentation.
https://codex.wordpress.org/Class_Reference/Walker
You need to apply the required logic in that. Do not use jQuery or frontend scripts to do that. The menu is fully customiszable with the Walker.

How to set the width of absolute positioned droppdown menu to fit the longest list item?

I have a header with 2 dropdowns.
the dropdown menu position is absolute to it's wrapper container.
I want each dropdown menu width fit to the size of longest list entry. I am wondering if there is any solution without looping through li s and achieve it only using css?
<nav>
<div class="nav-dropdownContainer">
<div class="navdropdown nav-primary__dropdown">
<div class="navdropdown__text">
Themes
<i class="fa fa-chevron-down">+</i>
</div>
<ul class="navdropdown__list">
<li class="navdropdown__listItem">linktheme1</li>
<li class="navdropdown__listItem">linktheme2</li>
</ul>
</div>
<div class="navdropdown nav-primary__dropdown">
<div class="navdropdown__text">
tags
<i class="fa fa-chevron-down">+</i>
</div>
<ul class="navdropdown__list">
<li class="navdropdown__listItem">linktag1</li>
<li class="navdropdown__listItem">linktag2</li>
</ul>
</div>
</div>
</nav>
And CSS:
ul{
margin: 0;
padding: 0;
}
nav{
background-color: grey;
line-height: 35px;
}
.nav-dropdownContainer {
height: 70px;
width: 25%;
display: inline-block;
position: relative;
}
.navdropdown {
background-color: #455565;
display: inline-block;
border-right: 1px solid #fff;
height: 100%; }
.navdropdown:first-child {
border-left: 1px solid #fff; }
.navdropdown > ul {
margin: 0; }
.navdropdown:hover .navdropdown__text {
color: #fff; }
.navdropdown.open .navdropdown__text {
color: #fff; }
.navdropdown.open .navdropdown__list {
display: block; }
.navdropdown .fa-chevron-up,
.navdropdown .fa-chevron-down {
padding-left: 1rem;
font-size: 0.875rem; }
.navdropdown .navdropdown__text {
text-align: center;
cursor: pointer;
color: #ccc;
border-top: none;
padding: 1rem; }
.navdropdown__list {
position: absolute;
top: 100%;
z-index: 1000;
display: none;
float: left;
width: 100%;
left: 0;
background-color: #455565;
list-style-type: none; }
.navdropdown__list .navdropdown__listItem {
width: 100%;
float: left;
padding: 1rem;
background-color: #374350;
margin: 0; }
.navdropdown__list .navdropdown__listItem > a {
text-decoration: none;
color: #fff;
cursor: pointer; }
.navdropdown__list .navdropdown__listItem:hover {
background-color: #374856; }
JS:
(function() {
// Cache DOM
var $body = $('body'),
$window = $(window),
_dropdownClassName = '.navdropdown',
$dropdownContainer = $('.nav-dropdownContainer');
$body.on('click', _dropdownClassName, toggleDropdown);
function closeAllDropdowns(){
$(_dropdownClassName).removeClass('open');
$('.navdropdown__text i').removeClass('fa-chevron-up').addClass('fa-chevron-down');
}
/**
* toggle dropdown
*/
function toggleDropdown(){
const $this = $(this);
const $thisArrow = $this.find('.navdropdown__text i');
var leftPosition = $this.offset().left - $dropdownContainer.offset().left;
console.log('leftPosition', leftPosition);
if (window.Modernizr.mq('only screen and (max-width: 64em)')) {
$this.find('.navdropdown__list').css('left', 0);
}else{
if(leftPosition > 0){
$this.find('.navdropdown__list').css('left', leftPosition+'px');
}
}
if($thisArrow.hasClass('fa-chevron-down')){
closeAllDropdowns();
$this.addClass('open');
$thisArrow.removeClass('fa-chevron-down').addClass('fa-chevron-up');
}else{
closeAllDropdowns();
}
}
})();
Code Pen link: http://codepen.io/neginbasiri/pen/Xjgwkx
Add this to your navdropdown class : min-width: 40%;
It sets the minimum width of them to 40% of it's container width(If you have more items set this percentage proportional to the number of items).
If you want it be exactly like the biggest width involves some javascripts I don't recommend that way.

BootStrap Continuous Slide [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Here is a strip down version of my website. Using the mobile view, when the slides transitions there is a blank wipe before then next slide comes in
http://www.bootply.com/vUXtZz6HQ2
I am not quite understanding what I have to do to get the continuousswipe, that is the current slide will slide off as the next comes on the screen so it looks like it is one continuous strip,
as in the example of Bootstrap Carousel
HTML
<section class="marquee row">
<div class="carousel slide article-slide" data-ride="carousel" data-pause="hover" id="mainPromotion" style="-webkit-user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); touch-action: none;">
<div class="carousel-inner">
<div class="item" data-cell-id="" data-interval="7000">
<div class="marquee-media" data-src-md="http://placehold.it/300&text=A" data-src-xs="http://placehold.it/300&text=A" data-link="http://placehold.it/300&text=A" data-link-target="" data-link-title="A" id="marquee0"><img class="marquee-image img-responsive" src="http://placehold.it/300x300&text=A"></div>
</div>
<div class="item" data-cell-id="" data-interval="7000">
<div class="marquee-media" data-src-md="http://placehold.it/300&text=B" data-src-xs="http://placehold.it/300&text=B" data-link="http://placehold.it/300&text=B" data-link-target="" data-link-title="B" id="marquee1"><img class="marquee-image img-responsive" src="http://placehold.it/300&text=B"></div>
</div>
<div class="item active" data-cell-id="" data-interval="7000">
<div class="marquee-media" data-src-md="http://placehold.it/300&text=B" data-src-xs="http://placehold.it/300&text=C" data-link="http://placehold.it/300&text=C" data-link-target="" data-link-title="C" id="marquee2"><img class="marquee-image img-responsive" src="http://placehold.it/300&text=C"></div>
</div>
</div>
<ol class="carousel-indicators clearfix">
<li class="" data-slide-to="0" data-target="#mainPromotion">
<img alt="A" src="http://placehold.it/300&text=A">
<p class="cell-text">A</p>
<i class="fa fa-caret-right fa-2x"></i>
</li>
<li data-slide-to="1" data-target="#mainPromotion" class="">
<img alt="B" src="http://placehold.it/300&text=B">
<p class="cell-text">B</p>
<i class="fa fa-caret-right fa-2x"></i>
</li>
<li data-slide-to="2" data-target="#mainPromotion" class="active">
<img alt="C" src="http://placehold.it/300&text=C">
<p class="cell-text">C</p>
<i class="fa fa-caret-right fa-2x"></i>
</li>
</ol>
</div>
</section>
CSS
/* CSS used here will be applied after bootstrap.css */
section.marque {
margin-top: 10px;
}
section.marquee .cell-text {
color: #777777;
position: relative;
padding: 5px;
font-weight: bold;
font-family: ProximaNova, Arial, Helvetica, sans-serif;
display: inline-block;
float: left;
vertical-align: middle;
text-align: left;
text-indent: 0;
height: 60px;
width: 125px;
}
section.marquee .cell-text:hover {
background-color: #00543d;
color: #ffffff;
}
section.marquee .carousel-control {
background-image: none !important;
}
section.marquee .next.left,
section.marquee .prev.right {
-ms-opacity: 1;
opacity: 1;
z-index: 0;
}
section.marquee .active.left,
section.marquee .active.right {
-ms-opacity: 0;
opacity: 0;
z-index: 0;
}
section.marquee .article-slide .carousel-indicators {
top: 0;
left: 18px;
margin-left: 0;
margin-top: 8px;
width: 204px;
z-index: 0;
}
section.marquee .article-slide .carousel-indicators img {
/*float: left;
left: 0;*/
display: inline-block;
float: left;
width: 70px;
height: auto !important;
}
section.marquee .carousel-indicators li {
text-indent: 0 !important;
border: 1px solid #c0c0c0;
display: inline-block;
-ms-border-radius: 0;
border-radius: 0;
margin-bottom: 2px;
margin-left: -2px;
width: auto;
height: auto !important;
line-height: 16px;
font-size: 15px;
background-color: white;
z-index: 0;
position: relative;
}
section.marquee .carousel-indicators li i {
display: none;
}
section.marquee .carousel-indicators li:hover .cell-text {
background-color: #00543d;
color: #ffffff;
}
section.marquee .carousel-indicators li.active .cell-text {
color: #00543d;
}
section.marquee .carousel-indicators li.active:hover .cell-text {
color: #ffffff;
}
section.marquee .carousel-indicators li.active {
border: 3px solid #00543d;
color: #00543d;
margin-left: -1px;
margin-bottom: -1px;
}
section.marquee .carousel-indicators li.active i {
display: block;
position: absolute;
text-indent: 0 !important;
right: -12px;
top: 15px;
}
section.marquee .edit-marquee-cell {
position: absolute;
top: 5px;
left: 45%;
}
#media (min-width: 768px) and (max-width: 991px) {
section.marquee .item img,
section.marquee .carousel {
width: 768px;
height: 300px;
}
}
#media (min-width: 1200px) {
section.marquee .item img,
section.marquee .carousel {
width: 100% !important;
height: auto !important;
}
}
#media (min-width: 991px) {
/* fade effect */
section.marquee .carousel .item {
z-index: 0;
left: 0 !important;
-webkit-transition: opacity .4s;
-moz-transition: opacity .4s;
-o-transition: opacity .4s;
-ms-transition: opacity .4s;
transition: opacity .4s;
}
}
#media(max-width : 991px) {
section.marquee .carousel-indicators li.active i,
section.marquee .carousel-indicators img,
section.marquee .carousel-indicators .cell-text {
display: none !important;
}
section.marquee .carousel-indicators {
position: relative !important;
margin-left: auto !important;
margin-right: auto !important;
width: 80px !important;
text-align: center !important;
left: auto !important;
right: auto !important;
top: auto !important;
bottom: 0;
}
section.marquee .carousel-indicators li {
display: inline-block !important;
width: 15px !important;
height: 15px !important;
margin: 1px !important;
border: 1px solid #bcbcbc !important;
-ms-border-radius: 10px !important;
border-radius: 10px !important;
cursor: pointer;
}
section.marquee .carousel-indicators li.active {
width: 15px;
height: 15px !important;
background-color: #00543d !important;
}
backface-visibility: hidden;
perspective: 1000;
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
}
}
JavaScript
$(function () {
var validFlag = false;
$(window).on({
"load": function() {
if (!window.marqueeJson) return;
var imageTemplate = Handlebars.compile($("#template-marquee-images").html());
var fragTemplate = Handlebars.compile($("#template-marquee-frags").html());
var compiledInner = $("section.marquee .carousel-inner");
var compiledFrags = $("section.marquee .carousel-indicators");
compiledInner.html(imageTemplate(window.marqueeJson));
compiledFrags.html(fragTemplate(window.marqueeJson));
if (window.marqueeJson.Cells.length == 1) {
compiledFrags.remove();
$("section.marquee .carousel-control").remove();
}
if (compiledInner.length > 0) {
validFlag = true;
var mainPromo = document.getElementById("mainPromotion");
var mc = new window.Hammer(mainPromo);
mc.on("swipeleft", function () {
$(mainPromo).carousel("next");
});
mc.on("swiperight", function () {
$(mainPromo).carousel("prev");
});
updateMarquee();
var carouselStartPromo = function (promoPos) {
if (!isNaN(promoPos) && (0 < promoPos) && (promoPos < 3)) {
$('#mainPromotion').carousel(promoPos);
} else {
$('#mainPromotion').carousel();
}
};
var t;
var promoStart = -1;
carouselStartPromo(promoStart);
$('#mainPromotion').carousel('pause');
var start = $('#mainPromotion').find('.active').attr('data-interval');
t = setTimeout(carouselStartPromo, start - 7000);
/*
This event is to fix an IE bug where the swf file does not replay when the marquee control cycles
around. It looks ahead to the next item before the slide event happens (or to the first item, if there
isn't an item after the active one) and reloads the swf by re-embedding it. This only fires if the
useragent contains "MSIE" for Internet Explorer.
*/
$('#mainPromotion').on('slide.bs.carousel', function () {
if(navigator.userAgent.indexOf('MSIE') > -1){
var params = { menu: "false", wmode: "transparent" };
var self;
if ($('#mainPromotion').find('.active + .item').length > 0) {
self = $('#mainPromotion').find('.active + .item').find('.marquee-media');
}
else {
self = $('#mainPromotion').find('.item').first().find('.marquee-media');
}
var flashMedia = self.attr("data-src-flv") !== undefined ? self.attr("data-src-flv") : false;
if (flashMedia) {
var flashId = self.attr("id") + "-flash";
swfobject.embedSWF(flashMedia, flashId, "100%", "300", "9.0", false, false, params);
}
}
});
$('#mainPromotion').on('slid.bs.carousel', function () {
clearTimeout(t);
var duration = $('#mainPromotion').find('.active').attr('data-interval');
$('#mainPromotion').carousel('pause');
t = setTimeout(carouselStartPromo, duration - 7000);
});
/* Marquee Unit Tracking (cells tracking in handlebar helpers) */
if (window.marqueeJson.AnalyticId.length > 1) {
$("#mainPromotion").attr("data-tracking", window.marqueeJson.AnalyticId);
}
}
},
"resize": function() {
if (!validFlag) return;
waitForFinalEvent(function() {
updateMarquee();
}, 300, new Date().getTime());
}
});
function updateMarquee() {
});
Going through your code the problem is caused in the css with these styles
section.marquee .next.left,
section.marquee .prev.right {
-ms-opacity: 1;
opacity: 1;
z-index: 0;
}
section.marquee .active.left,
section.marquee .active.right {
-ms-opacity: 0;
opacity: 0;
z-index: 0;
}
Removing these will get it working. What is happening is that the opacity:0; is applying straight away and so you just get a blank square.
If what your looking to do is have a fade out fade in effect on the slides, I think transition : opacity 1s ease; might help.
see below image of class being applied.
line 40,
if (!isNaN(promoPos) && (0 < promoPos) && (promoPos < 3)) {
$('#mainPromotion').carousel(promoPos);
update 4 by 3.

Resources