I'm using the hamburger toggling method from the AMP-WP website and replaced the text with a symbol ☰ to create the hamburger.
https://amp-wp.org/documentation/playbooks/toggling-hamburger-menus/
<?php echo( '☰' ); ?>
Everything works great, apart from I'd like to change the symbol to ✕ when the menu is open/active.
What PHP is required to do this please?
You need to take a different approach where your icon is really a set of HTML elements where each line is separate and can be targeted by animation, CSS transforms in this case:
const hamburger = document.querySelector('#hamburger-toggle');
hamburger.addEventListener('click', function() {
if (this.classList.contains('open')) {
this.classList.remove('open');
} else {
this.classList.add('open');
}
});
#hamburger-toggle {
position: relative;
cursor: pointer;
height: 40px;
width: 50px;
margin: 10px 0;
padding: 10px 0;
}
.hamburger-line {
display: block;
width: 24px;
height: 2px;
background-color: black;
margin-top: 6px;
opacity: 1;
}
.hamburger-line-1 {
margin-top: 0;
}
.hamburger-line-1, .hamburger-line-3 {
transform-style: preserve-3d;
transition: transform 200ms; /* this line animates the change in position */
transform: translateY(0px) rotateZ(0deg);
}
.hamburger-line-2 {
transition: opacity 200ms; /* this line animates the change in opacity fading in/out the middle hamburger line */
}
#hamburger-toggle.open .hamburger-line-1 {
transform-style: preserve-3d;
transition: transform 200ms;
transform: translateY(8px) rotateZ(44deg);
}
#hamburger-toggle.open .hamburger-line-2 {
transition: opacity 200ms;
opacity: 0;
}
#hamburger-toggle.open .hamburger-line-3 {
transform-style: preserve-3d;
transition: transform 200ms;
transform: translateY(-8px) rotateZ(-44deg);
}
<div id="hamburger-toggle">
<span class="hamburger-line hamburger-line-1"></span>
<span class="hamburger-line hamburger-line-2"></span>
<span class="hamburger-line hamburger-line-3"></span>
</div>
Related
css: owl.carousel.min.css
.owl-carousel,
.owl-carousel .owl-item {
-webkit-tap-highlight-color: transparent;
position: relative
}
.owl-carousel {
display: none;
width: 100%;
z-index: 1
}
.owl-carousel .owl-stage {
position: relative;
-ms-touch-action: pan-Y;
-moz-backface-visibility: hidden
}
.owl-carousel .owl-stage:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0
}
.owl-carousel .owl-stage-outer {
position: relative;
overflow: hidden;
-webkit-transform: translate3d(0, 0, 0)
}
.owl-carousel .owl-item,
.owl-carousel .owl-wrapper {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0)
}
.owl-carousel .owl-item {
min-height: 1px;
float: left;
-webkit-backface-visibility: hidden;
-webkit-touch-callout: none
}
.owl-carousel .owl-item img {
display: block;
width: 100%
}
.owl-carousel .owl-dots.disabled,
.owl-carousel .owl-nav.disabled {
display: none
}
.no-js .owl-carousel,
.owl-carousel.owl-loaded {
display: block
}
.owl-carousel .owl-dot,
.owl-carousel .owl-nav .owl-next,
.owl-carousel .owl-nav .owl-prev {
cursor: pointer;
cursor: hand;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none
}
.owl-carousel.owl-loading {
opacity: 0;
display: block
}
.owl-carousel.owl-hidden {
opacity: 0
}
.owl-carousel.owl-refresh .owl-item {
visibility: hidden
}
.owl-carousel.owl-drag .owl-item {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none
}
.owl-carousel.owl-grab {
cursor: move;
cursor: grab
}
.owl-carousel.owl-rtl {
direction: rtl
}
.owl-carousel.owl-rtl .owl-item {
float: right
}
.owl-carousel .animated {
animation-duration: 1s;
animation-fill-mode: both
}
.owl-carousel .owl-animated-in {
z-index: 0
}
.owl-carousel .owl-animated-out {
z-index: 1
}
.owl-carousel .fadeOut {
animation-name: fadeOut
}
#keyframes fadeOut {
0% {
opacity: 1
}
100% {
opacity: 0
}
}
.owl-height {
transition: height .5s ease-in-out
}
.owl-carousel .owl-item .owl-lazy {
opacity: 0;
transition: opacity .4s ease
}
.owl-carousel .owl-item img.owl-lazy {
transform-style: preserve-3d
}
.owl-carousel .owl-video-wrapper {
position: relative;
height: 100%;
background: #000
}
.owl-carousel .owl-video-play-icon {
position: absolute;
height: 80px;
width: 80px;
left: 50%;
top: 50%;
margin-left: -40px;
margin-top: -40px;
background: url(owl.video.play.html) no-repeat;
cursor: pointer;
z-index: 1;
-webkit-backface-visibility: hidden;
transition: transform .1s ease
}
.owl-carousel .owl-video-play-icon:hover {
-ms-transform: scale(1.3, 1.3);
transform: scale(1.3, 1.3)
}
.owl-carousel .owl-video-playing .owl-video-play-icon,
.owl-carousel .owl-video-playing .owl-video-tn {
display: none
}
.owl-carousel .owl-video-tn {
opacity: 0;
height: 100%;
background-position: center center;
background-repeat: no-repeat;
background-size: contain;
transition: opacity .4s ease
}
.owl-carousel .owl-video-frame {
position: relative;
z-index: 1;
height: 100%;
width: 100%
}
.owl-carousel .owl-wrapper-outer{
overflow: hidden;
position: relative;
width: 100%;
z-index: 1;
}
.owl-item {
transform: translateZ(0);
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
}
index.php
<script>
$(document).ready(function(){
$(".owl-carousel").owlCarousel({
navigation : false,
rtl:true,
slideSpeed : 300,
paginationSpeed : 400,
singleItem:true
});
});
</script>
<div class="col-xl-12">
<div class="product-tab-content">
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<div class="product-active owl-carousel">
<?php
foreach($deal as $row)
{
$img = explode(",",$row['product_image']);
?>
<div class="pro-item">
<div class="product-wrapper">
<div class="product-img">
<a href="<?php echo base_url(); ?>details/<?php echo $row['product_id']; ?>">
<?php
if(!empty($img[0]))
{
?>
<img src="<?php echo base_url(); ?>product/<?php echo $img[0]; ?>" alt="">
<?php
}
else
{
?>
<img src="<?php echo base_url(); ?>product/product_not.jpeg">
<?php
}
?>
</a>
</div>
<div class="product-content pt-15">
<h4>
<?php echo $row['product_name']; ?>
</h4>
<div class="product-meta">
<div class="pro-price f-left">
<span><?php echo $row['unit_price']; ?></span>
<span class="old-price"><?php echo $row['old_price']; ?></span>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
I am developing a eCommerce website where I am showing some product which are perfectly showing and previous and next button are also working perfectly but product are not sliding automatically. I had tried so many thing like jquery, css but I am not able to find any solution. How can I automatically slide my product? Please help me.
Thank You
put your js code below the html and add the line (autoplay:true) to the function.
$(document).ready(function(){
$(".owl-carousel").owlCarousel({
navigation : false,
rtl:true,
slideSpeed : 300,
paginationSpeed : 400,
autoplay:true,
singleItem:true
});
});
You could use Swiper is better than owl carousel.
Swiper
- is the free and most modern mobile touch slider with hardware accelerated transitions and amazing native behavior. It is intended to be used in mobile websites, mobile web apps, and mobile native/hybrid apps. Designed mostly for iOS, but also works great on latest Android, Windows Phone 8 and modern Desktop browsers.
Swiper is not compatible with all platforms, it is a modern touch
slider which is focused only on modern apps/platforms to bring the
best experience and simplicity.
In the owl.carousel.js file
search for transform you should find something like this
transform: 'translate3d("+b+"px,0px,0px)'
see this "+b+" replace it with "+-b+" it ends up like this
transform: "translate3d(" + -b + "px,0px, 0px)"
Notes this will not work in ltr versions so in my case I am using dynamic application so made 2 files and I called the English version without minus " + b + " and the rtl I added this minus.
it may help someone.
Context:
I've been working on the front and back-end for a fun startup company for the last month. There is a profile page on the website for users who are logged in. As shown below in its default state:
Default state
Using the 'checkbox' hack / trick, by clicking on the setting icon (as referenced through the label tag in the css below) The logged in user can open a side menu, with settings and options for their account as shown below:
The menu expanded
The problem:
Clicking on the profile text is supposed to create a drop-down menu so that the user can upload their own profile picture. I was hoping to do this through the same checkbox hack as before. However, when clicking on the profile text (referenced as h1), the checkbox is ticked but the background (referenced as .sidebar h1) doesn't change its colour to red. I think this is because of a problem with the :checked function in css, because when I click on the profile text I can see the checkbox become checked and unchecked.
Of note:
I can use javascript, but it's really not preferable (the person I'm working for isn't a big fan.)
Here is the whole file: https://pastebin.com/E0H6HgRe
CSS
.sidebar {
background-color: white;
position: fixed;
top: 0;
width: 0;
bottom: 0;
}
input#slide-sidebar[type="checkbox"] {
display: none;
}
input#slide-sidebar:checked ~ .sidebar{
left: 0;
width: 201;
z-index: 3;
-webkit-transition: width 2s;
transition: width 2s;
}
.setting {
font-size: 100px;
color:black;
z-index: 0;
background-color:white;
position: fixed;
left: 18.8%;
width: 100%;
}
input#slide-sidebar:not(:checked) ~ .sidebar {
width: 0;
-webkit-transition: width 2s;
transition: width 2s;
}
h1{
color: #222;
font-size: 20;
letter-spacing: 1px;
text-decoration: none;
text-transform: uppercase;
color:black;
left: 0px;
opacity:0;
position: fixed;
top: 200px;
}
input#slide-sidebar:checked ~ .sidebar h1 {
opacity: 1;
transition: opacity 1s ease-in;
-webkit-transition: opacity 1s ease-in;
}
input#slide-sidebar:not(:checked) ~ .sidebar h1 {
opacity: 0;
transition: opacity 0.5s ease-out;
-webkit-transition: opacity 0.5s ease-out;
}
input#profile-pic:checked ~ .sidebar h1 {
background-color: red;
}
Php (html running inside php)
echo "<div class='main-wrap'><input id='slide-sidebar' type = 'checkbox' role='button' /> <label for='slide-sidebar' class='setting'><span><i class = 'fa fa-cog'></i></span></label><div class='sidebar'>
<input id='profile-pic' type = 'checkbox' role='button' /><label for='profile-pic'><span><h1> Profile</h1></span></label></div>";
Through PHP the steps are counted and added in a session to avoid returning to the beginning in case of updating or refreshing the page, the value is obtained by means of the following variable $step
<?php
session_start();
if ( !empty($_SESSION['datos_form']['__step__'])) {
$step = $_SESSION['datos_form']['__step__'];
} else {
$step = '1';
}
?>
We receive the value of the variable in the jQuery javascript code.
show_step(<?= $step; ?>);
That would be equal to: (for the default value received)
show_step(1);
Each step of the process is shown according to the value received from PHP to the Javascript code as it was already mentioned.
Without the need to add additional controls like the following:
current = $(this).parent();
next = $(this).parent().next();
I have the following simple wizard with CSS
https://jsfiddle.net/2LL8x1sm/
I need to be able to adapt it to the ajax javascript code so that it animates the step in which it is.
The current code already had an animation using a technique called sprite
function animacion(caso){}
What I need is to be able to adapt the animation of the process, and using an icon (like this one) that goes sliding with the bar of progress similar to the following image:
This animation must be added inside the function animacion(caso) {} that works together with the back links and continue, add an example within the fuction in the following code:
$( ".test" ).animate({ "left": "-=50px" }, "slow" );
And in effect it works, the div with the test class was modifying the left style by continuing in each step.
How can I animate the process of my html code css?
$(function() {
show_step(<?= $step; ?>);
});
function animacion(caso){
//$( ".test" ).animate({ "left": "-=50px" }, "slow" );
};
// function to save the form data and change the step
function show_step(step){
var data = $( "#form" ).serialize();
var url = 'saveTemp.php?step=' + step;
$.ajax({
type: "POST",
url: url,
data: data
})
.done(function( resp ) {
$('.step').css( "display", "none" );
$('#step'+step).fadeIn("slow");
//animation of each step
animacion(step);
});
};
.container {
width: 100%;
padding-top: 20px;
}
.progressbar li {
list-style-type: none;
float: left;
width: 33.33%;
position: relative;
text-align: center;
}
.progressbar li > * {
position: relative;
padding-bottom: 20px;
display: inline-block;
font-size: 1.4rem;
color: #2c3f4c;
top: -45px;
}
.progressbar li:before {
content: '';
width: 12px;
height: 12px;
display: block;
text-align: center;
margin: 0 auto;
border-radius: 50%;
background-color: #edeff0;
}
.progressbar li:after {
content: '';
position: absolute;
width: 100%;
height: 4px;
background-color: #edeff0;
top: 4px;
left: -50%;
z-index: -1;
}
.progressbar li:first-child:after {
content: none;
}
.progressbar li.active {
color: green;
}
.progressbar li.active:before {
background-color: green;
}
.progressbar li.active + li:after {
background-color: green;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- <div class="test"></div> -->
<div class="container">
<ul class="progressbar">
<li class="active"><span>Step 1</span></li>
<li><span>Step 2</span></li>
<li><span>Step 3</span></li>
</ul>
</div>
<form id="form" action="procesar.php">
<div id="step1" class="step">
<h1>step 1</h1>
<a data-ref="#" onclick="show_step(2)">continue</a>
</div>
<div id="step2" class="step">
<h1>step 2</h1>
<a data-ref="#" onclick="show_step(1)">after</a>
<a data-ref="#" onclick="show_step(3)">continue</a>
</div>
<div id="step3" class="step">
<h1>step 3</h1>
<a data-ref="#" onclick="show_step(2)">after</a>
<button>Send</button>
</div>
</form>
Is this correct understanding of what you need?
function animacion(caso) {
if (!caso) {
document.getElementsByClassName("progressbar")[0].setAttribute("data-active", "");
} else {
document.getElementsByClassName("progressbar")[0].setAttribute("data-active", caso);
}
var items = document.getElementsByTagName("li");
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (!caso) {
item.className = "";
} else if (i < caso) {
item.className = "active";
} else {
item.className = "";
}
}
}
setTimeout(function () {
animacion(1);
}, 1000);
setTimeout(function () {
animacion(2);
}, 2000);
setTimeout(function () {
animacion(3);
}, 3000);
setTimeout(function () {
animacion(2);
}, 4000);
setTimeout(function () {
animacion(1);
}, 5000);
setTimeout(function () {
animacion(null);
}, 6000);
.container {
width: 100%;
}
.progressbar {
counter-reset: step;
}
.progressbar li {
list-style-type: none;
float: left;
width: 33.33%;
position: relative;
text-align: center;
}
.progressbar li > * {
position: relative;
padding-bottom: 20px;
display: inline-block;
font-size: 1.4rem;
color: #2c3f4c;
top: -45px;
/* new code start */
top: -65px;
/* new code end */
}
.progressbar li:before {
content: '';
width: 12px;
height: 12px;
display: block;
text-align: center;
margin: 0 auto;
border-radius: 50%;
background-color: #edeff0;
}
.progressbar li:after {
content: '';
position: absolute;
width: 100%;
height: 4px;
background-color: #edeff0;
top: 4px;
left: -50%;
z-index: -1;
}
.progressbar li:first-child:after {
content: none;
}
.progressbar li.active {
color: green;
}
.progressbar li.active:before {
background-color: green;
/* new code start */
-webkit-transition: background 300ms ease;
transition: background 300ms ease;
-webkit-transition-delay: 300ms;
transition-delay: 300ms;
/* new code end */
}
/* removed code start */
/*
.progressbar li.active + li:after {
background-color: green;
}
*/
/* removed code end */
/* new code start */
.progressbar {
position: relative;
padding: 0;
margin: 0;
}
.progressbar:after {
content: "";
height: 4px;
left: 16.666%;
background: green;
top: 4px;
position: absolute;
-webkit-transition: width 300ms ease;
transition: width 300ms ease;
}
.progressbar[data-active="1"]:after {
width: 0;
}
.progressbar[data-active="2"]:after {
width: 33%;
}
.progressbar[data-active="3"]:after {
width: 66%;
}
.progressbar[data-active=""]:before {
opacity: 0;
}
.progressbar:not([data-active=""]):before {
opacity: 1;
-webkit-transition: left 300ms ease, opacity 300ms ease;
transition: left 300ms ease, opacity 300ms ease;
}
.progressbar[data-active="1"]:before {
left: 16.666%;
}
.progressbar[data-active="2"]:before {
left: 50%;
}
.progressbar[data-active="3"]:before {
left: 83.333%;
}
.progressbar:before {
content: "";
height: 16px;
width: 16px;
margin-top: -24px;
margin-left: -8px;
left: 16.666%;
background: khaki;
top: 4px;
position: absolute;
-webkit-transition: left 300ms ease;
transition: left 300ms ease;
}
/* new code end */
<div class="container">
<br><br><br><br><br><br>
<ul class="progressbar" data-active="">
<li><span>Step 1</span></li>
<li><span>Step 2</span></li>
<li><span>Step 3</span></li>
</ul>
</div>
There is minor change in markup and style. Rectange indicates block where you can insert your icons.
I want to hover over an image (music album) and then a record rolls out, so I want it to move to the right and to rotate a bit. It can already move to the right but I can't get it to rotate with it.
the #cover1 is the album and the #coverrecord1 is the record that needs to roll out, i like to keep it as simple as possible as i am not a pro in coding.
Many thanks.
$(document).ready(function (){
$("#cover1").hover(
function() {
$("#coverrecord1").stop().animate({ left: '5%' });
},
function() {
$("#coverrecord1").stop().animate({ left: '0' });
}
);
});
You can also skip js if you wish :)
.album {
background-color: orange;
height: 10em;
margin: 3em auto;
position: relative;
width: 10em;
}
.album:after, .album:before {
content: "";
display: block;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
.album:after {
background-color: orange;
z-index: 1;
}
.album:before {
background-image: linear-gradient(to left, gray, black);
border-radius: 50%;
transition: transform 500ms;
}
.album:hover:before {
transform: translate3d(40%, 0%, 0) rotate(30deg);
}
<div class="album"></div>
Actually I don't know how to search this issue, if it is css or php issue.
I have a div that opens a hidden div.
When I test the code outside the website it works fine. When I tested inside the website I took this.
see the picture here (http://grab.by/H8TW)
The full construct of the code is:
<ol>
<div><div>
<div></div>
<div>
<li>
<div class="lyrics">
<article>
<input type="checkbox" id="read_more" role="button">
<label for="read_more" onclick=""><span>Lyrics</span><span>Hide Lyrics</span></label>
<section></section>
<section><?php $lyric = get_post_meta(get_the_ID(), '_lyrics', true); echo $lyric; ?>
</section>
</article>
</div>
</div>
</li>
</ol>
CSS
div.lyrics {
position: relative;
top: 10px;
}
article {
margin-bottom: 3rem;
position: relative;
*zoom: 1;
}
article:before, article:after {
content: "";
display: block;
}
article:after { clear: both }
article figure {
float: right;
width: 32.5%;
}
article section:first-of-type {
float: left;
width: 62.5%;
}
article section:last-of-type {
display: none;
visibility: hidden;
}
section {
-webkit-transition: .125s linear;
-moz-transition: .125s linear;
-ms-transition: .125s linear;
-o-transition: .125s linear;
transition: .125s linear;
}
input[type=checkbox] {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
}
[for="read_more"] {
position: absolute;
bottom: -3rem;
left: 0;
width: 100%;
text-align: center;
padding: .65rem;
box-shadow: inset 1px 1px rgba(0, 0, 0, 0.1), inset -1px -1px rgba(0, 0, 0, 0.1);
}
[for="read_more"]:hover {
background: rgba(0,0,0,.5);
color: rgb(255,255,255);
}
[for="read_more"] span:last-of-type {
display: none;
visibility: hidden;
}
input[type=checkbox]:checked ~ section {
display: block;
visibility: visible;
width: 100%;
}
input[type=checkbox]:checked ~ figure { width: 100% }
input[type=checkbox]:checked ~ [for="read_more"] span:first-of-type {
display: none;
visibility: hidden;
}
input[type=checkbox]:checked ~ [for="read_more"] span:last-of-type {
display: block;
visibility: visible;
}
Thanks for any help!
The solution of the problem came from the text editor, where I use enter for each break (< br >) I wanted to have! So every text line was a paragraph (< p >).