Click and Rotate for More Information

Hello everyone, I have a question regarding creating a unique Tumblr theme. My goal is to make the posts rotate on the y-axis when clicked, revealing like and reblog information. Currently, I've been able to achieve this effect on hover by using code from a specific source but now I need assistance in implementing it for click events instead. I've tried some tutorials involving JavaScript and jQuery without success. Can someone kindly guide me through this process in simple terms as I'm new to these programming languages? Your help is greatly appreciated! Below is a snippet of my CSS:

    #f1_container {
  position: relative;
  margin: 10px auto;
  width: 250px;
  z-index: 1;

  perspective: 1000;
}
#f1_card {
  width: 250px;
  transform-style: preserve-3d;
  transition: all 1.3s linear;
}

#f1_container:hover #f1_card {
  transform: rotateY(180deg);
}
.face {
  position: absolute;
  backface-visibility: hidden;
}
.face.back {
  position: absolute; 
  transform: rotateY(180deg);
  background-color: {color:Text};
  width: 250px;
  top: 0;
  height: 100%;
  box-sizing: border-box;
  text-align: center;
}

...and here is an excerpt of my HTML:

{block:Photo}
{block:IndexPage}
<div id="f1_container">
<div id="f1_card">
  <div class="photo"><div class="front-face"><img src="{PhotoURL-250}" alt="{PhotoAlt}"> </div></div> <div class="back face center">
<div class="perm"><span class="like"style="padding-right:7px">{LikeButton color="grey" size="13"}</span> <span class="rb" style="padding-left:5px;">{ReblogButton color="grey" size="13"}</span> <span class="noteslabel" style="padding-right:5px;"><a href="{Permalink}" target="_blank">{NoteCount}</a></li></ol></div>
  </div>
</div>
</div>
{/block:IndexPage}
{block:PermalinkPage} <img src="{PhotoURL-500}" alt="{PhotoAlt}"> {/block:PermalinkPage} {/block:Photo} 

Just to give you a glimpse, here's a link to my site: . It might seem messy right now as it's where I test my themes in progress.

Answer №1

It's my understanding that Tumblr does support the integration of jQuery and Javascript. To enable jQuery in your file, simply include this at the beginning:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

After doing this, you can start using jQuery by creating a click function like so:

var r=0;
$(document).ready(function() {
    $('#Image-ID-or-DIV').click(function(){   
        $("#Image-ID-or-DIV").css("transition", "500ms linear all");                    
        $("#imgs").css({transform: 'rotateY(' + (r += 180) + 'deg)'});
    });
});

1) Setting r=0 is crucial for resetting the animation once it completes.

2) The document.ready function is a fundamental part of jQuery, nothing too complex.

3) This snippet indicates that when a specific image with an ID is clicked, a function will be triggered.

4) By specifying the transition duration to be 500 milliseconds, the rotation effect will appear smooth and gradual upon clicking the image.

5) The actual image rotation occurs here based on the specified degree value. Refer to documentation for more details.

If you wish to add additional CSS styling when the image is clicked, you can do so by including:

$("#Image-ID-or-DIV").css('[place your CSS here]')

It's recommended to consult documentation regarding the proper usage of jQuery .css() method.

I trust this information proves helpful to you!

Answer №2

I believe Ramsay was heading in the right direction by using :focus. To improve, consider enclosing f1_container within an anchor tag like so:

<a href="#" class="focus-wrapper"> <!--also avoid reusing IDs - they should be unique-->
  <div class="f1_container"> 
     <!-- insert code here -->
  </div>
</a>

Furthermore, eliminate any special anchor styles as recommended in HTML Anchor, Disable Style:

.focus-wrapper:hover, .focus-wrapper:visited {
   text-decoration: inherit;
   color: inherit;
   cursor: auto;
}

Create a rule to apply changes on focus:

.focus-wrapper:focus .f1_container .f1_card {
   transform: rotateY(180deg);
}

Don't forget to remove the browser's focus outline:

.focus-wrapper:focus {
   outline:none;
}

If it isn't clear, remember to remove the existing rule that resembles:

#f1_container:hover #f1_card {
   transform: rotateY(180deg);
}

See an example here: http://jsfiddle.net/yb9exv9b/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best approach for loading locally stored images conditionally in Vue.js?

<template> <div> <div v-if="item"> <h1>Price: {{ item.email }}</h1> <v-if item.email=="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="670d080f0927000a060e0b4904080a">[email& ...

What is causing my nested class to be treated as a sibling rather than a child in HTML code

I have been searching for a clear answer to my query, but haven't found one yet. In my HTML script, I have nested divs structured like this: <ul id="navbar"> <li><a href='#' class='dropdown'>Rules</a> ...

Utilizing PHP to Extract Information through cURL and HTML Parsing

Is there a way to search through an HTML page specifically for text contained within a particular div element? ...

Experiencing difficulties when attempting to launch a React application and Express/Node.js backend on a shared port

I'm trying to set up my react front-end on localhost:5000, with API requests going to localhost:5000/api/some-path. After looking at similar questions, I've come to understand the following: Include a proxy in the package.json file Serve st ...

Creating a user authentication portal

Looking for advice on creating a basic front end HTML login. I'm new to coding and would appreciate any suggestions! Additionally, how can I link the login system to my database? ...

Converting HTML divs into a single page PDF document using DinkToPdf

Having trouble generating PDF from HTML using DinkToPdf due to div elements splitting across pages? Is there a way to ensure the entire div stays on one page, perhaps through html/css? Ideally, if there is sufficient space, the div should remain on the c ...

What is the best way to utilize toggle("slide") in order to reveal a message letter by letter?

I am currently experimenting with the `.toggle("slide") function to create an effect where a piece of text appears as though each letter is sliding in. However, I've noticed that instead of a smooth slide, it looks more like the text is flying in abru ...

The Puppeteer software does not automatically shut down the browser once the task is complete

Currently, I have set up puppeteer on my Ubuntu server with Express and Node.js like so: var puppeteer = require('puppeteer'); var express = require('express'); var router = express.Router(); /* GET home page. */ router.get('/&ap ...

What is the best way to make a panel width adjust automatically to fit the screen width?

I have developed a React/Material UI application that includes a Portal which showcases a Panel and a Widget. Main App: Show Portal and Set Background Color to Blue export default function App() { return ( <div style={{ backgroundC ...

Utilizing a Json.Net object within an Ajax request

Is there a way to pass a .Net object in an Ajax call using the Json.Net javascript library instead of json2.js? You can find more information on passing complex types via Ajax calls at this link: I am familiar with how to serialize and deserialize object ...

Eradicating a character from an Object using Jquery/Javascript

Looking at this code snippet, it appears that the 3rd column is not calculating correctly due to a comma being present in one of the values. Is there a way to rectify this issue without directly removing the comma? I am aware that using .replace(/,/g,&apos ...

Submitting via AJAX upon submission

I've implemented the following code in my comment.php: <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script type="text/javascript"> $(function() { $('#reset_form').cl ...

The functionality of jQuery's onclick event is not functioning as intended

I have been struggling to make the onclick event work, but unfortunately it is not happening for me. Here is the code I am working with: HTML <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de"> <head> ...

How can I implement disabling buttons for specific IDs in React?

I'm currently developing an interactive quiz application with React that features multiple choice questions. I've implemented state management to track and increment the user's score when they select the correct answer option, but there&apos ...

Creating a Custom Select Option Component with Ant Design Library

Is it possible to customize options in an antd select component? I have been trying to render checkboxes alongside each option, but I am only seeing the default options. Below are my 'CustomSelect' and 'CustomOption' components: // Cu ...

ways to verify ng-if post modification occurrence

Currently, my project is utilizing Angular 6. In the code, there is a div element with *ng-if="edited" as shown below: <div *ngIf="edited"> {{langText}} </div> Initially, when the page loads, edited is set to false and the div is not vis ...

Design a layout consisting of a grid with items that maintain a set maximum width while being evenly distributed across the entire width of the device

I'm trying to create a grid with 2 rows and 3 columns, each cell having an image with a max-width of 512px. I added margin to the grid but now the cells are larger than the content. How can I achieve the same visual appearance as flexbox's justif ...

Angular: issue with accessing deferred variable within then-method

When working with my Angular.JS code, I encountered an issue while calling the Yahoo YQL API using GET/JSONP. Although I receive a response, there are two specific problems that arise. Instead of triggering the success method, it calls the error method. ...

Improving performance in Next.JS by optimizing unused JavaScript resources

Currently working on my first website using Next.js and experiencing poor performance scores after running a lighthouse test. The issue seems to be related to unused JavaScript files located in the chunk folder. I've come across suggestions to split t ...

Retrieve only the initial tag content using jquery

My goal is to extract the "22" from the following code... <div class="left"> <a class="count-link" href="http://url1.com"> <span>22</span> users </a> <a class="count-link" href="http://url2.com"> <span>10</span ...