Reverse Text without Using CSS Transformation

I have a unique clock design where the hands are actually words (for example: < p >WORD< /p >), but when they pass 180deg, they naturally turn upside down. Normally, flipping them using transform properties like rotate would be simple, but since transform is the only method setting the hands at the correct time, I cannot use any other transform CSS that might disrupt it.

Is there an alternative solution to flip the text as soon as it reaches 180deg?

Here is a snippet of the CSS code:

#shortHand{
    -webkit-transform: rotate(270deg);
    transform: rotate(270deg);
    -webkit-transform-origin: 10% 70%;
    transform-origin: 0% 50%; }

And here is an example in JavaScript for setting the time:

shortHand.style.transform = `rotate(${currH}deg)`;

Answer №1

Experience the magic of text flipping at 180-degree intervals:

HTML

 <div id="shortHand">
  <span>word</span>
 </div>

CSS

#shortHand {
  transform: rotate(270deg);
  transform-origin: 0% 50%;
}

#shortHand span {
  display: inline-block;
}

JS

var shortHand = document.querySelector('#shortHand');
var shortHandWord = document.querySelector('#shortHand span');

var deg = 270;
var i = -1;

setInterval(function() {
  shortHand.style.transform = `rotate(${deg}deg)`;

  if (deg % 180 === 90) {
    i *= -1;
    shortHandWord.style.transform = `scale(${i})`;
  }

  deg++;
}, 10);

View the live demo on JSFiddle: https://jsfiddle.net/8nr98381/6/

Answer №2

Experiment with vertical text using the CSS3 writing-mode feature. Check out this informative article on writing-mode in CSS3:

uniquecontent.org/post/23847619257/css3-vertical-text

For information on browser support for the writing-mode property, visit Check Compatibility

Hopefully this solution suits your needs!

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

Utilize Typescript or JavaScript to dynamically access the names and values of class members

I'm relatively new to these programming languages and I know it may not be too difficult, but I am struggling to figure out how to dynamically access class instance variables. My goal is to display an instance's variables in a table using Angula ...

Is the JSON data not matching the file's content during validation?

After thorough testing, my JSON data appears to be functioning correctly with regular content. Here is a sample of the working JSON: Working Json { "language": "XYZ", "content": { "GEN": "this is test& ...

How to extract various arrays of identical objects from a larger array in JavaScript

I am working with an array containing objects of this structure: {id: 543, firstName: 'Ted', lastName: 'Foo', age: 32} My goal is to filter out objects in the array that have the same values for both the firstName and age properties. ...

Exploring the power of JSON and JavaScript: A guide to efficiently reading lists through JSON manipulation

I am facing an issue where I am unable to read an object using the method below function loadData(){ $.getJSON('data.json', function(data) { $.each(data, function(Index, entry) { mem = new user(entry.name, entry.age, entr ...

Divide the toggle buttons into separate rows for better organization

Snippet: <mat-button-toggle-group value="0" (change)="toggleChangeQuestion($event)" name="selectQuestions" #group2="matButtonToggleGroup"> <div *ngFor="let item of test; let i = index;"> ...

A guide to calculating the sum of columns using TypeScript and integrating it with Angular 8

Currently, I am attempting to calculate the average of all columns and display it at the footer of my table. The table data is fetched from an API resulting in a structure like this: <tr *ngFor="let item of items"> <td>{{item.num1 ...

Collapsed Navigation Bar in Bootstrap 4

I'm in the process of reorganizing my collapsed navbar, which was created using Bootstrap 4. Currently, it appears like this: https://i.sstatic.net/yxvvA.png Is there a method to align the social media buttons on one line, shift 'About' fu ...

Looking for a way to update the content inside a div using JavaScript or jQuery?

I have a function that allows me to load a webform/popup above my page test.aspx $(document).ready(function () { $('#<%= webform.ClientID %>').load('pop_up_one.html');}) Now, I want to change the inner HTML of this popup wit ...

Difficulty with making HTTP Requests in Node.js

It's like I'm stuck in a maze trying to find my way out. I could use some guidance on unraveling the mystery behind the appearance of "[object Object]" and understanding the error message. Any assistance in steering me towards the correct path w ...

Resize SVG to match the size of the browser

I need help making an SVG responsive to fit the browser window properly. Can someone provide guidance on how to achieve this? Here is a preview: https://i.sstatic.net/sAUny.png <svg height="100%" viewBox="0 0 1440 760" fill= ...

Real-time Exchange of HTML Data Forms

Hey everyone, I am completely new to programming and I would really appreciate your guidance through this process. Let's imagine a scenario where two users need to communicate through HTML forms. The first user fills out an HTML form (first name, la ...

Combining sticky user input and button side by side using CSS

I'm having trouble getting a user input and button to appear side by side and stay sticky at the top of the screen as you scroll. I've attempted using the float: left method and display:inline-block, but haven't had any success. Here is the ...

Unable to use saved images with jQuery Slider

I'm currently facing an issue with adding a jQuery slider to my website. It seems that the slider is not displaying images that are saved on my computer, only images from external websites. Below is the code snippet where I have included an image fil ...

guide on executing a function for dynamically added selections

When dynamically adding HTML elements to the page, I encountered an issue where using a "bind" wasn't practical due to multiple items being added at different times. As a solution, I opted for an inline function, which unfortunately only worked on bro ...

I'm having trouble executing the straightforward code I discovered on GitHub

https://github.com/Valish/sherdog-api Upon downloading the sherdog-api, I embarked on installing node.js as a prerequisite for using this new tool, despite having no prior experience with such software. Following that, I opened up the command prompt and n ...

What caused the failure of my asynchronous test in React?

When trying to test a React component using Jest and the React Testing Library, I'm facing difficulty with asynchronous tests. It seems like there might be a syntax error causing the issue. The component is being rendered correctly and the fetch opera ...

What is causing the col divs to stack instead of aligning next to each other?

I am a newcomer to Vue.JS and front-end programming in general. I wanted to create a page with a fixed sidebar and content below a navbar. Here is the configuration I tried: <template> <div class="container-fluid"> <div class ...

Avoid adding duplicate elements by redirecting to the already existing element

Here is my method for adding elements to a list, which contains links to articles, using an input field: Template.addForm.events({ 'submit form': function(event){ event.preventDefault(); var title = event.target.text.value; ...

The API response was blocked due to the CORS header "Access-control-allow-origin."

I have an index.html file that is used for making HTML and Ajax calls. When I run the file through localhost, the API works perfectly. However, if I directly open the index.html file in Google Chrome or Mozilla Firefox, I encounter a CORS (Cross-Origin Re ...

Strategically handling the intricacies of JavaScript within an extensive project

How can I effectively handle the increasing number of JavaScript files in my application? We are developing a Django application with multiple apps, each serving different functions and requiring rendering across three modes (PC, tablet, mobile). Our Java ...