Utilizing CSS3 transform to rotate text within a bar graph design

Although there are numerous inquiries regarding rotating text using CSS, I have attempted to implement the suggested solutions to my issue without success.

The objective is to design a bar graph, but in certain scenarios data points may be missing. The designer has requested an effect where the text, rotated 90 degrees counterclockwise, replaces the absent bar by forming a column.

HTML:

        <li><div class="bar-missing">Results upcoming</div>
            <span>Aug &rsquo;15</span></li>

CSS:

      .trend-graph #bars li .bar-missing {
        text-transform: uppercase;
        text-align: center;
        color: #00AEEF;
        /* Safari */
        -webkit-transform: rotate(-90deg);
        /* Firefox */
        -moz-transform: rotate(-90deg);
        /* IE */
        -ms-transform: rotate(-90deg);
        /* Opera */
        -o-transform: rotate(-90deg);
        /* Internet Explorer */
        filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); 
}

Using this code, the "column" of text wraps into two lines, is positioned slightly to the right (should align with the x-axis label), and is too high above the x-axis, as demonstrated in this example:

https://jsfiddle.net/wvfy6zje/

If I adjust the width of div.bar-missing, the text displays on a single line, but the parent li container becomes excessively wide. Adding a class to the parent li to restrict the child div.bar-missing did not significantly improve the situation. After researching similar issues on Stack Overflow, managing heights and widths seemed challenging, prompting me to experiment with absolute positioning and negative margins without much progress.

Answer №1

How about this code snippet? https://jsfiddle.net/wvfy6zje/11/

I've taken inspiration from your li.bar layout and applied it to li.bar-blank. Additionally, I included white-space:nowrap to prevent text wrapping:

.trend-graph #amh-bars li .bar-blank {
    text-transform: uppercase;
    text-align: center;
    color: #00AEEF;
    white-space: nowrap; /* Ensures no wrapping */
    width: 27px;         /* Set width */
    margin-left: 15px;   /* Adjusted left margin */
    position: absolute;  /* Positioned absolutely */
    bottom: 10px;        /* Aligned at the bottom */
    transform: rotate(-90deg); /* Rotated -90 degrees */
}

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

Using `object-fit: cover` on an image will cause the parent element's height to be affected

I am currently working on a component that will have variable content, and I want the image to respond like a background image by taking the height of its container instead of defining the height itself. Even when using object-fit: cover, the image still a ...

Zebra lines overlooking unseen details

Imagine having a table where rows can be dynamically assigned classes such as .hidden, which hide those rows using CSS. The rows are styled with alternating colors, like this: tr:nth-child(even) { background-color: $light-grey; } But here's the ...

Pseudo-class for clicking a button on Mobile WebKit

Currently, I am in the process of developing a private framework to replicate the iOS UI using CSS 3 and HTML 5. Most of the widgets have been created, including various colored gradient buttons, but faced with challenges when attempting to incorporate a b ...

Preserving the position of the header and footer while utilizing a combination of grid layout, Bootstrap, and handling

How can I ensure that the page layout does not allow scrolling for the entire page height (100vh), but allows scrolling within a table if necessary? The header and footer should remain fixed at the top and bottom of the page respectively, unaffected by the ...

`Heart-shaped loading bar in Reactjs`

Looking for help in creating a heart-shaped progress loader for a React project. I attempted using CSS but encountered issues with the progress not filling the entire heart design. Below is the code snippet I used. The progress should start from the bottom ...

Ways to create a distinct highlight for the selected link in the navigation upon clicking

Similar Inquiry: How can I highlight a link based on the current page? Situation I have been struggling to keep a selected link in my navigation menu highlighted after it has been clicked. Unfortunately, I haven't come across any straightfor ...

What is the reason behind the change in size and shape of the text when using "overflow: hidden"?

Check out this interactive demo using the provided HTML and CSS: You can view the demo by clicking on this link. /*CSS*/ .header { margin: 0px; padding: 0px; width: 100%; } .headertable { padding: 0px; margin: 0px; width: 100%; border-sp ...

CSS-only countdown animation

I've been experimenting with a pure HTML/CSS countdown animation, but I'm facing challenges in getting it to run smoothly. Currently, I'm focusing on minutes and seconds only. One issue I encountered is that the digit representing tens of mi ...

Is there a way to verify if an element possesses a specific style, and if so, alter the style of a different element accordingly?

Could you assist me in achieving a similar effect as demonstrated below: I have two menus (http://osiyo-nur.uz/osiyo-nur.uz/test6/), one of which is initially invisible. When I hover over the first menu, the second menu becomes visible with an overlay eff ...

"Concealing specific choices in Autocomplete with reactjs: A step-by-step guide

I am looking for a way to hide the selected option in a Dropdown menu so that it does not appear in the next dropdown. For example, if "Hockey" is selected in the first dropdown, it should not be displayed in the second dropdown; only "Baseball and badmint ...

Button click causing display block to fail on HTML table rendering

Upon page load, I have two tables that are hidden. Depending on a condition, one table should display and the other should hide, or vice versa. The issue is that the table is not displaying as expected when triggered. I attempted to use jQuery to hide the ...

Problem with Active State of DOM Element

My goal is to create an effect where clicking on a DOM element, specifically a list, will cause the target list to rotate and remain in that position. Describing it can be a bit challenging, so I have provided a visual example of what I'm working on ...

Percentage outlined

Is there a way to create a .testing element with a width of 100% (150px)? <div class='debug'> <div class='debug'> <div class='testing'>Hello world!</div> </div> </div> *, * ...

Is there a way to retrieve a website and make changes to its HTML and CSS?

I am interested in developing a platform where I can retrieve someone's website and present it using my own CSS. Additionally, I want to remove certain HTML tags from the retrieved content. Can you provide any guidance on how I can achieve this? What ...

Issue with jquery .click function not triggering after CSS adjustment

In the process of creating a fun game where two players take turns drawing on a grid by clicking <td> elements. Currently, I have implemented the functionality to toggle the background color of a <td> element from black to white and vice versa ...

Different ways to customize buttons using CSS

Looking for help with css button styles as a beginner in html. https://i.sstatic.net/LZOlO.png I can comprehend the .button code, but struggling to round the border in red color. Any experts in html and css who can provide assistance? Any guidance would ...

The content's div is not extending completely in the horizontal direction

Just starting out with tailwind CSS and struggling a bit with the design aspect due to my lack of CSS skills. Need some assistance troubleshooting my layout, particularly in making sure the div container stretches to fit the screen size properly. https:// ...

Why is it proving difficult to eliminate margin and padding from the top of the page?

Struggling to remove padding or margin from the top, I attempted to adjust the main container settings: margin-top:0px !important; padding-top:0px !important; Unfortunately, this did not have the desired effect. The code is too lengthy to include in thi ...

Implementing an infinite scrolling feature using Javascript within a specified div element

I'm currently working on implementing an infinite loading feature using JavaScript. I came across this helpful resource that explains how to achieve infinite scrolling without jQuery: How to do infinite scrolling with javascript only without jquery A ...

stop bootstrap collapse from re-activating when an item is clicked

I'm currently facing an issue with my sidebar that is implemented using bootstrap collapsible. The menus are all in tags, but the problem arises when I click on one of these tags - the page refreshes, re-animating the collapsible panel and creating a ...