Is it possible to increase font sizes without changing the overall height of the text?

In my current project, I am experimenting with a CSS Grid layout featuring 2 rows and 1 column. Within this layout, I have placed a word that dominates the entire view-port by setting its font size to 23rem;. Inspired by this music album cover, I am attempting to recreate it using only CSS and HTML.

The top row of my grid contains the letters "U" and "N," with the letter "N" extending further than the adjacent letter "U." Looking closely, you will notice that while the bottom of the "U" does not touch the letter below (the "T"), the long tail of "N" reaches out to touch surrounding elements.

If both letters share the same height and alignment, how can I accurately replicate the album cover? Should I use SVG text or draw these patterns in SVG format? In case CSS cannot achieve the desired effect, what alternatives should be considered?

https://i.sstatic.net/RpIIO.png

* {
                box-sizing: border-box;
            }

            body, html {
                margin: 0;
                padding: 0;
                font-size: 16px;
            }

            p {
                font-family: sans-serif;
            }

            li {
                list-style-type: none;
                font-family: sans-serif;
            }

            .unity-cover {
                display: grid;
                grid-template-columns: 1fr;
                grid-template-rows: 2fr 2fr;
                grid-template-areas: 
                "start-row"
                "end-row";
                justify-items: center;
            }

            .start-row {
                grid-area: start-row;
                display: flex;
            }

            .end-row {
                grid-area: end-row;
                display: flex;
            }
            
            /*CSS styles for each individual letter*/
            
            
<body>

    <ul class="unity-cover">
        <div class="start-row">
            <li class="letter letter-u">U</li>
            <li class="letter letter-n">N</li>
        </div>

        <div class="end-row">
            <li class="letter letter-i">I</li>
            <li class="letter letter-t">T</li>
            <li class="letter letter-y">Y</li>
        </div>


    </ul>

</body>

Answer №1

To adjust the scale of an element, you can utilize transform: scaleX(n), where 'n' represents the desired scale value.

A similar approach can be taken to alter the height by using transform: scaleY(n).

If you find that the font does not align perfectly with your design, consider using an SVG for better results. For example, on the album cover, the letter 'N' may touch the left side but not the right side.

When it comes to manipulating fonts, keep in mind that the transform property offers more than just scaling options.

* {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    font-size: 16px;
}

p {
    font-family: sans-serif;
}

li {
    list-style-type: none;
    font-family: sans-serif;
}

.unity-cover {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 2fr 2fr;
    grid-template-areas: 
    "start-row"
    "end-row";
    justify-items: center;
}

.start-row {
    grid-area: start-row;
    display: flex;
}

.end-row {
    grid-area: end-row;
    display: flex;
}

.letter {
    font-weight: bold;
    margin-right: 1px;
    font-size: 23rem;
}

.letter-u {
    height: 300px;
    position: relative;
    top: 34px;
    left: -28px;
    vertical-align: baseline;
    transform: scaleY(0.97);
}

.letter-n {
    height: 300px;
    position: relative;
    transform: scaleX(1.22);
    vertical-align: baseline;
    top: 36px;
    left: -24px;
}

.letter-i {
    height: 300px;
}

.letter-t {
    height: 300px;
}

.letter-y {
    height: 300px;
    position: relative;
    right: 40px;
}
<body>

        <ul class="unity-cover">
            <div class="start-row">
                    <li class="letter letter-u">U</li>
                    <li class="letter letter-n">N</li>
            </div>

            <div class="end-row">
                    <li class="letter letter-i">I</li>
                    <li class="letter letter-t">T</li>
                    <li class="letter letter-y">Y</li>
            </div>


        </ul>

</body>

Answer №2

To achieve the desired effect, you will need to utilize the CSS transform property with the scale() function. I have made some adjustments to your CSS code in order to reflect what you intended:

* {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    font-size: 16px;
}

p {
    font-family: sans-serif;
}

li {
    list-style-type: none;
    font-family: sans-serif;
}

.unity-cover {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 2fr 2fr;
    grid-template-areas: 
    "start-row"
    "end-row";
    justify-items: center;
}

.start-row {
    grid-area: start-row;
    display: flex;
}

.end-row {
    grid-area: end-row;
    display: flex;
}

.letter {
    font-weight: bold;
    margin-right: 1px;
    font-size: 23rem;
}

.letter-u {
    height: 315px;
    position: relative;
    top: 30px;
}

.letter-n {
    height: 315px;
    position: relative;
    top: 40px;
    right: 15px;
    transform: scaleX(1.2) scaleY(1.1);
}

.letter-i {
    height: 300px;
    position: relative;
    left: 25px;
}

.letter-t {
    height: 300px;
}

.letter-y {
    height: 300px;
    position: relative;
    right: 45px;
}

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

Automatically change div background image based on window resizing

.step-1-4 { background:url('../images/gadget-4-sprite.png') no-repeat; width:950px; height:70px; margin-left: 15px; } The code above sets the CSS for a div containing a background image. The dimensions of the div match that of the imag ...

How can I link an HTML anchor to a calendar?

Is there a way to create a universal link that generates a calendar event using HTML? For example, we can create an email link with <a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ff9e9b9b8d9a8c8cbf9a879e928f9 ...

Troubleshooting: Issue with detecting keypress using jQuery

Currently, I have a jQuery script that checks password strength and changes an image source based on complexity. The functionality works smoothly within jsFiddle (set to jQuery 1.91), but when implemented on my webpage, the event seems to not be triggered. ...

Storing HTML form values for other pages in PHP and MySQLi can be achieved by using session variables or by

I recently set up a database using phpMyAdmin that includes tables for different topics such as Math, Physics, etc. Each topic is assigned a unique topic_id as the primary key in the table tb_topic. Additionally, each topic can have multiple videos associa ...

Center-aligned video text overlay that adapts to different screen sizes for a responsive design

I am looking to showcase a full-width video with overlay text that is perfectly centered both vertically and horizontally on the video. The centering should adapt to changes in viewport width so that it remains centered at all times. Additionally, I would ...

Angular17+ introduces a new feature called the Dynamic Tag Class, providing

Why isn't my navigation bar updating when the page changes? Here is my app.component.html code: <html> <app-navbar></app-navbar> <router-outlet></router-outlet> </html> This is where my navbar.component.html s ...

The slideshow feature on W3 Schools does not start automatically when the page loads

After following the W3Schools tutorial to create a slideshow, I found that the animations are working correctly. However, only three dots appear on the screen and I have to manually click on one of them to view the pictures. var slideIndex = 0; sh ...

Trigger the click event on the ul element instead of the li element using jQuery

Is there a way to make the click event only affect ul tags and not all li elements using jQuery? <!-- HTML --> <ul class="wrap"> <li>test1</li> <li>test2</li> <li>test3</li> </ul> I attemp ...

Styling with CSS: Utilizing the Float Left Property to Anchor Elements

Currently, I have implemented an anchor element that utilizes a CSS class to replace the text with an image. Despite its unusual nature, the end result is mostly satisfactory. .toolLink a { overflow:hidden; } .toolEdit { float:left; ba ...

IE encounters an absolute z-index problem when expanding concealed content

I'm having trouble with the positioning of a block (div). I am new to CSS, so any help would be greatly appreciated. Here is the code snippet: http://jsfiddle.net/9rEmt/ (please check it out) for viewing online in IE. When I use absolute for positio ...

"Encountering difficulties with certain images not loading in the keyframe slide show feature on IOS

Ensure that the image in the slide show is preloaded, followed by preloading each additional image before transitioning to the next key frame. Finally, preload the original image for the final display. I even attempted changing the last image, but encounte ...

Tips for applying CSS conditionally to content at varying nesting levels

Currently, I am working with sass and finding it challenging to modify the structure of the page easily. The layout I have in place is due to my header having varying sizes depending on the specific page users are browsing: <div class="container"> ...

CSS styles are not being applied correctly to the Bootstrap modal in combination with Leaflet

After importing leaflet-bootstrapmodal.js into my project, I am facing an issue with styling it. Take a look at the plugins listed below: <!-- Bootstrap modal--> <link rel="stylesheet" href="bootstrap-modal/bootstrap ...

Can I create personalized animations using Compass?

I am curious about how to convert this code into Compass mixins @-webkit-keyframes shake { 0% { -webkit-transform: translate(2px, 0px) rotate(0deg); } 10% { -webkit-transform: translate(-1px, 0px) rotate(-1deg); } 20% { -webkit-transform: tran ...

Struggling with the loading of intricate attribute data into an array of arrays

I am struggling with loading different data attributes into an array of arrays. I have managed to load single data attributes into the dataArray, but when it comes to the data-size which contains groups of arrays in string format, I am facing difficulties ...

What is the best way to make a table expand upwards when adding rows dynamically?

Is there a way to dynamically grow a table upwards from a fixed position instead of downwards? For example, if the first table row is at 100px, can the next one be at 110px? I'm looking for a solution to achieve this effect when adding table rows dyna ...

The jQuery hover function is not functioning properly on page load in Firefox

While this code is functioning smoothly in Chrome and IE, it seems to be encountering issues in Firefox! <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> JS: $(window).load(function(){ $("#bosti ...

Aligning a DIV using javascript

Hey everyone, I'm encountering an issue with the JavaScript on my website. I'm struggling to center the div in order to properly display the image I click on. It seems to work fine on the second attempt, but on initial click, the div always appea ...

Determine whether there is greater available space above or below a specific element within the DOM

I'm looking to create a dynamic layout where an input field is accompanied by a list in a div, positioned either above or below depending on available space. This setup needs to account for the fact that the input field could be located anywhere on th ...

Electron fails to display images in the compiled version

I'm currently troubleshooting an issue related to displaying images using CSS in my electron project. In the latest version of the application, the images are not showing up when linked from a CSS file. However, in a previous version, the images disp ...