Utilizing CSS3 transformations for a symbol

I'm currently attempting to implement a CSS transformation on an icon (glyph) within a :before pseudo element.

My primary objective is to execute a simple "flip" animation on the icon using transform: scale(-1, 1), but I am encountering difficulties in applying any type of transformation to a glyph nested within a :before pseudo-element.

Here is a straightforward example:

<!DOCTYPE html>
<html>
    <style>
        .icon 
        { }

        .icon::before {
            content: "X";
            color: white;
            font-size: 11pt;

            transform: scale(5);
        }
    </style>

<body>

    <div style = "padding: 1em; background: black; width: 200px; height: 200px">
        <div class = "icon">

        </div>
    </div>

</body>
</html>

Access the fiddle here: http://jsfiddle.net/729yspsp/1/

In this instance, I am employing a basic X character in place of the actual glyph for illustrative purposes.

It is evident that no transformation has been successfully applied to the glyph.

What could possibly be the mistake in my approach?

Note: This issue is not attributed to browser compatibility as I am utilizing a current version of Chrome (Chrome 37).

Answer №1

CSS Transforms Module Level 1

An element that can be transformed is one whose layout follows the rules of the CSS box model and is either a block-level or atomic inline-level element, or has a display property that computes to table-row, table-row-group, table-header-group, table-footer-group, table-cell, or table-caption.

Therefore, the transform property does not affect strictly inline-level elements.

Pseudo elements are by default set to inline.

You can change the display to inline-block1 or block and it will function as expected.

Updated Example

.icon::before {
    content: "X";
    display: inline-block;
    transform: scale(5, 2);
    -webkit-transform: scale(5, 2);
    -moz-transform: scale(5, 2);
}

1 This converts it into an atomic inline-level box.

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

Adjusting the URL variable based on the selected checkbox option

My mobile website offers users the option of a bright or dark interface using a checkbox styled like an iPhone IOS7 switch. The functionality is working as expected, but I'm now facing an issue with passing the status of the checkbox between pages. I ...

Error: JavaScript Framework (JSF) application experiencing issues with jQuery functionality

I am a beginner when it comes to jQuery. In my Netbeans project, I have the jquery-1.7.2.js file where all HTML files are stored. Currently, I am working on creating a JSF 2.0 project. Below is the code snippet I am using: <?xml version='1.0&apo ...

Materialize CSS dropdown select arrow out of position

Here is a snapshot of the Materialize CSS, which can be viewed at: However, I am encountering an issue where the dropdown arrow appears below the list instead of on the side. I am currently using Django 3. How can I resolve this? https://i.sstatic.net/d ...

LESS: Using variable values in mixin and variable names

I am looking to simplify the process of generating icons from svg-files while also creating a png-sprite fallback for IE8 support. I am using grunt.js and less. I was inspired by the implementation on 2gis.ru: (in Russian), where they used technologies s ...

Examining a specific element node to see if it contains a certain string

When using PHP Unit with Selenium Server, my goal is to verify if a specific element in an xpath contains a certain string value, like this: <table> <thead></thead> <tbody> <tr> <th>1</th> < ...

Creating a changing text color using Material UI and React

How can one dynamically set the text color based on the background color of a component using Material-UI API? If component A has a light background, then the text should be dark. For component B with a black background, the text should be light. (I have ...

Adding options to a select element using JavaScript dynamically

Is there a way to create a dynamic select list for year values using JavaScript? <form action="something"> some other fields <select id="year"> </select> </form> ...

Is there a way for me to specifically show just the initial image contained in the images[] array within the json data?

{"status": true, "data": {"basic": {"dob": "2018-02-02", "gender": "male", "contact": {"address": null}, "is_new": false, "is_email_verified": false, "is_phone_verified": false}, "listings": [{"pid": 109, "category": {"name": "Education"}, "location": {"l ...

Generate a single-page PDF document mirroring the content of a website

I'm facing a dilemma. I need to generate a one-page PDF file without any gaps between the pages. Despite trying numerous plugins, add-ons, scripts, and software, all of them produce multiple pages. What I really require is to have all the pages in a s ...

css setting the dimensions of list items in HTML

Welcome to my page at . Notice how the "Storia del Bernese" menu voice is positioned above the other list items. I would like all list items to have the same height but different widths based on text length. What adjustments should I make in my CSS to ach ...

Unlocking the Power of jQuery's toggle Method for Dynamic Functionality

For my project, I require numerous jQuery toggles to switch between text and icons. Currently, I am achieving this by using: $("#id1").click(function () { //Code for toggling display, changing icon and text }); $("#id2").click(function () { //Same co ...

A distinctive noise is heard when hovering over multiple instances of a div

I'm trying to implement a feature where a unique sound plays when hovering over a specific div element with a particular class (.trigger). However, I am encountering an issue where multiple instances of this div class result in the same sound being pl ...

Is it possible for jQuery UI Tabs to load entire new HTML pages?

In my index.html file, I have set up 3 different tabs. Using the jQuery UI function tabs(), I am attempting to load an HTML page via Ajax. Each HTML page includes the jQuery library and contains the following code: <link type="text/css" href="css/redmo ...

What is the best way to update the content of a div on an HTML page by incorporating the content of a div from a different page using JavaScript?

I have a requirement where I need to implement a link in a Table of Contents that, upon clicking, should replace the existing content of one div on a page with the content of another div on a different page. My goal is to accomplish this using only JavaScr ...

Effective ways to implement Select2 tags while utilizing the newline character tokenSeparator

I'm currently working on a select2 input feature that allows users to paste CSV data and have it converted into tags. One issue I am facing is the inability to create tags from vertically copied data. This is due to select2 using an <input type="te ...

Yii2 Gridview - Horizontal Scroll Bar at the Top of the Page

I found a helpful post on Stack Overflow about creating a Yii2 Gridview with a fixed first column (Yii2 : Gridview with fixed first column), and now I'm looking to add a horizontal scrollbar at the top of the grid. My users really appreciate being ab ...

Position a single div on the left-hand side and arrange two divs on the right using display:flex

Is there a way to achieve this layout without adding another div, using only parents and 3 child elements? I had tried using height: max-content, but it didn't work as expected. .container { display: flex; flex-wrap: wrap; } .item { flex-bas ...

Perfectly aligning css tabs both vertically and horizontally with dead centering technique

Can you help me figure this out? Currently, the tabs in the HTML and CSS provided below are positioned close to the top of the screen. How can I adjust the markup so that the tabs are dead-centered (both vertically and horizontally) instead? Check out th ...

Choosing several buttons in typescript is a skill that every programmer must possess

I need help with selecting multiple buttons in TypeScript. The code I tried doesn't seem to be working, so how can I achieve this? var input = document.getElementById('input'); var result = document.getElementById('result'); v ...

"Creating a custom navigation bar with full width and navigation corners on both left

I am struggling to make my website's navbar stretch to the edges of the container while maintaining full width. I have added left and right padding to each navigation item, but in smaller laptop resolutions, the items break onto a new line, which is n ...